配置网络桥接,bond 接口和 team 接口
1.网络桥接:
网络桥接用网络桥实现共享上网主机和客户机除了利用软件外,还可以用系统自带的网络桥建立连接,用双网卡的机器作主机。
配置网络桥接
网络桥接的管理命令
brctl 桥接管理命令
show 显示
addbr 添加网桥
delbr 删除网桥
addif 添加网桥连接
delif 删除网桥连接
初始化状态下是默认没有网桥的

eth0是网卡,lo是回环接口。没有br0
brctl show 当前没有桥接

brctl addbr br0 添加一个br0之后就有了桥接

此时没有真实的物理设备与至对应,搭建的br0只是一个空壳

ifconfig br0 172.25.254.103/24 给空壳的br0添加一个与之对应的ip及子网掩码

图形化界面删除eth0

brctl addif br0 eth0 添加一个新的网桥连接

br0的删除
brctl delif br0 eth0
brctl show 先删除搭建的连接

ifconfig br0 down
brctl show 关掉br0
brctl delbr br0 删除br0
systemctl restart network 重启网络服务
ifconfig 查看状态

以配置文件的形式搭建网桥
#1)在真实主机,模拟安装系统后最原始的状态
cd /etc/sysconfig/network-scripts/
mv ifcfg-br0 ifcfg-enp0s25 /mnt/ 做好备份,以便还原
vim ifcfg-enp0s25
DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.24
NETMASK=255.255.255.0
TYPE=Bridge
systemctl restart network
#2)在虚拟机内
直接配置
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.103
NETMASK=255.255.255.0
TYPE=Bridge
systemctl restart network
########################################
2.配置bond 接口
Red Hat Enterprise Linux允许管理员使用 bonding内核模块和称为通道绑定接口的特殊网络接口将多个网络接口绑定到一个通道。根据选择的绑定模式,通道绑定使两个或更多网络接口作为一个网络接口,从而增加逮狂和/提供冗余性。
bond 只支持俩块网卡
选择Llinux 以太网绑定模式:
模式一:平衡轮循,所有接口都使用采用轮循方式在所有Slave中传输封包;任何Slave都可以接收。
模式二:主动备份,一次只能使用一个Slave接口,但是如果该接口出现故障,另一个Slave将接替它。
模式三:广播,所有封包都通过所有Slave接口广播
例:
nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.103/24
创建bond0

添加网卡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

watch -n 1 'cat /proc/net/bonding/bond0' 监控命令方便查看效果

开启另一个shell进行命令的调试(最好能有三个shell,一个监控一个ping ip ,一个进行命令调试)

关闭了eth0后,因为搭建了bond的缘故,在eth0关闭的状态下直接切换到eth1工作,ping ip的信号未曾中断
再次打开eth0 因为eth1还在正常工作,所以不会自动从eth1切换至eth0

删除bond0 的网卡
nmcli connection delete eth0
nmcli connection delete eth1
#########################################
3.配置team 的网络接口
Team的特性:
Team和bond0功能类似
Team不需要手动加载相应内核模块
Team有更强的拓展性
支持8块网卡
Team的种类:
broadcast 广播容错
roundrobin 平衡轮叫
activebackup 主备
loadbalance 负载均衡
创建team0
nmcli connection add con-name team0 type team ifname team0 config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.103/24

添加网卡eth0 和 eth1
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

watch -n 1 ' teamdctl team0 state ' 监控命令

再打开俩个shell一个ping ip 一个进行命令的调试

同样,关闭eth0后,直接切换至eth1进行工作,不会产生中断
打开eth0 ,在eth1正常工作的情况下,也不会切换回eth0


491

被折叠的 条评论
为什么被折叠?



