如下圖:主機A發(fā)送的報文被送到交換機S1的eth0口,由于eth0與eth2、eth3橋接在一起,故而報文被復(fù)制到eth2和eth3,并且發(fā)送出去,然后被主機B和交換機S2接收到。而S2又會將報文轉(zhuǎn)發(fā)給主機C、D
成都創(chuàng)新互聯(lián)專注于灌云網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供灌云營銷型網(wǎng)站建設(shè),灌云網(wǎng)站制作、灌云網(wǎng)頁設(shè)計、灌云網(wǎng)站官網(wǎng)定制、小程序定制開發(fā)服務(wù),打造灌云網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供灌云網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。
可以通過多種方式實現(xiàn),這里介紹通過nmcli和bridge實現(xiàn)。
1)添加一個名為br0的網(wǎng)橋,并且手工指定ip為192.168.8.100
[root@CentOS7 ~]# brctl show
bridge name bridge id STP enabled interfaces
[root@CentOS7 ~]# nmcli con add con-name br0 type bridge ifname br0
Connection 'br0' (77a81012-0760-441a-a90a-8f4b357c5dfb) successfully added.
[root@CentOS7 ~]# nmcli con modify br0 ipv4.addresses 192.168.8.100/24 ipv4.method m
anual
2)添加eth0、eth2設(shè)備到網(wǎng)橋br0
[root@CentOS7 ~]# nmcli con add con-name br0-port0 type bridge-slave ifname eth0 master br0
Connection 'br0-port0' (60961b5d-312c-49dd-b9ff-287f8236436b) successfully added.
[root@CentOS7 ~]# nmcli con add con-name br0-port1 type bridge-slave ifname eth2 master br0
Connection 'br0-port1' (e4b436f2-8bc5-4696-ad6d-bdcb3ec40a0f) successfully added.
3)啟動網(wǎng)橋并且查看信息
[root@CentOS7 ~]# nmcli con up br0
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/32
[root@CentOS7 ~]# nmcli device show br0
GENERAL.DEVICE: br0
GENERAL.TYPE: bridge
GENERAL.HWADDR: E6:CF:41:C0:93:74
GENERAL.MTU: 1500
GENERAL.STATE: 100 (connected)
GENERAL.CONNECTION: br0
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/32
IP4.ADDRESS[1]: 192.168.8.100/24
IP4.GATEWAY: --
IP4.ROUTE[1]: dst = 192.168.8.0/24, nh = 0.0.0.0, mt = 425
IP6.GATEWAY: --
4)查看其生成的配置文件
[root@CentOS7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-br0
[root@CentOS7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-br0-port0
[root@CentOS7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-br0-port1
該工具需要安裝bridge-utils包
[root@CentOS7 ~]# rpm -qf `which brctl`
bridge-utils-1.5-9.el7.x86_64
[root@CentOS7 ~]# yum -y install bridge-utils
1)新建一個名為br0的網(wǎng)橋
[root@CentOS7 ~]# brctl addbr br0
2)添加eth0、eth2設(shè)備到br0網(wǎng)橋
[root@CentOS7 ~]# brctl addif br0 eth0
[root@CentOS7 ~]# brctl addif br0 eth2
3)顯示當(dāng)前存在的網(wǎng)橋及其所連接的網(wǎng)絡(luò)端口:
[root@CentOS7 network-scripts]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c29082a73 no eth0
eth2
4)啟動網(wǎng)橋
[root@CentOS7 network-scripts]# ip link set up dev br0
5)刪除網(wǎng)橋,需要先關(guān)閉它
[root@CentOS7 network-scripts]# ip link set dev br0 down
[root@CentOS7 network-scripts]# brctl delbr br0
[root@CentOS7 network-scripts]# brctl show
bridge name bridge id STP enabled interfaces