CentOs 6.4-x86-64 网络桥接配置
network config
前提:
保证有bridge-utils,若没有先安装之
# yum install bridge-utils
step1:copy the eth0 config-file to be the model of the br0
#cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scipts/ifcg-br0
step2:modify the content of the ifcfg-eth0:
#vim /etc/sysconfig/network-scripts/ifcfg-eth0
The content of the ifcfg-eth0 as bellow:
DEVICE=eth0
TYPE=Ethernet
#UUID=f21c26a1-7633-43fc-b425-7fd24db6c3de
ONBOOT=yes
#NM_CONTROLLED=yes
#BOOTPROTO=none 注释掉 BOOTPROTO
#IPADDR=10.10.84.115 注释掉
PREFIX=21
#GATEWAY=10.10.80.1 注释掉
#DNS1=10.15.3.222 注释掉
#DEFROUTE=yes 注释掉
#IPV4_FAILURE_FATAL=yes 注释掉
#IPV6INIT=no 注释掉
#NAME=”System eth0″ 注释掉
#HWADDR=00:1E:67:9C:8A:7D 注释掉
BRIDGE=br0 添加
step3:modify the ifcfg-br0
#vim /etc/sysconfig/network-scripts/ifcfg-br0
The cotent of this file as bellow:
DEVICE=br0
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.10.84.115
NETMASK=255.255.248.0
PREFIX=21
GATEWAY=10.10.80.1
DNS1=10.15.3.222
STP=on #添加
DELAY=0 #添加
step 4:stop the NetworkManager
# service NetworkManager stop
step 5:restart the network
#service network restart
ok it’s over as you can see the information of the br0 has addr and the eth0
has no addr when you type the “ifconfig” command on the commandline!
step 6: self-start when the server turn on
# echo “ifup br0” >> /etc/rc.d/rc.local |
参考资料:
http://www.zhukun.net/archives/6857
http://www.ruilog.com/blog/view/c3564dd3c776.html
实际用例
物理机桥接配置文件
物理机一:(10.10.84.115)
“/etc/sysconfig/network-scripts/ifcfg-br0”
1 DEVICE=br0
2 TYPE=Bridge
3 ONBOOT=yes
4 BOOTPROTO=static
5 IPADDR=10.10.84.115
6 NETMASK=255.255.248.0
7 PREFIX=21
8 GATEWAY=10.10.80.1
9 DNS1=10.15.3.222
10 STP=on
11 DELAY=0
“/etc/sysconfig/network-scripts/ifcfg-eth0”
1 DEVICE=eth0
2 TYPE=Ethernet
3 #UUID=f21c26a1-7633-43fc-b425-7fd24db6c3de
4 ONBOOT=yes
5 #NM_CONTROLLED=yes
6 #BOOTPROTO=none
7 #IPADDR=10.10.84.115
8 PREFIX=21
9 #GATEWAY=10.10.80.1
10 #DNS1=10.15.3.222
11 #DEFROUTE=yes
12 #IPV4_FAILURE_FATAL=yes
13 #IPV6INIT=no
14 #NAME=”System eth0″
15 #HWADDR=00:1E:67:9C:8A:7D
16 BRIDGE=br0
物理机二:(192.168.2.101)
虚拟机原机配置文件:
原机配置文件
“/etc/sysconfig/network-scripts/ifcfg-br0”
BRIDGE=br0
DEVICE=br0
HWADDR=52:54:00:11:00:60
TYPE=Bridge
UUID=b8e23c47-4a83-4740-adba-e00055044cc0
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
DNS=10.15.3.222
/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=52:54:00:11:00:60
TYPE=Ethernet
#UUID=b8e23c47-4a83-4740-adba-e00055044cc0
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
当使用克隆虚拟机时注意eth0有可能会变成eth1/eth2等非eth0
克隆机一,配置文件:
“/etc/sysconfig/network-scripts/ifcfg-br0”
DEVICE=’br0′
#HWADDR=52:54:00:11:00:60
TYPE=Bridge
#UUID=b8e23c47-4a83-4740-adba-e00055044cc0
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
NAME=”System br0″
IPADDR=10.10.83.41
GATEWAY=10.10.80.1
NETMASK=255.255.248.0
DNS1=10.15.3.222
DNS2=10.15.3.233
/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=’eth1′
#HWADDR=52:54:00:11:00:60
TYPE=Ethernet
#UUID=b8e23c47-4a83-4740-adba-e00055044cc0
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
BRIDGE=’br0′