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桥接接口

猜你喜欢

转载自blog.csdn.net/qq_38449802/article/details/81698889