Linux网卡绑定bond0-实验
虚拟机添加网卡
ip addr 查看新增的网卡是否读取
添加bonding接口
[root@centos8~]$nmcli con add type bond con-name mybond0 ifname bond0 mode active-backup ipv4.method manual ipv4.addresses 10.0.0.111/24 Connection 'mybond0' (9f639157-8a97-4c6e-9785-5ccaecdabdfb) successfully added.
添加从属接口
[root@centos8~]$nmcli con add type bond-slave ifname eth1 master bond0 Connection 'bond-slave-eth1' (22dd25a3-a5bc-46d9-874e-008b536c181a) successfully added. [root@centos8~]$nmcli con add type bond-slave ifname eth2 master bond0 Connection 'bond-slave-eth2' (6e662363-1adb-4511-ba8e-7ab07ba7efdb) successfully added.
注:如无为从属接口提供连接名,则该名称是接口名称加类型构成
启动绑定,则必须先启动从属接口
[root@centos8~]$nmcli con reload [root@centos8~]$nmcli con up bond-slave-eth1 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/5) [root@centos8~]$nmcli con up bond-slave-eth2 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
启动绑定
[root@centos8~]$nmcli con up mybond0 Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
测试
[root@centos8~]$ip link set eth0 down 禁用eth0 让bond0工作
[root@centos8~]$ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN group default qlen 1000 link/ether 00:50:56:33:29:8d brd ff:ff:ff:ff:ff:ff 3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP group default qlen 1000 link/ether 00:0c:29:bd:f1:80 brd ff:ff:ff:ff:ff:ff 4: eth2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP group default qlen 1000 link/ether 00:0c:29:bd:f1:80 brd ff:ff:ff:ff:ff:ff permaddr 00:0c:29:bd:f1:8a 5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 00:0c:29:bd:f1:80 brd ff:ff:ff:ff:ff:ff inet 10.0.0.111/24 brd 10.0.0.255 scope global noprefixroute bond0 valid_lft forever preferred_lft forever inet6 fe80::7f80:d8e3:83ec:8966/64 scope link noprefixroute valid_lft forever preferred_lft foreverl
两张网卡都是启用状态
断掉eht1连接