首页 > 技术文章 > linux 网络配置

zhengyipengyou 2018-08-12 18:47 原文

链路聚合:多个网卡聚合到一起.
bond与team两种方法。
bond: 0平衡轮循环 1主动备份   
实验步骤
bond网络接口;
该网络接口同时支持连接到两块网卡,并且有不同的使用方式。
roundrobin                                       平衡轮询模式:两块网卡同时接受数据。
activebackup                                    主动备份模式:只有一块网卡工作。

nmcli connection show           查看网卡接口
nmcli connection delete "eth0"删除已有的接口

 


添加网络接口bond0
nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.103/24

 


将eth0网卡添加到接口bond0中
nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0
将eth1网卡添加到网络接口中
nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0

 


测试
watch -n 1 cat /proc/net/bonding/bond0

 


ifconfig eth0 down/up 
通过执行此命令会发现当一块网卡停止工作时,另一块网卡会自动顶替之前工作的网卡,网络连接不中断 
------------------------------------------------------------
删除之前的接口。

 


team 支持8块网卡。
删除之前的bond接口。
nmcli connection delete bond0
nmcli connection delete eth0
nmcli connection delete eth1
创建team接口
nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.10/24

 

创建连接team的网卡接口
nmcli connection add con-name eth0 ifname eth0 type team-slave master team0
nmcli connection add con-name eth1 ifname eth1 type team-slave master team0

 


测试:
teamctl team0 stat

 

 

删除
nmcli connection delete team0
nmcli connection delete eth0
nmcli connection delete eth1
------------------------------------------------------------
网络桥接
用于虚拟化
桥接接口

vim /etc/sysconfig/network-scrpits/ifcfg-enp0s25
BOOTPROTO=none
DEVICE=enp0s25
ONBOOT=yes
BRIDGE=br0

 

vim /etc/sysconfig/network-scrpits/ifcfg-br0
DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.4
PREFIX=24
TYPE=Bridge

 

systemctl restart network
检测:
brctl show

 

 

推荐阅读