Linux——高级网络控制

来源:互联网 发布:scanner java 编辑:程序博客网 时间:2024/05/16 12:54

网络桥接bridge

mv ifcfg-br0 ifcfg-enp0s25 /mnt/ ##保存文件
这里写图片描述
vim ifcfg-enp0s25
这里写图片描述

reboot

ifconfig
这里写图片描述

systemctl stop NetworkManager.service

vim ifcfg-enp0s25
这里写图片描述

vim ifcfg-br0
这里写图片描述

systemctl restart network
这里写图片描述
ifconfig ##重启后br0启用成功
这里写图片描述
rm -rf ifcfg-enp0s25 ifcfg-br0 ##还原
mv /mnt/ifcfg-* .
reboot

网络接口

nm-connection-editor ##删除eth0
brctl show ##查看接口
brctl addbr br0 ##添加br0
ifconfig br0 172.25.254.108 netmask 255.255.255.0 ##配置br0
ping 172.25.254.250 ##网络不通
这里写图片描述
brctl addif br0 eth0 ##添加物理接口
ping 172.25.254.250 ##网络通畅
这里写图片描述
ifconfig br0 down ##去掉br0
brctl delbr br0 ##去掉br0
brctl show ##再次查看
这里写图片描述

bond主备

添加网卡
nm-connection-editor ##清除环境
systemctl start NetworkManager
nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.108/24 ##添加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
ping 172.25.254.250 ##网络通畅
这里写图片描述
ifconfig
这里写图片描述
ifconfig eth0 down ##将eth0关掉
ping 172.25.254.250 ##网络依然通畅
这里写图片描述

team主备

nm-connection-editor
nmcli connection delete bond0
nmcli connection delete eth0
nmcli connection delete eth1 ##清除环境

nmcli connection add con-name team0 type team ifname team0 config ‘{“runner”:{“name”:”activebackup”}}’ ip4 172.25.254.108/24
这里写图片描述
ifconfig
这里写图片描述
teamdctl team0 state ##查看team状态
这里写图片描述
nmcli connection add con-name eth0 ifname eth0 type team-slave master team0
ping 172.25.254.250 ##添加eth0后网络通畅
这里写图片描述
nmcli connection add con-name eth1 ifname eth1 type team-slave master team0
ping 172.25.254.250 ##再次添加eth1后网络依然通畅
这里写图片描述
ifconfig eth0 down ##将eth0关掉
ping 172.25.254.250 ##网络通畅
这里写图片描述
teamdctl team0 state ##查看team状态