网卡链路聚合之bond
什么是网卡链路聚合
网卡链路聚合可以有效地防止当一块网卡损坏后,依旧可以继续访问网络,同时提高了网速。
配置
1.配置网卡
首先给虚拟机配置两块网卡
2.删除所有网络配置
nm-connection-editor ##删除eth0网络配置
此时可以看出eth0和eth1都没有配置网络
3.设置链路聚合
nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.141/24 ##设置bond0链路,ip为172.25.254.141
4.添加网卡
nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0 ##给bond0添加网卡eth0
nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0 ##给bond0添加网卡eth1
5.监控
watch -n 1 cat /proc/bonding/bond0 ##监控bond0状态
测试
ifconfig eth0 down ##关闭eth0网卡
发现依旧在ping,没有任何影响,但bond0的工作网卡换为eth1
反之
ifconfig eth0 up ##开启eth0网卡
ifconfig eth1 down ##关闭eth0网卡
依旧能ping,没有任何影响,只有bond0的工作网卡切换了