高级网络配置之bond 与 team网络接口

bond接口与team接口的区别:

bond接口:仅支持2块网卡
team接口:与bond接口功能类似,区别在于team不需要手动加载相应的内核模块,它有更强的拓展性,支持8块网卡

1.配置bond网络接口

  1. 什么是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 

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值