linux中的高级网络配置

一:######bond######   链路聚合主动备份网卡,当一个网卡接口故障时,另一个会接替他的工作,不中断。
1:为虚拟机添加第二块网卡

2:删除虚拟机原有的网络配置      ##nmcli connection delete eth0


3:添加bond接口,必须添加过bond接口后,/proc/net/中才会出现bonding目录

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


4:为bond添加第一块网卡设备eth0   ###添加网卡设备之后才可以ping通网络

nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0


5:添加第二块网卡设备eth1

nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0


6:监控bond0

watch -n 1 cat /proc/net/bonding/bond0   #####bonding目录下的文件全部是bond0的信息


7:添加的两块网卡设备一块使用一块备用,当第一块损坏后第二块直接顶替
在监控命令下打开另外一个shell 关闭使用中的网卡设备,可以看到备用网卡直接顶替关掉的网卡

ifconfig eth0 down ###关掉网卡设备


ifconfig eth0 up   ###启用网卡设备                                                                 

二:######team#########

1:删掉bond0网络配置和eth0.1


2:添加team接口

nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.103/24


3:为team添加网卡设备
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


4:监控team0

watch -n 1 cat teamdctl team0 stat

5:在监控命令下打开另外一个shell 关闭使用中的网卡设备,可以看到备用网卡直接顶替关掉的网卡

ifconfig eth0 down ###关掉网卡设备

三:########搭建网桥####   ####在真机里面做###
1:进入 /etc/sysconfig/network-scripts

mv ifcfg-br0 ifcfg-enp0s31f6 /opt


2:nm-connectin-editor

删掉除了virtio以外其他的所有东西


3:重新设定一个网络然后重启


4:vim ifcfg-enp0s31f6
写入:
DEVICE=enp0s31f6
ONBOOT=yes
BOOTPROTO=none
BRIDGE=br0

5:vim ifcfg-br0


写入:
DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.66.250
PREFIX=24

TYPE=Bridge


6:systemctl stop NetworkManager.service
systemctl restart network

7:brctl show


验证网桥是否搭建成功
virt-manager

安装虚拟机看可不可以选择br0一行


四:########虚拟机中#####
1:brctl addbr br0     添加
brctl show
ifconfig
ifconfig br0 172.25.254.103/24
ifconfig br0

ping 172.25.254.3   ping不通


brctl addif br0 eth0   将br0桥接在eth0上

ping 172.25.254.3     可以ping通


ifconfig br0 down

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





猜你喜欢

转载自blog.csdn.net/gd0306/article/details/80398903