配置bond网络接口
bond网络(支持两块网卡)
Red Hat Enterprise Linux 允许管理员使用 bonding内核模块和成为通道绑定接口的特殊网络接口将多个网络接口绑定到一个通道。根据选择的绑定模式,通道绑定使两个或更多个网络接口作为一个网络接口,从而增加宽带和 /提供称余性
选择linux以太网绑定模式
模式0 (平衡轮循)-轮寻策略,所有接口都使用采用轮寻方式在所有slave中传输封包;任何slave都可以接收
模式1(主动备份)-容错。一次只能使用一个slave接口,但是如果该接口出现故障,另一个slave将接替它
模式3(广播)-容错。所有封包都通过所有slave接口广播
实验:
##这个实验的前提是拥有两个网卡,在虚拟机原有的基础上增加一个网卡
nmcli connection delete eth0 (删除网卡配置)
nmcli connection add con-name bond0 ifname bond0(名字可以随便起) type bond mode cative-backup ip4 172.25.254.135/24(开启创建bond服务,创建的bond一个名字叫bond0 的bond端口)
ping172.25.254.135失败(由于没有提供网卡设备,所以失败)
nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0(给bond0端口添加一个新的网卡eth0)
nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0(给bond0端口添加一个新的网卡eth1)
watch -n 1 cat /proc/net/bonding/bond0(打开监控命令,监控bond0端口)
ifconfig eth0 down (当关掉这个网卡eth0之后eth1顶上继续工作)
可以通过监控命令清晰的看到当eth0网卡停止工作后,eth1顶上继续工作
ifconfig eth1 down (停止eth1网卡后,eth0顶上继续工作)
配置team接口
team接口
team和bond0功能类似
team不需要手动加载相应内核模块
team有更强的拓展性
支持8块网卡
broadcast 广播容错
roundrobin 平衡轮叫
activebackup 主备
loadbalance 负载均衡
实验:
wtch -n 1 teamdctl tem0 stat (监控tem0网络端口)
nmcli connection add con-name tem0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.135/24(添加一个名字叫做team0的team端口)
nmcli connection add con-name eth0 ifname eth0 type team-selave master team0(给team0口添加一个网卡eth0)
nmcli connection add con-name eth1 ifname eth1 type team-selave master team0(给team0口添加一个网卡eth1)
ping172.25.254.135 (ping自己能ping通,说明网卡添加成功)
ifconfig eth0 down (停止网卡eth0工作,但是依然有网络,eth1顶替eth0继续工作)
网桥的建立
真机中:
cd /etc/sysconfig/network-scripts/(切换到网络目录下)
mv ifcfg-br0 ifcfg-enp0s25 /opt/(备份这个两个网关,为了做恢复工作)
1.网络的建立
nm-connection-editor(打开网络图形,除了vibr1 vibr0 以外所有的网络和wifi全部删除)
再建立一个新的网络enternet
2.网桥的建立
把名字改为ifcfg-enp0s25
vim enp0s25(打开网桥配置文件)
DEVICE=enp0s25
ONBOOT=yes
BOOTPROTO=none
BRIDGE=br0
vim ifcfg-br0(配置网桥的网络类型)
DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.35
NETMASK=255.255.255.0
TYPE=Bridge
systemctl stop NetworkManager.service (关闭)
systemctl restart network
brctl show(查看网桥配置)
虚拟设备与真实设备之间的桥接
brctl show(显示端口)
brctl addbr br0(添加一个br0端口)
ifconfig br0 172.25.254.135/24 (添加一个br0和一个ip)
网桥的删除
ifconfig br0 down (关闭br0端口的工作)
brctl delbr br0 (删除br0端口)