一、链路聚合
实现接口稳定性;接口宽度不够时增宽网卡。
先准备双网卡虚拟机,将网卡ip删除
有两种方法:
1.bond
命令方式建立bond
建立bond0
nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.108/24
active-backup:主动备份,当网卡不能正常工作则自动替换。
监控命令
watch -n 1 cat /proc/net/bonding/bond0 ##bond状态
将两个网卡放在bond,最多可以添加2个网卡
nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0
nmcli connection add con-name eth0 ifname eth0 type bond-sla
ve master bond0
成功添加之后测试:
ping 主机
关掉eth0:ifconfig eth0 down
正常运行
文件方式建立bond
先将上一步文件和网络配置删除
nm-connection-editor—>删除bond0。
建立
cd /etc/sysconfig/network-scripts
vim ifcfg-bond0
vim ifcfg-eth0
systemctl restart network
systemctl restart NetworkManger
测试
2.team
##team的主动备份
可以增加更多的网卡(最多可以添加八块)
命令建立team0
建立
先将上一步文件和网络配置删除
nmcli connection add con-name team0 ifname team0 type team config ‘{“runner”:{“name”:“activebackup”}}’ ip4 172.25.254.108/24
监控命令
watch -n 1 teamdctl team0 stat
team0建立成功。
添加网卡
将两个网卡作为主动备份,team最多可以添加8个网卡
测试
文件方式建立team0
先将上一步文件和网络配置删除
vim ifcfg-team0
vim ifcfg-eth0
vim ifcfg-eth1
systemctl restart network
systemctl restart NetworkManger
测试
二、桥接
1.桥接的作用
把虚拟机的虚拟网卡通过内核直接连接到真实网卡上,掠过NAT,让解析变得更快。
1.将ifcfg-br0 和 ifcfg-enp0s25 备份并删除。
mv ifcfg-br0 ifcfg-enp0s25 /mnt
2.打开网络管理(nm-connection-editor)
删除除了 Bridge下virbr0 和virbr1 以外的所有内容。
重启电脑。
3.设定ip
设定主机网卡ip确保可以联网。
4.主机桥接设定
vim ifcfg-enp0s25
vim ifcfg-br0
成功之后可以打开虚拟机。
5.虚拟机桥接设定
brctl show ##查看桥接情况
brctl addbr ##添加bridge
ifconfig br0 172.25.254.108/24 ##给br0添加ip
ping主机 ##ping不通 因为没有添加网卡接口
brctl addif br0 eth0 ##添加网卡接口
ping主机 ##可以ping通 实验成功
删除设定
brctl delif br0 eth0 ##摘除网卡接口
ifconfig br0 down ##关闭
brctl delbr br0