# brctl addbr br-lan (建立一个逻辑网段,名称为br-lan)
我们不需要STP(生成树协议)等。因为我们只有一个路由器,是绝对不可能形成一个环的。我们可以关闭这个功能。(这样也可以减少网络环境的数据包污染):
# brctl stp br-lan off
建立一个逻辑网段之后,我们还需要为这个网段分配特定的端口。
在Linux中,一个端口实际上就是一个物理网卡。而每个物理网卡的名称则分别为eth1,eth2。
我们需要把每个网卡一一和br-lan这个网段联系起来,作为br-lan中的一个端口。
# brctl addif br-lan eth1 (让eth1成为br-lan的一个端口)
# brctl addif br-lan eth2 (让eth2成为br-lan的一个端口)
网桥的每个物理网卡作为一个端口,运行于混杂模式,而且是在链路层工作,
现在他们成了逻辑网桥设备的一部分了,所以不再需要IP地址
# ifconfig eth1 down
# ifconfig eth2 down
# ifconfig eth1 0.0.0.0 up
# ifconfig eth2 0.0.0.0 up
启用网桥
# ifconfig br-lan up
可选: 我们给这个新的桥接口分配一个IP地址
root@bridge:~> ifconfig br-lan 10.0.3.129
或者把最后这两步合成一步:
root@bridge:~> ifconfig br-lan 10.0.3.129 up
就是多一个up!
关闭网桥命令
# brctl delif br-lan eth1
# brctl delif br-lan eth2
# ifconfig br-lan down
# brctl delbr br-lan
参考 http://blog.youkuaiyun.com/wangwenwen/article/details/7479678