网卡绑定的模式
- 模式0:balance-rr
- 模式1:active-backup
- 模式2:balance-xor
- 模式3:broadcast
- 模式4:802.3ad
- 模式5:balance-tlb
- 模式6:balance-alb
常用以下4种模式
- 模式0:轮询(流量在两个网卡之间一边一个)
- 模式1:主备(流量走一个网卡,另一个网卡standby)
- 模式3:广播(流量复制2份,从两个网卡分别发送)
- 模式6:适应性负载均衡(流量占满一个网卡,然后再占第二个)
模式1和模式6不需要对端交换机配置
模式0和模式3需要对端交换机配置EtherChannel
方法一:通过nmcli命令实现绑定网卡
添加绑定接口
[root@sre01 ~]# nmcli connection add type bond con-name bond0 ifname bond0 mode active-backup ipv4.method manual ipv4.addresses 12.12.12.12/24
Connection 'bond0' (3aade552-1e96-4701-b9ba-adf8b37cd91c) successfully added.
添加从属接口
[root@sre01 ~]# nmcli connection add type bond-slave ifname ens37 master bond0
Connection 'bond-slave-ens37' (cf156391-e98f-4f98-8154-7b73123e411e) successfully added.
[root@sre01 ~]# nmcli connection add type bond-slave ifname ens38 master bond0
Connection 'bond-slave-ens38' (04287791-99ef-46d4-bb12-f7f60ae08600) successfully added.
启动接口
[root@sre01 ~]# nmcli connection up bond-slave-ens37
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
[root@sre01 ~]# nmcli connection up bond-slave-ens38
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
[root@sre01 ~]# nmcli connection up bond0
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8)
删除绑定
[root@sre01 network-scripts]# nmcli connection down bond0
[root@sre01 network-scripts]# nmcli connection delete bond-slave-ens37
Connection 'bond-slave-ens37' (cf156391-e98f-4f98-8154-7b73123e411e) successfully deleted.
[root@sre01 network-scripts]# nmcli connection delete bond-slave-ens38
Connection 'bond-slave-ens38' (04287791-99ef-46d4-bb12-f7f60ae08600) successfully deleted.
[root@sre01 network-scripts]# nmcli connection delete bond0
Connection 'bond0' (3aade552-1e96-4701-b9ba-adf8b37cd91c) successfully deleted.
[root@sre01 network-scripts]# nmcli connection
NAME UUID TYPE DEVICE
ens33 7791cb1b-8774-49e8-8eaa-fa131ab6c509 ethernet ens33
demo 83e8c326-356c-46e6-b83e-bdef791c5eb7 ethernet ens36
Wired connection 1 4b15b5a3-1649-3890-ad4e-66b4b5b52933 ethernet ens37
Wired connection 2 d2f61a05-feb5-3967-9c26-7f86c551f1ac ethernet ens38
[root@sre01 network-scripts]#
方法二:通过编辑配置文件实现绑定网卡
[root@sre01 network-scripts]# cat ifcfg-bond0
BONDING_OPTS=mode=active-backup
TYPE=Bond
BONDING_MASTER=yes
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
IPADDR=12.12.12.12
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=bond0
UUID=3aade552-1e96-4701-b9ba-adf8b37cd91c
DEVICE=bond0
ONBOOT=yes
[root@sre01 network-scripts]# cat ifcfg-ens37
cat: ifcfg-ens37: No such file or directory
[root@sre01 network-scripts]# cat ifcfg-bond-slave-ens37
TYPE=Ethernet
NAME=bond-slave-ens37
UUID=cf156391-e98f-4f98-8154-7b73123e411e
DEVICE=ens37
ONBOOT=yes
MASTER=bond0
SLAVE=yes
[root@sre01 network-scripts]# cat ifcfg-bond-slave-ens38
TYPE=Ethernet
NAME=bond-slave-ens38
UUID=04287791-99ef-46d4-bb12-f7f60ae08600
DEVICE=ens38
ONBOOT=yes
MASTER=bond0
SLAVE=yes
启用
[root@sre01 network-scripts]# nmcli connection reload
标签:sre01,bond0,Centos,connection,网卡,bonding,slave,root,bond
From: https://blog.51cto.com/zywqs/12166871