器量大者,福泽必厚
全部博文(587)
分类: LINUX
2013-01-31 14:16:26
创建网桥需要先确认bridge-utils是否已经安装:
[root@nfs ~]# rpm -qa | grep bridge
bridge-utils-1.2-9.el6.x86_64
如果没有安装
[root@nfs ~]# yum -y install bridge-utils 即可!
过程见附件
为什么要关闭NetworkManager服务?见附件
[root@management network-scripts]# cat ifcfg-eth0
DEVICE="eth0"NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=00:E0:6F:12:B2:FD
TYPE=Ethernet
BOOTPROTO=none
IPADDR=192.168.1.61
PREFIX=24
GATEWAY=192.168.1.1
DNS1=61.177.7.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
BRIDGE=br0 ##需要添加到行,注意BRIDGE为大写
同时如果有HWADDR=***的行,将其删除!
2:修改后的文件内容如下:
[root@management network-scripts]# cat ifcfg-br0
DEVICE=br0 ##必须修改
NM_CONTROLLED="yes"
ONBOOT=yes
TYPE="Bridge" ##必须修改
BOOTPROTO=none
IPADDR=192.168.1.61
PREFIX=24
GATEWAY=192.168.1.1
DNS1=61.177.7.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System br0" ##最好修改
## 同时如果有HWADDR=***的行,将其删除!
3:重启网络服务就可以了!
[root@management network-scripts]# ifconfig
br0 Link encap:Ethernet HWaddr 00:E0:6F:12:B2:FD
inet addr:192.168.1.61 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::2e0:6fff:fe12:b2fd/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1523 errors:0 dropped:0 overruns:0 frame:0
TX packets:568 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:309189 (301.9 KiB) TX bytes:387108 (378.0 KiB)
eth0 Link encap:Ethernet HWaddr 00:E0:6F:12:B2:FD
inet6 addr: fe80::2e0:6fff:fe12:b2fd/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:10466 errors:0 dropped:0 overruns:0 frame:0
TX packets:1608 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2823948 (2.6 MiB) TX bytes:520656 (508.4 KiB)
Interrupt:28 Base address:0xc000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:503616 errors:0 dropped:0 overruns:0 frame:0
TX packets:503616 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:70646930 (67.3 MiB) TX bytes:70646930 (67.3 MiB)
virbr0 Link encap:Ethernet HWaddr 52:54:00:27:6F:AB
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:96 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:8934 (8.7 KiB)
##显然已经有了br接口, 它的ip地址为192.168.1.61 ,现在eth0已经没有地址了!
配置过程中遇到一个问题!/etc/sysconfig/network-scripts/ifup-eth: Device br0 does not seem to be present,
原因:我在配置网桥模式的时候,仅仅在ifcfg-eth0中加入BRIDGE=br0和修改ifcfg-br0的DEVICE=br0,而没有修改TYPE="Bridge" ,结果导致出现上面的问题!
而且要提醒的是必须在ifcfg-eth0中加入BRIDGE=br0 行,注意BRIDGE的大小写。