2023.6.7 02.⽹路进阶管理

1.1 Linux7配置bond聚合链路
1.2 LInux7配置team聚合链路
1.3 Linux7配置brige桥接⽹络
1.4 Linux6配置bond链路聚合
Atuor: Wing
 
管理聚合链路和桥接⽹络s
通过⽹⼝绑定技术 Bonding ,实现⽹络冗余, 负载均衡, 从⽽提升⽹络传输能⼒,避免⽹络链路单点故障, 达到⾼可⽤
⾼可靠的⽬的。
Bonding 的两种绑定⼯作模式:实际上有7种,其他不常⽤
模式0 balance-rr 负载轮询(
 
2⽹卡单独都是100MB,聚合为1个⽹络传输带宽200MB)
模式1 active-backup ⾼可⽤(其中⼀条线若断线,其他线路将会⾃动备援)
1.1 Linux7配置bond聚合链路
完成 bond0, balance-rr
--> eth0 ----\
app --发送数据到--> bond0 <---> switch
--> eth1 ----/
centos7`系统配置链路聚合`bond
[root@wing ~]# nmcli device
DEVICE TYPE STATE CONNECTION
ens32 ethernet connected ens32
ens36 ethernet disconnected --
ens37 ethernet disconnected --
//创建bond0, 模式为balance-rr
[root@wing ~]# nmcli connection add type bond \
mode balance-rr con-name bond0 ifname bond0 \
ipv4.method manual \
ipv4.addresses 192.168.69.223/24 \
ipv4.gateway 192.168.69.1 \
ipv4.dns 8.8.8.8
//添加物理⽹卡连接⾄bond0
[root@wing ~]# nmcli connection add type bond-slave \
con-name bond-slave36 ifname ens36 master bond0
 
[root@wing ~]# nmcli connection add type bond-slave \
con-name bond-slave37 ifname ens37 master bond0
//查看bond配置信息
[root@wing ~]# cat /proc/net/bonding/bond0
//关闭ens36⽹卡, 测试bond0是否正常
[root@wing ~]# nmcli device disconnect ens36
完成 bond1, active-backup
[root@wing ~]# nmcli device
DEVICE TYPE STATE CONNECTION
ens32 ethernet connected ens32
ens36 ethernet disconnected --
ens37 ethernet disconnected --
 
//创建bond1相关设备
[root@wing ~]# nmcli connection add type bond \
con-name bond1 ifname bond1 mode active-backup \
ipv4.method manual ipv4.addresses '192.168.69.222/24' \
ipv4.gateway='192.168.69.2' ipv4.dns='192.168.69.2'
//添加连接⾄bond1
[root@wing ~]# nmcli connection add type bond-slave \
con-name bond-slave36 ifname ens36 master bond1
[root@wing ~]# nmcli connection add type bond-slave \
con-name bond-slave37 ifname ens37 master bond1
//启⽤相关连接
[root@wing ~]# nmcli connection up bond1
[root@wing ~]# nmcli connection up bond-slave36
[root@wing ~]# nmcli connection up bond-slave37
//验证
[root@wing ~]# cat /proc/net/bonding/bond1
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: ens36 //⽬前是ens36⽹卡提供⽀撑
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: ens36
 
1.2 LInux7配置team聚合链路
centos7/rhce7 使⽤ teaming 实现聚合链路,能够提供⽹卡绑定之后的⽹络吞吐性能,并且提供⽹卡的故障切换处
理能⼒。
Team 是基于⼀个⼩型内核驱动实现聚合链路,在⽤户层提供 teamd 命令实现链路管理。
teamd 可以实现以下模式的聚合链路
broadcast ⼴播容错
roundrobin 负载轮询
activebackup 主备(必考)
loadbalance 负载均衡
lacp 需要交换机⽀持lacp协议
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:34:92:06
Slave queue ID: 0
Slave Interface: ens37
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:34:92:10
Slave queue ID: 0
//停⽌ens36物理⽹卡设备
[root@wing ~]# nmcli device disconnect ens36
//ens37物理⽹卡设备会进⾏⾃动切换
[root@wing ~]# grep "Currently Active Slave" /proc/net/bonding/bond1
Currently Active Slave: ens37
//考试建议使⽤命令⾏配置,图形界⾯配置不稳定
[root@wing ~]# nmcli connection add type team con-name team0 ifname team0 \
config '{"runner":{"name":"activebackup"}}' \
ipv4.addresses 192.168.56.111/24 \
ipv4.gateway 192.168.56.2 \
ipv4.dns 192.168.56.2 ipv4.method manual
[root@wing ~]# nmcli connection add type team-slave \
con-name team0-port1 ifname eth1 master team0
[root@wing ~]# nmcli connection add type team-slave \
con-name team0-port2 ifname eth2 master team0
 
动态修改team模式
1.3 Linux7配置brige桥接⽹络
建⽴桥接接⼝
1.4 Linux6配置bond链路聚合
//检查team0状态
[root@wing ~]# ping -I team0 192.168.56.1
[root@wing ~]# teamdctl team0 state
//断掉后检测
[root@wing ~]# nmcli dev disconnect eth1
[root@wing ~]# teamdctl team0 state
// 导出配置进⾏修改 (man teamd.conf)
[root@wing ~]# teamdctl team0 config dump > /tmp/team.conf
[root@wing ~]# vim /tmp/team.conf
//以最新修改的配置选项修改team0属性
[root@wing ~]# nmcli con mod team0 team.config /tmp/team.conf
//修改之后需要重启team0
[root@wing ~]# nmcli connection down team0;nmcli connection up team0
[root@wing ~]# nmcli connection up team0-port1
[root@wing ~]# nmcli connection up team0-port2
+------eth0-----+
| | |
| [ br0 ] |
| | |
| +--eth0--+ |
| | vm | |
| +--------+ |
+---------------+
创建桥接⽹络br1
[root@wing ~]# nmcli connection add type bridge \
con-name br1 ifname br1 \
ipv4.addresses 192.168.56.222/24 ipv4.method manual
桥接⾄eth1
[root@wing ~]# nmcli connection add type bridge-slave \
con-name br1-port1 ifname eth1 master br1
[root@wing ~]# ping -I br1 192.168.56.1
[root@wing ~]# brctl show
 
1.4 Linux6配置bond链路聚合
适⽤于 RedHat6 以及 CentOS6

 

//1.创建绑定⽹卡配置⽂件
[root@wing ~]# cat ifcfg-bond0
DEVICE=bond0
TYPE=Ethernet
ONBOOT=yes
USERCTL=no
BOOTPROTO=static
IPADDR=192.168.56.200
NETMASK=255.255.255.0
GATEWAY=192.168.56.2
DNS1=192.168.56.2
BONDING_OPTS="mode=0 miimon=50" #如果使⽤模式1将mode修改为1即可
//2.修改eth0和eth1⽹卡配置⽂件
[root@wing ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
USERCTL=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
[root@wing ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
USERCTL=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
//3.添加驱动⽀持bond0
[root@wing ~]# vim /etc/modprobe.d/bonding.conf
alias bond0 bonding
posted @   必兮相语--  阅读(104)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
点击右上角即可分享
微信分享提示