1.bond team链路聚合
1.1bond链路聚合
- 只支持两块网卡
(1) 连路聚合应用思想:
为主机添加两块网卡,将两块网卡链路在一起,一起为bond0服务;bond0网卡为虚拟网卡,为他服务的网卡为真实网卡。多个物理端口绑定在一起当成一个逻辑端口使用,提高带宽,实现负载平衡的个功能。
-
网卡的链路聚合将多块网卡连接在一起,当一块网卡损坏时,其余网卡仍可工作,网络依旧能正常服务。
-
只需要一个ip即可,给bond0 ,但虚拟网卡有ip,即使保证与其他主机处于同一网段,也无法与其他主机通信;若想让虚拟机与真机ping通,bond0必须bond真实网卡,有ip有真实网卡才能通信。
-
链路聚合有多种模式,例如,主备模式、交替模式…
(2)bond0虚拟接口的配置:
1)systemctl start NetworkManager
NetworkManager必须是开启的才能使用命令nmcli
2)
-
nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.101/24
添加网络接口服务bond0 虚拟接口为bonf0 接口服务类型为bond 模式为主备模式 ip地址为172.25.254.101 网关为24 -
nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0
添加真实网卡eth0 真实网卡名为eth0 类型为 为bond虚拟网卡工作 网卡主人为 bond0 -
nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0
添加真实网卡eth1 真实网卡名为eth1 类型为 为bond虚拟网卡工作 网卡主人为 bond0 -
nmcli connection show
查看添加的网络接口服务
cat /proc/net/bonding/bond0
可以查看bond0虚拟接口的详细信息
测试:
1)watch -n 1 cat /proc/net/bonding/bond0
监控虚拟接口信息文件,观测接口变化
ping 172.25.254.250
观测通信是一直稳定
2)ifconfig eth0 down
将eth0网卡暂停服务,可以看到网卡eth1顶替工作 一主一备模式工作
ifconfig eth0 up
两块网卡都可以是up状态,只是使用时只能使用一块网卡
1.2team链路聚合
-
功能与bond链路聚合一样,区别是team接口最多支持八块网卡
(1)team0网络接口的配置:
1)systemctl start NetworkManager
2) -
nmcli connection add con-name team0 ifname team0 type team config ‘{“runer”:{“name”:”activebackup”}}’ip4 172.25.254.101/24
添加网络接口服务team0 其虚拟网卡为team0 网卡服务类型为 team 服务模式为主备模式 ip地址为172.25.254.101 子网掩码为24 -
nmcli connection add con-name eth0 ifname eth0 type team-slave master team0
添加网卡eth0 真实网卡为eth0 网卡服务类型为team-slave 主网卡为team0 -
nmcli connection add con-name eth1 ifname eth1 type team-slave master team0
添加真实网卡eth1 名为eth1 网卡类型为team-slave 主网卡为team0
测试:
1) watch -n 1 “teamdctl team0 stat”
监控网卡服务内部变化
ping 172.25.254.1
观测网络是否一直通信
2)ifconfig eth0 down
让真实网卡eth0停止工作,观察通信是否通畅及team0网卡内部工作的变化
2.桥接
(1)NAT与桥接的区别
- 网桥:工作在数据链路层,主机与主机之间的通信不需要ip,通过MAC通信,不需要地址转换
- NAT:工作在网络层,需要ip,主机与主机之间的通信需要地址转换,需要路由转发
相对来说,网桥的应用更快捷,nat工作更加繁琐
(2)桥接思想:
添加网桥br0,br0 与eth0同时存在,需要把ip加在br0上,eth0不用加ip ,将二者桥接实现网络连通,如果真实网卡也有ip也是不可以的
(3)桥接管理命令:
brctl 命令 | 作用 |
---|---|
brctl show | 查看网桥状态 |
brctl addbr br0 | 添加网桥 |
brctl addif br0 eth0 | 桥接网卡 |
brctl delif br0 eth0 | 删除桥接 |
(4)添加桥接准备:
nm-connection-editor
删除原先的桥接网络
(5)命令方式开启桥接(命令添加网桥是临时的,想要永久开启就写配置文件)
*在真机做实验需要备份ifcfg-eth0 与ifcfg-br0这俩个文件 防止实验失败导致恢复不了
1)brctl addbr br0
添加桥接br0
2)ifconfig br0 ip/24
为桥接添加ip,具有临时性
或者配置一个桥接配置文件 具有永久性
DEVICE=br0
IPADDR=172.25.254.101
ONBOOT=yes
BOOTPROTO=none
PREFIX=24
TYPE=Bridge
3)brctl addif br0 eth0
桥接真实物理网卡 具有临时性
永久性配置eth0网卡配置文件
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
BRIDGE=br0
4)brctl show
查看网卡桥接状态 在没有真实的物理设备桥接时 ping不通
(6)恢复无桥接状态
1)brctl delif br0 eth0
#删除网卡桥接
2)ifconfig br0 down
#停止br0的服务
3)brctl delbr br0
#删除br0
3.网络连接排错
3.1局域网连接排错
1.查看网线:是否插好
2.查看网卡状态:是否为up
3.查看ip是否处于同一网段
4.查看桥接 :桥接是否对应
3.2虚拟机与真机连接排错
1.查看网卡状态 :是否为up状态
2.查看桥接:是否桥接 桥接是否对应 虚拟机网卡为vnet0