十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
如下图:主机A发送的报文被送到交换机S1的eth0口,由于eth0与eth2、eth3桥接在一起,故而报文被复制到eth2和eth3,并且发送出去,然后被主机B和交换机S2接收到。而S2又会将报文转发给主机C、D
可以通过多种方式实现,这里介绍通过nmcli和bridge实现。
1)添加一个名为br0的网桥,并且手工指定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设备到网桥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)启动网桥并且查看信息
[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的网桥
[root@CentOS7 ~]# brctl addbr br0
2)添加eth0、eth2设备到br0网桥
[root@CentOS7 ~]# brctl addif br0 eth0
[root@CentOS7 ~]# brctl addif br0 eth2
3)显示当前存在的网桥及其所连接的网络端口:
[root@CentOS7 network-scripts]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c29082a73 no eth0
eth2
4)启动网桥
[root@CentOS7 network-scripts]# ip link set up dev br0
5)删除网桥,需要先关闭它
[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
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。