bond接口与team接口的区别:
bond接口:仅支持2块网卡
team接口:与bond接口功能类似,区别在于team不需要手动加载相应的内核模块,它有更强的拓展性,支持8块网卡
1.配置bond网络接口
- 什么是bond?
网卡bond是通过多张网卡绑定为一个逻辑网卡,实现本地网卡的冗余,带宽扩容和负载均衡,在生产场景中是一种常用的技术。 |
2 .bond常用的2种模式?
mode=0(balance-rr) |
表示负载分担round-robin,并且是轮询的方式比如第一个包走eth0,第二个包走eth1,直到数据包发送完毕。
优点:流量提高一倍
缺点:需要接入交换机做端口聚合,否则可能无法使用
mode=1(active-backup) |
表示主备模式,即同时只有1块网卡在工作。
优点:冗余性高
缺点:链路利用率低,两块网卡只有1块在工作
1.命令的方式
(1)打开图形,并手动添加网卡
[root@foundation34 ~]# virt-manager
成功:
##如果设备的上有ip,则需要先删除设备上的ip
[root@localhost ~]# ifconfig
(2)添加bond接口
[root@localhost ~]# nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.134/24
[root@localhost ~]# ifconfig
##查看bond0接口信息
[root@localhost ~]# cat /proc/net/bonding/bond0
监控:
[root@localhost ~]# watch -n 1 cat /proc/net/bonding/bond0
[root@localhost Desktop]# nmcli connection show
(3)给bond0接口添加eth0网卡设备
[root@localhost ~]# nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0
[root@foundation34 ~]# ping 172.25.254.102
(4)给bond0接口添加eth1网卡设备
[root@localhost ~]# nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0
[root@localhost Desktop]# nmcli connection show
测试:
@1模拟破坏eth0网卡设备
[root@localhost Desktop]# ifconfig eth0 down
[root@foundation34 ~]# ping 172.25.254.102 仍然可以ping通
@恢复网卡eth0
[root@localhost Desktop]# ifconfig eth0 up
2.配置team网络接口
概述:
1.什么是team?
team实现的功能跟bond相似,team本质上也是一个虚拟的网卡驱动(networkdevicedriver), 只不过并没有真实的物理网卡与之对应,而是由这个虚拟网卡去“管辖”一系列的真实的物理网卡, 它的代码结构和一般网卡驱动的代码结构非常类似。 实验: |
1.命令的方式
(1)添加team接口
[root@localhost Desktop]# nmcli connection add con-name team0 ifname team0 type team config \
>'{"runner":{"name":"activebackup"}}' \
> ip4 172.25.254.134/24
[root@localhost Desktop]# ifconfig
(2)给team0接口添加eth0网卡设备
[root@localhost Desktop]# nmcli connection add con-name eth0 ifname eth0 type team-slave master team0
(3)给team0接口添加eth1网卡设备
[root@localhost Desktop]# nmcli connection add con-name eth1 ifname eth1 type team-slave master team0
[root@localhost Desktop]# nmcli connection show
[root@foundation34 ~]# ping 172.25.254.102
还原实验环境:
##直接删除配置文件
[root@localhost Desktop]# rm -rf /etc/sysconfig/network-scripts/ifcfg-team0
[root@localhost Desktop]# rm -rf /etc/sysconfig/network-scripts/ifcfg-eth0
[root@localhost Desktop]# rm -rf /etc/sysconfig/network-scripts/ifcfg-eth1
##必须重启网络,才能生效
[root@localhost ~]# systemctl restart network
[root@localhost ~]# nmcli connection show