网卡绑定bond0的实现
1、虚拟机添加一张网卡
2、通过ip a可以看到多了一张eth1网卡
3、创建bond0
[root@rocky8-1 ~]#nmcli connection add type bond con-name mybond0 ifname bond0 mode active-backup ipv4.method manual ipv4.address 192.168.177.100/24 #添加bonding接口,模式为主备模式并设置ip Connection 'mybond0' (f081fbd6-f844-4bcd-99cf-3d9d9d47c063) successfully added. [root@rocky8-1 ~]#nmcli connection add type bond-slave ifname eth0 master bond0 #添加从属接口eth0 Connection 'bond-slave-eth0' (3b9dcf40-da25-4045-8f67-03b93d3dabce) successfully added. [root@rocky8-1 ~]#nmcli connection add type bond-slave ifname eth1 master bond0 #添加从属接口eth1 Connection 'bond-slave-eth1' (efd8ed09-bbd9-4500-8a3b-11d0f9afaf14) successfully added. [root@rocky8-1 ~]#nmcli connection NAME UUID TYPE DEVICE eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 ethernet eth0 mybond0 f081fbd6-f844-4bcd-99cf-3d9d9d47c063 bond bond0 virbr0 7d51fad9-62e3-4890-848d-464a8f8001b0 bridge virbr0 bond-slave-eth1 efd8ed09-bbd9-4500-8a3b-11d0f9afaf14 ethernet eth1 bond-slave-eth0 3b9dcf40-da25-4045-8f67-03b93d3dabce ethernet -- [root@rocky8-1 ~]#ls /etc/sysconfig/network-scripts/ ifcfg-bond-slave-eth0 ifcfg-bond-slave-eth1 ifcfg-eth0 ifcfg-mybond0
[root@rocky8-1 ~]#nmcli connection up bond-slave-eth0 #先启动从属接口eth0
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
[root@rocky8-1 ~]#nmcli connection up bond-slave-eth1 #启动从属接口eth1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
[root@rocky8-1 ~]#nmcli conn up mybond0 #启动绑定
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8)
通过ip a命令可以看到eth0 eth1网卡已经没有ip地址,mac地址相同
[root@rocky8-1 ~]#cat /proc/net/bonding/bond0 #查看此文件看到当前主网卡是eth0,eth1为备用 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011) Bonding Mode: fault-tolerance (active-backup) Primary Slave: None Currently Active Slave: eth0 MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Peer Notification Delay (ms): 0 Slave Interface: eth0 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:49:e3:f9 Slave queue ID: 0 Slave Interface: eth1 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:49:e3:03 Slave queue ID: 0
断开eth0接口可看到网络丢了一个包重新连上
将eth0启用,断开eth1,可看到网络丢一个包后重连正常
将2个网卡都断开后网络中断