网络桥接用网络桥实现共享上网主机和客户机除了利用软件外还可以用系统自带的网络桥建立连接用双网卡的机器做主机
1. 在真机中添加网桥
目的:使在一个局域网中的主机能够直接进行数据传输
cd /etc/sysconfig/network-script/
vim ifcfg-br0 ##配置网桥
vim ifcfg-en4ps0 ##配置物理网卡
systemctl restart network
建立完网桥后,创建虚拟机时就会在选择网络中有所创建的网桥
2. 网桥连接
brctl show ##显示网桥
brctl addbr br0 ##添加网桥br0
ifconfig br0 172.25.254.190 netmask 255.255.255.0 ##给网桥ip和子网掩码
brctl addif br0 eth0 ##添加网桥连接
ifconfig br0 down ##关闭网桥
brctl delif br0 eth0 ##删除网桥连接
brctl delbr br0 ##删除网桥
3. 链路聚合
目的:将两个网卡进行链路绑定,当一个网卡突然坏掉时,绑定的另一个网卡即能及时替补上去,从而让主机能够继续正常运行。
a. bonding链路聚合
创建bond链接
nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.10/24
测试:ping 172.25.254.10
发现虽然bond0上面给了ip,但ping不通。是因为bond0上面缺少物理网卡的支持
在bond链接中加入两个网卡eth0与eth1
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 172.25.254.10
ifconfig eth0 down ##关闭eth1这个网卡
ping 172.25.254.90 依然可以Ping通 是因为eth1网卡立即上去替换了eth0
ifconfig eth1 up ##开启eth0这个网卡
会发现工作的依旧是eth0,说明这两个网卡之间并不存在优先级
bonding链路聚合可以有效的控制两个网卡,让其进行多模式的工作,但是他限制了最多添加的网卡为两块.
注意:可以watch -n 1 cat /proc/net/bonding/bond0 来监控哪个网卡正在被使用
b. team链路聚合
*team的种类
broadcast ##广播容错
roundrobin ##平衡轮叫
activebackup ##主备
loadbalance ##负载均衡
创建team链路
nmcli connection add con-name team0 ifname team0 config’{“runner”:{“name”:”activebackup”}}’ ip4 172.25.254.10/24
teamdctl team0 state ##查看team链路的状态
添加网卡到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
测试可以和bonding链路的形式一样