Linux高级网络配置链路聚合与桥接

版权声明:皆为本人原创,复制必究 https://blog.csdn.net/m493096871/article/details/84228146

链路聚合:两个网卡邦在一起
balance-rr 轮循  任务轮流来  增快传输速率
active-backup  只是自己当作备用  使接口更稳定

ping不通还需要物理设备的支持
bond-slave  为bond接口服务 需要两个接口 因为两个网卡

操作命令
nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.213/24
 
这时候会自动生成  /proc/net/bonding/bond0
采用  watch -n 1 cat /proc/net/bonding/bond0
这里是先加一个连接bond类型  
下面添加两块网卡

nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0
nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0  
因为是slave 所以得有主人 master 

这时候
ifconfig down  eth0  或者 eth1   还会可以ping通
ifconfig up eth1 就恢复了
你只有用真机ping虚拟机才行  


nmcli connection delete eth1
nmcli connection delete eth0
nmcli connection delete bond0
nmcli connection show 
就删掉了

/etc/sysconfig/network-scripts
文本形式添加ifcfg-bond0

DEVICE=bond0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.100
NETMASK=255.255.255.0
TYPE=Bond
BONDING_OPTS=mode=active-backup

添加文件  ifcfg-eth1  ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0


DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0


然后systelclt restart network

扫描二维码关注公众号,回复: 4140195 查看本文章

以上都是链路聚合中的bonding

红帽还出了 team链路聚合

team  
支持负载均衡()
 哈希加密
bond 不支持加密  不支持负载均衡  不支持哈希加密

下面是team的操作
team是纯软件  
 
nmcli connectiong add con-name team0 ifname team0 type team \ config '{"runner":{"name":"activebackup"}}'  ip4 172.25.254.213/24
查看状态
watch -n 1 teamdctl team0  stat
添加网卡
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


文件格式添加
DEVICE=team0
TEAM_CONFG="{\"runner\":{\"name\":\"activebackup\"}}"
DEVICETYPE=Team
BOOTPROTO=none
IPADDR=172.25.254.213
PREFIX=24
NAME=team0
ONBOOT=yes

DEVICE=eth0 
BOOTPROTO=none
ONBOOT=yes
TEAM_MASTER=team0
DEVICETYPE=TeanPort


DEVICE=eth1 
BOOTPROTO=none
ONBOOT=yes
TEAM_MASTER=team0
DEVICETYPE=TeanPort

不可以将DEVICETYPE  换为TYPE


 
/etc/sysconfig/network-scripts
vim  ifcfg-enp0s25

DEVICE=enp0s25
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.13
NETMASK=255.255.255.0

nat地址转换 会影响速度和内核负载  降低真实主机速度

桥接
可以让虚拟机通过内核直接连接网卡
网桥  虚拟机直接通过真实网卡,设定的ip 和真机是同等级别

首先修改
/etc/sysconfig/network-scripts/
vim ifcfg-enp0s25

DEVICE=enp0s25
ONBOOT=yes
BOOTPROTO=none
BRIDGE=br0   br0名字后的数字随意


然后建立br0桥

DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.13
NETMASK=255.255.255.0
TYPE=Bridge


重启网络就可以了

恢复的时候  删除br0  修改enp0s25


DEVICE=enp0s25
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.13
NETMASK=255.255.255.0


重启网络即可


命令方式添加桥接

brctl addbr br0
ifconfig br0 172.25.254.13/24
brctl addif br0 eth0
brctl show


删除桥的操作

ficonfig br0 down 
brctl delif br0 eth0
brctl delbr br0
brctl  show

猜你喜欢

转载自blog.csdn.net/m493096871/article/details/84228146