CentOS配置网桥模式

参考网页:http://www.2cto.com/os/201302/189949.html

1、创建桥接器 

在/etc/sysconfig/network-scripts目录下,创建一个ifcfg-br0 文件,其类型设为Bridge:

例:

DEVICE=br0

BOOTPROTO=static

BROADCAST=192.168.110.255

IPADDR=192.168.110.205

NETMASK=255.255.255.0

NETWORK=192.168.110.0

ONBOOT=yes

GATEWAY=192.168.110.1

TYPE=Bridge

2、将物理接口桥接到桥接器

修改eth0的内容(本服务器是用eth0上网的),去掉其IP相关信息,加上“BRIDGE=br0”,将其桥接到br0上;如果是双网卡或是多网卡,照此过程修改:

DEVICE=eth0

#BOOTPROTO=static

#BROADCAST=192.168.110.255

HWADDR=00:30:48:F1:7C:3A

#IPADDR=192.168.110.205

#NETMASK=255.255.255.0

#NETWORK=192.168.110.0

ONBOOT=yes

#GATEWAY=192.168.110.1

#TYPE=Ethernet

BRIDGE=br0

3、重启物理机网络服务 

[root@virt ~]# service network restart

错误提示:

Device bond0 does not seem to be present, delaying initialization.

4.加载网桥驱动

[root@virt ~]# modprobe bridge

5、查看当前桥接情况

[root@virt ~]# brctl show

6、将虚拟机接口桥接到桥接器

brctl delif virbr0 vnet0

 brctl addif br0 vnet0

[root@virt ~]# brctl show

bridge name     bridge id               STP enabled     interfaces

br0             8000.003048f17c3a       no              eth0

                                                        vnet0

virbr0          8000.000000000000       yes

7

如果从网桥模式转换成普通网卡模式:

Shutting down interface eth0: bridge br0 is still up; can't delete it

这个时候还需要手动卸载驱动模块!!

[root@virt ~]# rmmod bridge

 

你可能感兴趣的:(接口,服务器,网卡,信息,网桥)