Linux的网络高级配置——bond、team、桥接的建立

 一.bond和team

1.网络配置文件目录  /etc/sysconfig/network-scripts/

2.备份网络配置文件(ifcfg-enp5s0     ifcfg-br0)

   ifcfg-enp5s0      ##网卡配置文件

   ifcfg-br0             ##桥接配置文件

   mv    /etc/sysconfig/network-scripts/ ifcfg-enp5s0   ifcfg-br0   /mnt

3.bond的建立

    给虚拟机配置两块网卡

nmcli connection show         ##查看网卡接口信息

nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.124/24        

##设置接口名称为bond0的bond主备模式网络配置,ip为172.25.254.124,子网延码为255.255.255.0

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通网络

4.bond的替补

watch -n 1 cat /proc/net/bonding/bond0     ##监控bond0接口信息

正在工作的是eth0网卡,eth0和eth1工作状态正常

ifconfig eth0 down      ##eht1就会接替上去

5.删除bond接口

nmcli connection delete bond0    ##删除bond0接口

nmcli connection delete eth0       ##删除eth0网卡

nmcli connection delete eth1       ##删除eth1网卡

6.team的建立

nmcli connection add con-name team0 ifname team0 type team config  '{"runner":{"name":"activebackup"}}'  ip4 172.25.254.124/24        ##设置接口名称为team0的team主备模式网络配置,ip为172.25.254.124,子网延码为255.255.255.0

nmcli connection add con-name eth0 ifname eth0 type team-slave master team0  添加eth0网卡

nmcli connection add con-name eth1 ifname eth1 type team-slave master team0  添加eth1网卡

teamdctl team0 stat        ##查看team0接口信息

ping 172.25.254.24

ifconfig eth0 down

7.删除team接口

nmcli connection delete eth0   删除eth0
nmcli connection delete eth1   删除eth1
nmcli connection delete team0  删除team0

 

二、网络桥接

1.主机中网桥的建立

mv    /etc/sysconfig/network-scripts/ ifcfg-enp5s0   ifcfg-br0   /mnt

nm-connection-editor打开网络图形配置,删除掉除了virbr0和virbr1的所有接口信息

cd /etc/sysconfig/network-scripts/

systemctl restart network

vim ifcfg-westos  

vim ifcfg-br0   

systemctl restart network

brctl show    ##查看桥接接口

恢复之前的配置文件:

rm -fr ifcfg-westos ifcfg-br0

[root@foundation24 network-scripts]# mv /mnt/ifcf*

 

三.临时桥接(虚拟机)

brctl   show ##查看虚拟机桥接信息 

brctl addbr br0      ##添加br0桥接接口

ifconfig br0 172.25.254.224/24    ##设定br0接口的临时IP

brctl addif br0 eth0                    ##将br0接口添加到网卡设备eth0上

brctl show        ##查看网卡接口信息

ping 172.25.254.24

 

四.临时网桥的删除

brctl delif br0 eth0         ##将br0接口从网卡eth0上卸下

ifconfig br0 down          ##关闭br0桥接接口停止桥接接口工作后才能删除

brctl delbr br0               ##删除br0桥接接口

 

 

 

 

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值