前期环境准备
[root@ /root] alibaba cloud
#cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@ /root] alibaba cloud
#uname -r
3.10.0-693.el7.x86_64
网卡信息
[root@ /root] alibaba cloud
#ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:89:03:4d brd ff:ff:ff:ff:ff:ff
inet 192.168.152.130/24 brd 192.168.152.255 scope global dynamic ens33
valid_lft 1593sec preferred_lft 1593sec
inet6 fe80::20c:29ff:fe89:34d/64 scope link
valid_lft forever preferred_lft forever
3: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:89:03:57 brd ff:ff:ff:ff:ff:ff
inet 192.168.152.131/24 brd 192.168.152.255 scope global dynamic ens37
valid_lft 1594sec preferred_lft 1594sec
inet6 fe80::d906:e1fd:f3c2:8123/64 scope link
valid_lft forever preferred_lft forever
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
link/ether 02:42:c2:91:09:77 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 scope global docker0
valid_lft forever preferred_lft forever
备份网卡
[root@ /etc/sysconfig/network-scripts] alibaba cloud
#cp ifcfg-en* /tmp/net_bak
配置bond(ens33 ens37做bond)
[root@ /etc/sysconfig/network-scripts] alibaba cloud
# nmcli connection add type bond ifname bond0 mode 1
连接“bond-bond0”(a513378e-d0f3-4ad8-9026-b8426f3a1d03) 已成功添加。
[root@ /etc/sysconfig/network-scripts] alibaba cloud
#ls |grep bon
ifcfg-bond-bond0
[root@ /etc/sysconfig/network-scripts] alibaba cloud
#nmcli connection add type bond-slave ifname ens33 master bond0
连接“bond-slave-ens33”(7f562877-cd8e-4ba9-8811-71cb3952e200) 已成功添加。
[root@ /etc/sysconfig/network-scripts] alibaba cloud
#nmcli connection add type bond-slave ifname ens37 master bond0
连接“bond-slave-ens37”(40950158-17cd-4eca-aec8-58cc346a9467) 已成功添加。
[root@ /etc/sysconfig/network-scripts] alibaba cloud
#ls |grep bond
ifcfg-bond-bond0
ifcfg-bond-slave-ens33
ifcfg-bond-slave-ens37
[root@ /etc/sysconfig/network-scripts] alibaba cloud
#cat ifcfg-bond-bond0
DEVICE=bond0
BONDING_OPTS=mode=active-backup
TYPE=Bond
BONDING_MASTER=yes
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
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=bond-bond0
UUID=a513378e-d0f3-4ad8-9026-b8426f3a1d03
ONBOOT=yes
IPADDR=192.168.152.99
NETMASK=255.255.255.0
GATEWAY=192.168.152.2
[root@ /etc/sysconfig/network-scripts] alibaba cloud
#ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
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: ens33: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
link/ether 00:0c:29:89:03:4d brd ff:ff:ff:ff:ff:ff
3: ens37: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
link/ether 00:0c:29:89:03:4d brd ff:ff:ff:ff:ff:ff
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
link/ether 02:42:cd:a7:04:3a brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 scope global docker0
valid_lft forever preferred_lft forever
6: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
link/ether 00:0c:29:89:03:4d brd ff:ff:ff:ff:ff:ff
inet 192.168.152.99/24 brd 192.168.152.255 scope global bond0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe89:34d/64 scope link
valid_lft forever preferred_lft forever
删除bond
查看网卡设备
[root@ /sys/class/net] alibaba cloud
#echo -bond0 > bonding_masters