Unit 3.2 高级网络配置

本文详细介绍如何使用bond和team进行链路聚合,实现网络接口的负载均衡与故障转移;并介绍了网络桥接的两种配置方法,一种是通过修改配置文件实现,另一种是利用brctl命令进行动态管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#####Unit3.2 高级网络配置######



1.bond

nmcli connection add con-name bond0  ifname bond0 type bond mode active-backup ip4 172.25.254.124/24      ##添加主动备份模式的bond0,ip4为172.25.254.124


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


然后 ifconfig eth0 down  ##断开eth0


eth1会接替eth0,并且网络始终没有断开




2.team
1).team也是链路聚合的一种方式,最多支持8块网卡
支持模式
broadcast    广播容错
roundrobin   轮询
activebackup 主备
loadbalance  负载均衡

2).配置
nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.124/24          ##建立team网络接口
nmcli connection add con-name eth0 ifname eth0 type team-slave master team0  ##建立网卡eth0

nmcli connection add con-name eth1 ifname eth1 type team-slave master team0  ##建立网卡eth1



3).测试

watch -n 1 teamdctl team0 stat

ifconfig


ifconfig eth0 down

ifconfig eth0 up



3.网络桥接
root权限下
cd /etc/sysconfig/network-scripts/

mv ifcfg-enp0s25 ifcfg-br0  /mnt      ##备份


vim ifcfg-enp0s25
DEVICE=enp0s25
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.24
NETMASK=255.255.255.0
systemctl stop NetworkManager.service
systemctl restart network
配置方式
vim /etc/sysconfig/network-scripts/ifcfg-enp0s25
DEVICE=enp0s25         ##设备名称
ONBOOT=yes             ##开启服务设备自动激活
BOOTPROTO=none         ##网卡工作状态

BRIDGE=br0             ##网卡开启的网络接口



vim /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.24
NETMASK=255.255.255.0

TYPE=Bridge            ##网络接口类型是桥接



systemctl stop NetworkManager.service
systemctl restart network

systemctl start NetworkManager


ifconfig查看可以看到br0,然后安装虚拟机速度加快



4.命令管理方式
1).添加
systemctl stop NetworkManager
brctl show
brctl addbr br0       ##添加网桥br0       
brctl addif br0 eth0  ##给网桥添加网卡eth0
ifconfig eth0 up      ##开启网卡eth0
ifconfig br0 172.25.254.124 netmask 255.255.255.0
brctl show            ##查看网桥配置

ping 172.25.254.24


2).删除
ifconfig br0 down     ##关闭网桥
brctl delif br0 eth0  ##删除br0网桥重的eth0网卡
brctl delbr br0       ##删除网桥br0

brctl show



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值