Linux之企业高级网络配置

一、bond网络

Red Hat Enterprise Linux 允许管理员使用bonding内核模块和称为通道绑定接口的特殊网络接口将多个网络接口绑定到一个通道。根据选择的绑定模式,通道绑定使两个或更多个网络接口作为一个网络接口,从而增加带宽 | 提供冗余性

1、选择Linux以太网绑定模式

(1)模式0(平衡轮循)-轮循策略.
所有接口都使用采用轮循方式在所有slave中传输封包;任何slave都可以接受。
(2)模式1(主动备份)-容错。
一次只能使用一个slave接口,但是如果该接口出现故障,另一个slave将接替它继续工作
(3)模式3(广播)-容错。
所有封包都通过所有slave接口广播。

2、主动备份模式管理

1、添加接口

nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.133/24	##创建bond接口

nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0		##将网卡eth0添加至bond0接口

nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0		##将网卡eth1添加至bond0接口

示例:
首先保证服务机的两块网卡的纯洁性,及新网卡。
在这里插入图片描述
step1:

nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.133/24	##创建bond接口bond0

在这里插入图片描述
step2:

nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0		##将网卡eth0添加至bond0接口

在这里插入图片描述
step3:

nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0		##将网卡eth1添加至bond0接口

在这里插入图片描述
step4:

cat /proc/net/bonding/bond0		##查看bond0接口

在这里插入图片描述
模拟问题:

ifconfig eth0 down		##模拟eth0网卡损坏
ifconfig eth0 up		##添加eth0网卡

在这里插入图片描述分析:可以看到当模拟eth0网卡损坏时,eth1网卡工作,不会影响用户的使用。

ifconfig eth1 down		##模拟eth1网卡损坏
ifconfig eth1 up		##添加eth1网卡

在这里插入图片描述
分析:可以看到当模拟eth1网卡损坏时,eth0网卡工作,不会影响用户的使用。

2、删除接口

nmcli connection delete bond0		##删除bond0接口
nmcli connection delete eth0		##关闭eth0网卡bond0接口
nmcli connection delete eth1		##关闭eth1网卡bond0接口
nmcli connection show				##查看网卡接口

在这里插入图片描述

二、team网络

Team和bond 功能类似:

Team 不需要手动加载相应内核模块
Team有更强的拓展性
支持8块网卡

1、种类

<1>broadcast 广播容错
<2>roundrobin 平衡轮循
<3>activebackup 主备
<4>loadbalance 负载均衡

2、team网络的主备模式设置

nmcli connection add con-name team0 ifname team0 type team config '{"runner"{"name":"activebackup"}}' ip4 172.25.254.133/24		##添加team网络的team0接口

nmcli connection add con-name eth0 ifname eth0 type team-slave master team0			##将网卡eth0添加到team0接口

nmcli connection add con-name eth0 ifname eth0 type team-slave master team0			##将网卡eth1添加到team0接口

teamdctl team0 stat		##查看team0接口状态

示例:

首先保证服务机的两块网卡的纯洁性,及相当于新网卡。

step1:

nmcli connection add con-name team0 ifname team0 type team config '{"runner"{"name":"activebackup"}}' ip4 172.25.254.133/24

在这里插入图片描述
step:2

nmcli connection add con-name eth0 ifname eth0 type team-slave master team0

在这里插入图片描述
step:3

nmcli connection add con-name eth0 ifname eth0 type team-slave master team0

在这里插入图片描述
step:4

teamdctl team0 stat

在这里插入图片描述
分析:默认网卡eth0开始工作。

模拟问题:

ifconfig eth0 down
ifconfig eth0 up

在这里插入图片描述

ifconfig eth1 down
ifconfig eth1 up

在这里插入图片描述
分析:一块网卡不能工作后,另一块网卡继续工作,不影响用户使用。

三、设置网络桥接

实验前准备:

cd /etc/sysconfig/network-scripts/
cp ifcfg-br0 ifcfg-enp0s25 /mnt/		##备份主机原有网络配置文件,方便实验后还原

在这里插入图片描述

nm-connection-editor				##打开网络管理服务,删除原有网络桥接以及网卡
shutdown -r now				##重新启动主机

在这里插入图片描述

1、更改配置文件设置

cd /etc/sysconfig/network-scripts/		##进入网络管理目录
vim ifcfg-redhat				##添加网卡配置文件
BOOTPROTO=none
NAME=redhat
DEVICE=enp0s25
ONBOOT=yes
BRIDGE=br0
vim ifcfg-br0					##添加桥接br0配置文件
DEVICE=br0
IPADDR=172.25.254.33
PREFIX=24
ONBOOT=yes
BOOTPROTO=none
TYPE=Bridge
systemctl stop NetworkManger			##关闭网络管理服务
systemctl restart network			##重启网络服务

brctl show					##查看桥接设置

在这里插入图片描述

2、命令临时设置

1、添加桥接br0

brctl show				##查看桥接状态
brctl addbr br0				##添加网络桥接br0
ifconfig br0 172.25.254.133/24		##设置桥接IP及netmask
brctl addif br0 eth0			##将网络桥接br0与真实网卡eth0连接起来,及打开网卡eth0的网络桥接接口并与br0连接起来

在这里插入图片描述

2、删除桥接br0

brctl delif br0 eth0			##删除网卡eth0网络桥接接口
ifconfig br0 down			##卸载br0网络桥接
brctl delbr br0				##删除br0网络桥接

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_41830712/article/details/87391085