1、配置bond网络接口
bond网络
Red Hat Enterprise Linux 允许管理员使用 bonding 内核模块和称为通道绑定接口的特殊网络接口将多个网络接口绑定到一个通道。根据选择绑定模式,通过绑定是两个网络接口作为一个网络接口,从而增加带宽和或者提供冗余性
选择 Linux 以太网绑定模式
模式0(平衡轮循)——轮循策略,所有接口都使用采用轮循方式在所有 Slave 中传输封包;任何 Slave 都可以接受
模式1(主动备份)——容错。一次只能使用一个 Slave 接口,但是如果该接口出现故障,另一个 Slave 将接替它
模式3(广播)——容错。所有封包都通过所有 Slave 接口广播
利用 nmcli 命令管理 bond
主动备份,建立绑定接口:
nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 1.2.3.4/24
建立 Slave 接口:
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
主动备份,2块网卡,不能对网卡进行加密
bond的配置文件/etc/sysconfig/network-scripts/ifcfg-bond0
实验如下:
首先 virt-manager 添加网卡
终端1:
nmcli connection delete //清空网卡
ifconfig //查看是否清空
建立绑定接口bond0:
这时因为没有网络接口是 ping 不通的,如下图所示:
然后我们添加网络接口 eth0 和 eth1 ,其中eth1是防止 eth0 接口出现故障而接替它,这时候就可以 ping 通了
终端2:
打开监控查看网卡使用情况:
监控显示如下,eth0 在工作状态,eth1 处于候补状态:
终端1:
破坏eth0,监控eth1是否代替其工作
[root@locathost Desktop]# ifconfig eth0 down //破坏eth0
监控显示如下,eth1 代替 eth0 工作:
[root@locathost Desktop]# ifconfig eth0 up //添加上eth0,eth0 处于候补状态
删除bond网络接口
首先删除绑定接口:
nmcli connection delete bond0
然后删除网络接口:
nmcli connection delete eth0
nmcli connection delete eth1
实验如下:
2、配置team网络接口
Team
Team 和 bond 功能相似,Team 不需要手动加载相应的内核模块,有更强的扩展性,支持8快网卡
种类有:broadcast 广播容错、roundrobin 平衡轮叫、activebackup 主备、loadbalance 负载均衡
通过 nmcli 设定 team
建立 team
nmcli connection add con-name team0 ifname team0 type team config ‘{“runner”:{“name”:“activebackup”}}’ ip4 1.2.3.4/24
添加网络接口:
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
实验如下:
终端1:
建立 team ,这时因为没有网络接口是 ping 不通的:
然后我们添加网络接口 eth0 和 eth1 ,其中eth1是防止 eth0 接口出现故障而接替它,这时候就可以 ping 通了
终端2:
打开监控查看网卡使用情况:
监控显示如下,eth0 在工作状态,eth1 处于候补状态:
终端1:
破坏eth0,监控eth1是否代替其工作
[root@locathost Desktop]# ifconfig eth0 down //破坏eth0
监控显示如下,eth1 代替 eth0 工作:
[root@locathost Desktop]# ifconfig eth0 up //添加上eth0,eth0 处于候补状态
3、配置网络桥接
网络桥接
网络桥接用网络桥实现共享上网主机和客户机除了利用软件外,还可以用系统自带的网络桥接建立连接用双网卡的机器做主机
网络桥接配置
vim /etc/sysconfig/network-scripts/ifcfg-eth0
BRIDGE=br0
vim /etc/sysconfig/network-scripts/ifcfg-br0
TYPE=Bridge
网络桥接的管理命令
brctl #桥接管理命令
show #显示
addbr #添加网桥
delbr #删除网桥
addif #添加网桥连接
delif #删除网桥连接
######命令方式添加网桥实验如下:
首先在添加网桥之前将网络关闭:
添加网桥连接 br0
当ping 不通时,是没有网卡,当我们添加了网卡,就可以 ping 通了