使用网桥功能的示例
进行图4-1的网桥连接时的操作如下。如果在经由作为设置对象的网络接口之一连接(ssh等)的状态下实施这个作业,需要注意有时会由于网络接口IP地址更换的时机等而无法进行网络断开的操作。
1.生成网桥设备br0。
brctl addbr br0
2.向网桥设备分配IP地址。
ifconfg br0 10.1.0.100 netmask 255.255.255.0 broadcast 10.1.0.255 up
3.将eth0连接到网桥br0。
brctl addif br0 eth0
4.将eth0激活。
ifconfg eth0 up
5.同样对eth1~eth3进行操作3、4。
brctl addif br0 eth1
ifconfg eth1 up
brctl addif br0 eth2
ifconfg eth2 up
brctl addif br0 eth3
ifconfg eth3 up
通过以上操作,网络接口的网桥连接就完成了。brctl show显示的网桥状态如下所示。
brctl show
bridge name bridge id STP enabled interfaces
br0 8000.545200006400 no eth0
eth1
eth2
eth3