linux高级网络配置

一.链路聚合(bond接口和team接口)

添加网卡    virt-manager        #bond接口环境需要两块网卡,team接口需要至少两块至多八块

linux高级网络配置
检查网络    systemctl status NetworkManager

linux高级网络配置
删除本机  eth0 nmcli connection delete "System eth0"
查看网络配置    nmcli connection show

linux高级网络配置


bond接口:
1.新建bond接口   nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 IP地址/24

linux高级网络配置

2.网卡阵列    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

linux高级网络配置

3.查看接口工作 cat /proc/net/bonding/bond0
#建立监视窗口 watch -n 1 cat /proc/net/bonding/bond0

linux高级网络配置

  • 此时eth0工作,eth0出现问题时,eth1马上接替其工作:

linux高级网络配置

linux高级网络配置

  • 此时eth1工作,eth0恢复后,依旧eth1工作:

linux高级网络配置

  • 此时eth1工作,eth1出现问题时,eth0接替eth1的工作:

linux高级网络配置

4.删除网卡及接口 nmcli connection delete 部分名称

linux高级网络配置

 

team接口:
1.新建team接口  nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip4 IP地址/24

linux高级网络配置
2.网卡阵列   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

linux高级网络配置
3.查看接口工作   teamdctl team0 stat

linux高级网络配置

  • 此时eth0工作,eth0出现问题时,eth1马上接替eth0工作:

linux高级网络配置

  • 此时eth1工作,eth0修复后,eth1继续工作:

linux高级网络配置

  • 此时eth1工作,eth1出现问题后。eth0马上接替eth1工作:

linux高级网络配置

 

二.配置网络桥段
#ifconfig查看本机网络配置文件名称,不同主机网络配置文件名称不同
1.网络配置文件目录   /etc/sysconfig/network-scripts/

linux高级网络配置
2.备份网络配置文件(ifcfg-br0  ifcfg-enp0s25)     mv ifcfg-br0 ifcfg-enp0s25 /backup

linux高级网络配置
3.删除原有网络桥段并配置本机IP   nm-connection-editor

linux高级网络配置

linux高级网络配置
4.新建网卡配置文件(ifcfg-名称)
1 BOOTPROTO=none
2 DEVICE=enp0s25
3 ONBOOT=yes
4 BRIDGE=br0

linux高级网络配置
5.新建网桥配置文件(ifcfg-br0)
1 DEVICE=br0
2 ONBOOT=yes
3 BOOTPROTO=none
4 IPADDR=本机IP地址
5 PREFIX=24
6 TYPE=Bridge

linux高级网络配置
6.重启网络服务 systemctl restart network
7.查看配置的网络桥段 brctl show

linux高级网络配置
#实验后删除新增配置文件,移动回原有配置文件,保持机器本身环境不变

三.配置虚拟机临时桥接接口
1.查看主机桥接信息 brctl show

linux高级网络配置
2.建立桥接接口 brctl addbr br0

linux高级网络配置
3.配置br0文件 ifconfig br0 172.25.254.122/24
4.查看桥接信息 brctl show

linux高级网络配置
5.配置桥接网卡 brctl addif br0 eth0

linux高级网络配置
6.检查网络连接状态 ping 主机IP地址

linux高级网络配置

7.删除桥接连接 brctl delif br0 eth0

停止网桥接口工作 ifcongig br0 down   #必须先停止接口工作才能删除调网桥接口
删除桥接接口 brctl delbr br0

linux高级网络配置