Linux网卡绑定bond0 - 实验

Linux网卡绑定bond0 - 实验

添加虚拟网卡

[04:13:53 root@centos8[ ~]#ip addr #查看新增网卡是否被读取

添加bonding接口

[04:35:36 root@centos8[ ~]#nmcli con add type bond con-name mybond0 ifname bond0 mode active-backup ipv4.method manual ipv4.addresses 10.0.0.101/24

添加从属接口

[04:35:31 root@centos8[ ~]#ipv4.method manual ipv4.addresses 10.0.0.100/24^C
[04:35:36 root@centos8[ ~]#nmcli con add type bond-slave ifname eth1 master bond0
Connection 'bond-slave-eth1' (3cb5245a-c8d6-4449-ab86-0d20d5111da5) successfully added.
[04:38:11 root@centos8[ ~]#nmcli con add type bond-slave ifname eth2 master bond0
Connection 'bond-slave-eth2' (808bd20c-fc15-4f01-a8ea-697493ecc116) successfully added.
#注:如无为从属接口提供连接名,则该名称是接口名称加类型构成

启动绑定,必须先启动从属接口

[04:38:22 root@centos8[ ~]#nmcli con reload #修改配置文件执行生效
[05:08:49 root@centos8[ ~]#nmcli  con up bond-slave-eth1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8)
[05:09:39 root@centos8[ ~]#nmcli  con up bond-slave-eth2
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/9)

启动绑定

[05:09:48 root@centos8[ ~]#nmcli con up mybond0 
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/10)

测试

[02:59:31 root@centos8[ ~]#ip link set  eth0 down #禁用eth0 让bond工作
[04:27:29 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 fq_codel state DOWN group default qlen 1000
    link/ether 00:0c:29:d0:79:b0 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bond0 state UP group default qlen 1000
    link/ether 00:0c:29:d0:79:ba brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bond0 state UP group default qlen 1000
    link/ether 00:0c:29:d0:79:ba brd ff:ff:ff:ff:ff:ff permaddr 00:0c:29:d0:79:c4
6: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:29:d0:79:ba brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.101/24 brd 10.0.0.255 scope global dynamic noprefixroute bond0
       valid_lft 1397sec preferred_lft 1397sec
    inet6 fe80::6ef7:555f:fe4a:eb6f/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

断开eth0

模拟物理断开eth1

连接正常

posted @ 2022-06-27 17:15  醉酒画忧愁  阅读(204)  评论(0编辑  收藏  举报