linux高级网络配置

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

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


检查网络    systemctl status NetworkManager


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


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

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

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

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

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

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

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

 

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


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


3.查看接口工作   teamdctl team0 stat

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

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

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

 

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


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


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


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


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


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


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

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


2.建立桥接接口 brctl addbr br0


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


5.配置桥接网卡 brctl addif br0 eth0


6.检查网络连接状态 ping 主机IP地址

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

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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值