测试环境 Oracle Virtual Box5.1
操作系统 RHEL7.2
网卡状态
[root@higsin ~]# nmcli device status
DEVICE TYPE STATE CONNECTION
virbr0 bridge connected virbr0
enp0s3 ethernet connected enp0s3
lo loopback unmanaged --
virbr0-nic tap unmanaged --
先参考红帽官方给出的绑定方案:https://access.redhat.com/articles/172483?tdsourcetag=s_pctim_aiomsg
Configuring bonded devices on Red Hat Enterprise Linux 7
* man 7 nmcli-examples is a good way for us. Here are the detailed steps:
* Add a bond device:
* Raw
nmcli con add type bond ifname <bond-name> mode active-backup
(There are 6 types of bonding mode 802.3ad/balance-alb/balance-tlb/broadcast/active-backup/balance-rr/balance-xor.)
此处提出的六种绑定模式请参考博主另一篇博客:
https://blog.csdn.net/pg_hgdb/article/details/81945856
* Set up ip-address for bond device.
* Raw
nmcli connection modify <bond-name> ipv4.addresses <ip-address>
* Set a static IP for bond device.
* Raw
nmcli connection modify <bond-name> ipv4.method manual
* Add bond-slave to bond device.
* Raw
nmcli con add type bond-slave ifname <ethx> master <bond-name>
* Add another slave to bond device.
* Raw
nmcli con add type bond-slave ifname <ethx> master <bond-name>
* Show configuration.
* Raw
nmcli connection show
操作记录:
添加绑定设备:
nmcli con add type bond ifname t1 mode active-backup
Connection ‘bond-t1’ (52b0dd91-53a6-48ef-b435-ace77c1a4f9d) successfully added.
为设备设置IP地址:
nmcli connection modify bond-t1 ipv4.addresses 192.168.80.21 ipv4.gateway 192.168.80.254
为设备设置静态IP:
nmcli connection modify bond-t1 ipv4.method manual
[root@higsin network-scripts]# cat ifcfg-bond-t1
DEVICE=t1
TYPE=Bond
BONDING_MASTER=yes
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=bond-t1
UUID=52b0dd91-53a6-48ef-b435-ace77c1a4f9d
ONBOOT=yes
BONDING_OPTS=mode=active-backup
IPADDR=192.168.80.21
PREFIX=32
GATEWAY=192.168.80.254
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
网卡绑定,添加bond-slave到绑定设备
[root@higsin network-scripts]# nmcli con add type bond-slave ifname enp0s3 master bond-t1
Connection ‘bond-slave-enp0s3’ (36373b27-d0e1-45b5-9dd5-d703d4cd2f8d) successfully added.
[root@higsin network-scripts]# nmcli con add type bond-slave ifname enp0s8 master bond-t1
Connection ‘bond-slave-enp0s8’ (3daf50d2-14a2-404f-8074-835fcac60ff3) successfully added.
显示连接状态:
[root@higsin ~]# nmcli con sh
NAME UUID TYPE DEVICE
enp0s3 08f2cb95-8643-4dcc-9729-088d08ea9806 802-3-ethernet --
virbr0 6cafb384-0d25-4bec-9cdc-c9a378450fe2 bridge virbr0
bond-slave-enp0s8 3daf50d2-14a2-404f-8074-835fcac60ff3 802-3-ethernet enp0s8
bond-slave-enp0s3 36373b27-d0e1-45b5-9dd5-d703d4cd2f8d 802-3-ethernet enp0s3
bond-t1 52b0dd91-53a6-48ef-b435-ace77c1a4f9d bond t1
设备状态:
[root@higsin ~]# nmcli dev st
DEVICE TYPE STATE CONNECTION
t1 bond connected bond-t1
virbr0 bridge connected virbr0
enp0s3 ethernet connected bond-slave-enp0s3
enp0s8 ethernet connected bond-slave-enp0s8
lo loopback unmanaged --
virbr0-nic tap unmanaged --
如果要删除一些网卡绑定配置:
[root@higsin network-scripts]# nmcli connection delete bond-bond1
Connection ‘bond-bond1’ (f8f09b2a-bfd6-4e19-8f3e-c24e33e50e20) successfully deleted.
BY 海无涯