关键词:
用途:将主机上的两块网卡绑定在一起,构成一个逻辑端口。
交换机根据用户配置的端口负荷分担策略决定报文从哪一个成员端口发送到对端的交换机。当其中一块网卡发生故障时,则继续使用另外一块正常的网卡。
RHEL5/6叫网卡bonding,需要加载内核模块
RHEL7叫链路聚合,内核自带驱动,需要配置team的master和多个slave
聚合网络的原理
真实的ip地址并不是在物理网卡上设置的,而是把两个或多个物理网卡聚合成一个虚拟的网卡,在虚拟网卡上设置地址,而外部网络访问本机时,就是访问的这个虚拟网卡的地址,虚拟网卡接到数据后经过两个网卡的负载交给服务器处理。如果一块网卡出现问题,则通过另一块传递数据,保证正常通信。聚合网络实验过程中,添加的两块新网卡可以不是active状态,甚至nmcli connect show查看没有新添加的网卡信息。也可以使active状态的网卡。
链路聚合的工作模式
1.active-backup 主备
2.loadbalance 负载均衡
3.RR RoundRobin 轮询
测试环境:
[root@localhost ~]# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.100.4 netmask 255.255.255.255 broadcast 192.168.100.4 inet6 fe80::922e:b8be:7ea8:4562 prefixlen 64 scopeid 0x20<link> ether 08:00:27:3e:f6:4d txqueuelen 1000 (Ethernet) RX packets 164 bytes 20454 (19.9 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 168 bytes 28639 (27.9 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1 (Local Loopback) RX packets 82 bytes 8488 (8.2 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 82 bytes 8488 (8.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:81:e7:fc txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@localhost ~]# hostnamectl Static hostname: localhost.localdomain Icon name: computer-vm Chassis: vm Machine ID: c59cb0b9011f459297a11b7b6b3e457b Boot ID: b029771ca9204611abe911f960ea7d51 Virtualization: kvm Operating System: Red Hat Enterprise Linux Server 7.4 (Maipo) CPE OS Name: cpe:/o:redhat:enterprise_linux:7.4:GA:server Kernel: Linux 3.10.0-693.el7.x86_64 Architecture: x86-64
[root@localhost ~]# nmcli connection show
NAME UUID TYPE DEVICE
enp0s3 59118063-4e4e-403c-ad25-374704d6f6f1 802-3-ethernet enp0s3
virbr0 b7180c81-0027-49ee-ab06-8f34a2df30be bridge virbr0
[root@localhost ~]#
|
一、测试主备模式(active-backup)
1、在主机模式再添加一块新的网卡
先shutdown 虚拟机,然后再 VirtualBox界面再启用网卡2。
然后启动虚拟机。
2、查看网卡信息
[root@localhost ~]# nmcli device show | grep -i device --新增网卡为enp0s8
GENERAL.DEVICE: virbr0
GENERAL.DEVICE: enp0s3
GENERAL.DEVICE: enp0s8
GENERAL.DEVICE: lo
GENERAL.DEVICE: virbr0-nic
[root@localhost ~]# nmcli connection show ---看不到enp0s8,因为无配置文件 NAME UUID TYPE DEVICE enp0s3 59118063-4e4e-403c-ad25-374704d6f6f1 802-3-ethernet enp0s3 virbr0 b4f4c345-d863-41c0-b396-55fd0f67785f bridge virbr0
|
# nmcli connection show 看不到enp0s8,因为无配置文件,如果手动添加配置文件后,就可以看到enp0s8了。其实都没必要为enp0s8和enp0s3造配置文件,因为我们要跟把两块网卡绑定到一块,作为新的team设备,使用新的配置文件。这里只为了测试一个小知识点。
[root@localhost ~]# nmcli connection add con-name enp0s8 type ethernet ifname enp0s8
Connection 'enp0s8' (b3972183-4a71-4635-b910-02c0530517d3) successfully added.
[root@localhost ~]# nmcli connection show
NAME UUID TYPE DEVICE
enp0s3 59118063-4e4e-403c-ad25-374704d6f6f1 802-3-ethernet enp0s3
enp0s8 b3972183-4a71-4635-b910-02c0530517d3 802-3-ethernet enp0s8
virbr0 b4f4c345-d863-41c0-b396-55fd0f67785f bridge virbr0
|
3、添加team设备及配置文件
[root@localhost ~]# nmcli connection add type team con-name testteamfile ifname testteamdevice config '{"runner":{"name":"activebackup"}}'
Connection 'testteamfile' (d2c8f925-8645-4ac5-95e6-6245a4431778) successfully added.
[root@localhost ~]# nmcli connection show --如果看不到team设备,说明上一命令有问题。
NAME UUID TYPE DEVICE
enp0s3 59118063-4e4e-403c-ad25-374704d6f6f1 802-3-ethernet enp0s3
enp0s8 b3972183-4a71-4635-b910-02c0530517d3 802-3-ethernet enp0s8
testteamfile d2c8f925-8645-4ac5-95e6-6245a4431778 team testteamdevice
virbr0 b4f4c345-d863-41c0-b396-55fd0f67785f bridge virbr0
|
说明:
# nmcli connection add type team con-name testteamfile ifname testteamdevice config '{"runner":{"name":"activebackup"}}'
testteamfile配置文件名
testteamdevice 绑定的设备名
config ’{运行规则}’。运行规则中出现的所有关键字使用双引号。
"runner":{"name":"activebackup"} 指明运行级别为activebackup
如果添加错误,则使用 nmcli connection delete testteamfile来删除,然后重新再添加。
配置文件添加成功后,会在/etc/sysconfig/network-scripts/目录下生成。
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls ifcfg-*
ifcfg-enp0s3 ifcfg-enp0s8 ifcfg-lo ifcfg-testteamfile
4、为team设备配置IP
[root@localhost network-scripts]# nmcli connection modify testteamfile ipv4.method manual ipv4.addresses 192.168.100.123/24 ipv4.gateway 192.168.100.100 ipv4.dns 192.168.100.1 connection.autoconnect yes
[root@localhost network-scripts]# nmcli connection show
NAME UUID TYPE DEVICE
enp0s3 59118063-4e4e-403c-ad25-374704d6f6f1 802-3-ethernet enp0s3
enp0s8 b3972183-4a71-4635-b910-02c0530517d3 802-3-ethernet enp0s8
testteamfile d2c8f925-8645-4ac5-95e6-6245a4431778 team testteamdevice
virbr0 b4f4c345-d863-41c0-b396-55fd0f67785f bridge virbr0
|
5、将两块网卡enp0s3和enp0s8绑定到虚拟网卡上
[root@localhost ~]# nmcli connection add type team-slave con-name testteamslave1 ifname enp0s3 master testteamdevice
Connection 'testteamslave1' (506b5fe9-0c3b-4251-b58b-b1a1a53acda4) successfully added.
[root@localhost ~]# nmcli connection add type team-slave con-name testteamslave2 ifname enp0s8 master testteamdevice
Connection 'testteamslave2' (312ba2d8-7b18-4446-b37f-5de7217a6646) successfully added.
[root@localhost ~]# nmcli connection show
NAME UUID TYPE DEVICE
enp0s3 59118063-4e4e-403c-ad25-374704d6f6f1 802-3-ethernet enp0s3
enp0s8 b3972183-4a71-4635-b910-02c0530517d3 802-3-ethernet enp0s8
virbr0 b4f4c345-d863-41c0-b396-55fd0f67785f bridge virbr0
testteamfile d2c8f925-8645-4ac5-95e6-6245a4431778 team --
testteamslave1 506b5fe9-0c3b-4251-b58b-b1a1a53acda4 802-3-ethernet --
testteamslave2 312ba2d8-7b18-4446-b37f-5de7217a6646 802-3-ethernet --
|
enp0s3----->testteamslave1------>testteamdevice
enpos8----->testteamslave2------>testteamdevice
可以这么理解:enp0s3和enp0s8被它们的主子master买去做了奴隶,一个取名叫slave1,另一个取名叫slave2。
6、激活虚拟网卡testteamdevice
[root@localhost ~]# nmcli connection up testteamfile ---注意启动的是文件,而不是设备
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/157)
[root@localhost ~]# nmcli connection up testteamslave1
[root@localhost ~]# nmcli connection up testteamslave2
|
先启动master,再启动两个slave。
[root@localhost ~]# nmcli connection show
NAME UUID TYPE DEVICE
virbr0-nic 6944d05c-3906-4fc5-84e7-cb46f3e6e2b2 generic virbr0-nic
virbr0 05e6ca14-f6f5-4697-bcc0-e13e4b212236 bridge virbr0
enp0s3 7419645c-73a9-423f-bcfd-fccd36773841 802-3-ethernet --
testteamslave2 608bb6f1-099d-459d-9589-5b2f2b28b2d9 802-3-ethernet enp0s8
testteamslave1 90b0d08f-dec2-4a1f-827a-ce198f21fb46 802-3-ethernet enp0s3
testteamfile f2277aa4-a7b3-4166-afaa-dcd60e550d97 team testteamdevice
[root@localhost ~]# ifconfig | grep ether ether 08:00:27:57:c1:ff txqueuelen 1000 (Ethernet) ether 08:00:27:57:c1:ff txqueuelen 1000 (Ethernet) ether 08:00:27:57:c1:ff txqueuelen 0 (Ethernet) ether 52:54:00:59:75:9b txqueuelen 0 (Ethernet)
[root@localhost ~]# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 ether 08:00:27:57:c1:ff txqueuelen 1000 (Ethernet) RX packets 144 bytes 17362 (16.9 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 152 bytes 23282 (22.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 ether 08:00:27:57:c1:ff txqueuelen 1000 (Ethernet) RX packets 10 bytes 907 (907.0 B) RX errors 0 dropped 5 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 10 bytes 984 (984.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 10 bytes 984 (984.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
testteamdevice: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.100.123 netmask 255.255.255.0 broadcast 192.168.100.255 inet6 fe80::a00:27ff:fe57:c1ff prefixlen 64 scopeid 0x20<link> ether 08:00:27:57:c1:ff txqueuelen 0 (Ethernet) RX packets 133 bytes 14204 (13.8 KiB) RX errors 0 dropped 4 overruns 0 frame 0 TX packets 116 bytes 17841 (17.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:59:75:9b txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
You have mail in /var/spool/mail/root
|
从上边可以看出:testteamdevice,enp0s3,enp0s8 三块网卡的mac地址一样。
三个常用的命令:
1、查看虚拟网卡的状态
[root@localhost ~]# teamdctl testteamdevice state
setup: runner: activebackup --运行模式
ports: enp0s3 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up --状态为启动 down count: 0 enp0s8 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up --状态为启动 down count: 0
runner: active port: enp0s3 --当前激活的网卡;testteamdevice设备目前使用的是enp0s3网卡
|
2、查看虚拟网卡的端口
[root@localhost ~]# teamnl testdevice -h
teamnl [options] teamdevname command [command args] -h --help Show this help
Commands: ports options getoption OPT_NAME setoption OPT_NAME OPT_VALUE monitor OPT_STYLE
[root@localhost ~]# teamnl testteamdevice ports ----查看网卡对应的端口 3: enp0s8: up 1000Mbit FD 2: enp0s3: up 1000Mbit FD
[root@localhost ~]# teamnl testteamdevice getoption activeport ---当前使用的网卡端口,当前使用的是enp0s3。 2
|
验证结果:
[root@localhost ~]# nmcli device disconnect enp0s3 --断开enp0s3
Device 'enp0s3' successfully disconnected.
[root@localhost ~]# teamdctl testteamdevice state ---可以虚拟网卡自动连接到时enp0s8网卡上
[root@localhost ~]#teamncl testteamdevice port
3:enp0s8:up 1000Mbit FD
|
图形化界面配置方式:
#nm-connection-editor
同样,再添加team设备的另外一块网卡进来。
为team2设备配置IP地址:
二、桥接
要求:把本机1的其中一块网卡转换为桥接设备(交换机),其它客户机连接到该设备后能与主机1正常通信。
下面把网卡enp0s8转换为桥接设备:
[root@localhost ~]# nmcli connection show
NAME UUID TYPE DEVICE
enp0s3 6759482b-076f-4181-9d69-ca6dc0190faa 802-3-ethernet enp0s3
virbr0 4f99dff9-d3fb-461a-b0d6-00297e7584a0 bridge virbr0
[root@localhost ~]# nmcli device show | grep -i device
GENERAL.DEVICE: virbr0
GENERAL.DEVICE: enp0s3
GENERAL.DEVICE: enp0s8
GENERAL.DEVICE: lo
GENERAL.DEVICE: virbr0-nic
[root@localhost ~]# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.100.111 netmask 255.255.255.0 broadcast 192.168.100.255 inet6 fe80::6ea:59df:4b18:530b prefixlen 64 scopeid 0x20<link> ether 08:00:27:3e:f6:4d txqueuelen 1000 (Ethernet) RX packets 188 bytes 21984 (21.4 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 246 bytes 38495 (37.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 ether 08:00:27:45:59:30 txqueuelen 1000 (Ethernet) RX packets 63 bytes 9404 (9.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1 (Local Loopback) RX packets 84 bytes 9340 (9.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 84 bytes 9340 (9.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:81:e7:fc txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@localhost ~]#
|
#nmcli connection add type bridge con-name testbrifile ifname testbridevice
#nmcli connection modify testbrifile ipv4.method manual ipv4.addresses "192.168.100.222/24 192.168.100.1" ipv4.dns 192.168.100.1
#nmcli connection add type bridge-slave con-name testbrislave1 ifname enpos8 master testbridevice
#nmcli connection down testbrifile
#nmcli connection up testbrifile
#nmcli connection up testbrislave1
#ping -I testbridevice 192.168.100.111 #-I表示从哪块网卡发出ping
关于在链路聚合下做smart,monitorlink的转发测试
关于在链路聚合下做smart,monitorlink的转发测试这次又要开始瞎折腾了。没事找事了。毕竟我还是很无聊的;这个实验主要要涉及到以下几个方面:1、gvrp的应用:2、SmartLink与MonitorLink的配置;3、链路聚合; 先复习一波基本... 查看详情
关于在链路聚合下做smart,monitorlink的转发测试
关于在链路聚合下做smart,monitorlink的转发测试这次又要开始瞎折腾了。没事找事了。毕竟我还是很无聊的;这个实验主要要涉及到以下几个方面:1、gvrp的应用:2、SmartLink与MonitorLink的配置;3、链路聚合; 先复习一波基本... 查看详情
华为交换机---链路聚合
链路聚合简介链路聚合:作用:增加宽带,同事提供链路冗余LACP模式支持链路备份灵活多用手工负载分担模式:无法自由自定义配置链路聚合:手工负载配置所有活动接口都参与数据的转发分担负载流量 二层链路聚合eth-trunkL... 查看详情
链路聚合原理
TRUNKING即为链路聚合技术,可以实现链路聚合功能。组网时,核心交换机之间的连接、核心交换机与数据服务器的连接以及核心交换机与边缘交换机的连接是整个网络最重要的连接,叫主干连接(Trunk)。 主干连接具有高带... 查看详情
思科链路聚合技术
参考技术A思科链路聚合技术 链路聚合技术的明显的优点是为用户提供一种经济的提高链路传输率的方法,同时在链路聚合中,成员互相动态备份。下面是我整理的关于链路聚合技术知识,希望对你有帮助! 交换机基础:... 查看详情
链路聚合
...障,这条链路仍然存在,只是带宽略有下降,这就是链路聚合技术。Eth-Trunk优势:负载分担、提高可靠性、增加带宽实现链路聚合条件:要求Eth-Trunk的物理端口的参数必须一致,这些参数包括,物理端口类型、端口数量、端口速... 查看详情
桥接模式
...*把抽象部分与它的实现部分分离变得可以独立变化*多用聚合,少用继承合成聚合*合成是指一个整体一个对象完整是有很多个部份组成不可分开(强的拥有)**聚合是指多个对象聚合在一起成一个对象(弱的拥有)*(或说一个对... 查看详情
配置lacp模式链路聚合
组网需求 在两台Router设备上配置LACP模式链路聚合组,提高两设备之间的带宽与可靠性,具体要求如下:两条活动链路具有负载分担的能力。两设备间的链路具有一条冗余备份链路,当活动链路出现故障链路时,备份链... 查看详情
以太网链路聚合技术
以太网链路聚合技术(LinkAggregation),端口捆绑、链路捆绑技术。通过该技术,我们能将多条以太网链路进行捆绑,捆绑之后的这些物理链路就形成了逻辑上的一条新的链路(Eth-trunk)。这条聚合链路不仅仅在带宽上成倍的增加... 查看详情
路由器与交换机做链路聚合(代码片段)
AR1配置interfaceEth-Trunk1undoportswitch#interfaceGigabitEthernet0/0/0eth-trunk1#interfaceGigabitEthernet0/0/1eth-trunk1SW1配置interfaceEth-Trunk1modelacp-staticinterfaceGigabitEthernet0/0/1et 查看详情
二层链路聚合实验
链路聚合的作用:1、扩容;2、为链路冗余提供可靠性。1、两台交换机,两四主机PC,左边PC3和右边PC5为VLAN10,左边PC4和右边PC6为为VLAN20进行测试。然后连线,接下来是交换机配置级联,用最大端口进行级联。2、接着给每台PC主... 查看详情
某虚拟化项目中思科与华为交换机链路聚合互连案例
...VMware虚拟化项目中,涉及到华为与思科交换机通过“链路聚合”的方式互连,经过咨询华为的技术工程师,问题得以成功解决。不像某些厂家的售后:我们的产品只支持与我们的产品互连,其他的不提供技术支持。华为售后没有... 查看详情
华为万兆路由器支持链路聚合吗
华为万兆路由器支持链路聚合。链路聚合(LinkAggregation)是将多个物理接口当作一个逻辑接口,以增加带宽的提供线路冗余,链路聚合的带宽理论上相当于所包含的物理接口带宽总和,非常适合与企业核心网络中,同时参与捆绑... 查看详情
grassrouter多链路聚合通信-基于4g5g和卫星聚合的多链路应急组网方案
“使用4G/5G多链路聚合路由器,解决移动环境中指挥调度网络连接稳定性痛点”应急指挥车、现场应急指挥系统作为整个应急指挥平台的主要组成部分,被广泛用于救灾抢险,安全保障等特殊场景,可通过应急指挥车或... 查看详情
什么是链路聚合?链路聚合的功能是什么?
链路聚合(英语:LinkAggregation)是一个计算机网络术语,指将多个物理端口汇聚在一起,形成一个逻辑端口,以实现出/入流量吞吐量在各成员端口的负荷分担,交换机根据用户配置的端口负荷分担策略决定网络封包从哪个成员... 查看详情
设计模式——桥接模式
...用来实现自己的对象)二、UML示意图 三、组合/聚合复用原则概念:聚合表示一种弱的‘拥有’关系,体现的是A对象可以包含B对象,但B对象不是A对象的一部分;组合则是一种强的‘拥有’关系,体现了严格... 查看详情
华为交换机配置链路聚合(手工模式链路聚合和lacp模式聚合)ubuntu20.04服务器配置多网卡链路聚合
一.华为交换机配置链路聚合(Eth-Trunk),是将多个物理接口捆绑为一个逻辑接口,实现增加链路带宽、提高可靠性、提供负载分担的目的。链路聚合两种模式:手工负载分担模式(默认模式,默认负载均衡方式src-dst-ip适用于:... 查看详情
华为静态链路聚合配置
参考技术A华为链路聚合分为两种:●手动负载均衡模式:在这种模式下,Eth-Trunk的建立、成员接口的加入都是手工配置的,没有协议的参与。在该模式下所有活动链路都参与数据转发,平均分坦流量。如果某条活动链路出现故... 查看详情