高级网络配置(网络桥接 、bond 网络接口 、 team 网络接口)

bond网络

bond内核模块和称为通道绑定接口的特殊网络,接口将多个网络接口绑定到一个通道。根据选择的绑定模式,通道绑定使两个或者更多个网络接口作为一个网络接口,从而增加带宽或者提供冗余性
绑定模式选定linux以太网绑定模式
模式0(平衡轮循) - 轮循策略,所有 接口都采用轮循方式在所有slave中传输封包,任何slave都可以接收
模式1(主动备份) - 容错,  一次只能使用一个slave接口,但是如果该接口出现故障,另一个slave将接替它
模式3(广播) - 容错, 所有封包都将通过所有slave接口广播

首先添加一块网卡,然后删除网络


nmcli connection  delete   "System eth0"  (网络名,可以用两下tab补齐)  删除网络
ifconfig
添加bond网络(此时并不能ping通其他人)

nmcli connection add con-name  bond0  ifname bond0(自己起的名字)  type bond mode active-backup  ip4  172.25.254.155/24


监控命令
watch  -n 1 cat /proc/net/bonding/bond0
给bond下添加网络接口
nmcli connection  add con-name eth0 ifname eth0 type bond-slave master  bond0      添加网络接口eth0  
nmcli connection  add con-name eth1 ifname eth1 type bond-slave master  bond0       添加网络接口eth1

(此时有了网络可以ping通别人)


使其中某一个接口坏掉观察工作模式,恢复之后观察
ifconfig  eth0 down    使网络接口eth0 坏掉   

ifconfig  eth0  up          使网络接口eth0 恢复


删除bond网络
nmcli connection delete bond0
nmcli connection delete eth0

nmcli connection delete eth1


team 网络

team和bond0 功能类似
team不需要手动加载相应内核模块
team 有更强的拓展性
支持8块网卡

team 的种类
broadcast    广播容错
roundrobin   平衡轮叫
activebackup  主备
loadbalance    负载均衡

监控命令:watch -n 1 teamdctl team0 stat
添加team

nmcli  connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.113/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


使其中某一个接口坏掉观察工作模式,恢复之后再观察
ifconfig  eth0 down

ifconfig  eth0  up




网桥的建立
mv ifcfg-br0   ifcfg-enp0s25   /opt/
nm-connection-editorzhon
真机里面的网络bridge里只删除enp****,前面的enternet和wifi里面都删除
1、创建网络
nm-connection-editor
cd /etc/systemconfig/network-scripts
ls
2、建立网桥
vim enp0s25

DEVICE=enp0s25
ONBOOT=yes
BOOTPROTO=none
BRIDGE=br0



vim ifcfg-br0

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


systemctl stop NetworkManager.service
systemctl restart network
 



brctl show   (显示已建立网桥)

3、网桥的删除
cd /etc/sysconfig/network-scripts
rm -fr ifcfg-br0
rm -fr ifcfg-enp0s25
 ls
mv /opt/ifcfg-*   .

reboot
虚拟机
brctl show    查看是否有网络桥接
brctl addbr  br0    添加桥接设备br0
brctl  show    
ifconfig  br0 172.25.254.113/24  为桥接设置ip
ping不通
brctl   addif br0  eth0   添加网络接口eth0到br0
brctl show
ping通
brctl delif br0 eth0     将eth0接口从br0上卸下来
ifconfig   br0 down      使br0关掉停止使用
brctl delbr  br0         删掉桥接设备br0

brctl show




猜你喜欢

转载自blog.csdn.net/xdmaidou/article/details/80409620
今日推荐