1.软文推荐

2.软文推荐

3.软文推荐

linux的链路聚合就是把多网卡捆绑成一个逻辑网卡,在本篇文章中将重点为大家阐述一下使用使用nmcli配置主备模式链路聚合具体方法, 有需要的小伙伴可以参考一下。

现在让我们在CentOS 7中配置网卡绑定,运行ip link命令查看可以使用的网卡

[root@localhost ~]# ip link
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s3:  mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:7b:d3:32 brd ff:ff:ff:ff:ff:ff
3: enp0s8:  mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:81:d3:be brd ff:ff:ff:ff:ff:ff


在这里使用enp0s3和enp0s8两个网卡配置 主备模式的链路聚合。

创建Team接口
[root@localhost ~]# nmcli connection add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}' 
Connection 'team0' (4df78635-b9fc-4539-ab02-27db11c656fe) successfully added.


运行nmcli con show查看team0的配置

[root@localhost ~]# nmcli con show
NAME                UUID                                  TYPE      DEVICE 
team0               4df78635-b9fc-4539-ab02-27db11c656fe  team      team0  
enp0s3              5005942f-a7fd-4e55-b8e7-77928d8da72d  ethernet  enp0s3 
Wired connection 1  45dee64a-53b3-3e2a-b2d4-e377f3e668a2  ethernet  enp0s8

添加Slave接口

在这里使用enp0s3和enp0s8两个网卡作为team0的slave接口:

[root@localhost ~]# nmcli connection add type team-slave con-name team0-port1 ifname enp0s3 master team0 
Connection 'team0-port1' (15183c4a-2053-4b53-ad58-de5a07ae3ae9) successfully added.
[root@localhost ~]# nmcli connection add type team-slave con-name team0-port2 ifname enp0s8 master team0
Connection 'team0-port2' (a34e20b0-3422-46e5-a947-bb2eaa6c0622) successfully added.


查看端口配置信息:

[root@localhost ~]# nmcli connection show 
NAME                UUID                                  TYPE      DEVICE 
team0               4df78635-b9fc-4539-ab02-27db11c656fe  team      team0  
enp0s3              5005942f-a7fd-4e55-b8e7-77928d8da72d  ethernet  enp0s3 
Wired connection 1  45dee64a-53b3-3e2a-b2d4-e377f3e668a2  ethernet  enp0s8 
team0-port1         15183c4a-2053-4b53-ad58-de5a07ae3ae9  ethernet  --     
team0-port2         a34e20b0-3422-46e5-a947-bb2eaa6c0622  ethernet  --     

分配IP地址

给team0分配一个静态的IP地址并启动team0配置:

[root@localhost ~]# nmcli connection modify team0 ipv4.method manual ipv4.addresses 192.168.0.200/24 ipv4.gateway 192.168.0.1 ipv4.dns 202.102.128.68
[root@localhost ~]# nmcli connection up team0 
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)

查看连接配置信息,发现team0-port1没有绑定在enp0s3这个网卡接口上

[root@localhost ~]# nmcli connection 


这是以内ifcfg-team0-port1配置文件和ifcfg-enp0s3两个配置文件都设置为开机启动了

所以我们需要关闭enp0s3的开机启动,在这里我们把enp0s3和Wired connection 1这两个配置都关掉开机启动

[root@localhost ~]# nmcli connection modify enp0s3 autoconnect no
[root@localhost ~]# nmcli connection modify Wired connection 1 autoconnect no


然后重启一下网络服务,查看链接配置:

[root@localhost ~]# systemctl restart network
[root@localhost ~]# nmcli connection
[root@localhost ~]# ip ad

可以看到team0-port1和team0-port2都绑定在对应的网卡上面了,team0的ip地址显示的是手动设置的192.168.0.200

验证

查看team0的状态:

[root@localhost ~]# teamdctl team0 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: enp0s8


现在活动的端口是enp0s8,我们断开这个端口,看一下主备模式配置是否工作:

[root@localhost ~]# nmcli device disconnect enp0s8 
Device 'enp0s8' successfully disconnected.
[root@localhost ~]# teamdctl team0 state
setup:
  runner: activebackup
ports:
  enp0s3
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
runner:
  active port: enp0s3

看到活动接口切换到enp0s3上面了。

总结

主备模式的链路聚合将其中一个接口置于备份状态,并且仅当活动接口断开链接时才会使其处于活动状态。

本文来源:www.lxlinux.net/4143.html,若引用不当,请联系修改。

相关文章 8

1

百度网盘下载速度(百度网盘下载速度为什么这么慢) 52秒前

目录:1、百度网盘怎么加速下载2、百度网盘开了会员下载速度还是慢怎么办3、百度网盘下载速度4、百度网盘下载速度慢破解方法5、电脑百...

2

Linux下安装全文搜索服务器SOLer 2分钟前

SOLer是基于 Lucene 的全文搜索服务器,也是最流行的企业级搜索引擎,其主要功能包括全文检索、命中高亮、分面搜索、动态聚类、数据库集...

3

黔东南云服务器(黔龙云客户端) 5分钟前

目录:1、云计算服务器要多少钱?2、云计算服务器怎么选择?3、云贵州服务器什么时候成立4、云计算服务器哪家好5、哪种云服务器便宜...

4

轻松自如关闭与开启SELinux 6分钟前

SELinux 主要由美国国家安全局开发。2.6 及以上版本的 Linux 内核都已经集成了 SELinux 模块,SELinux 的结构及配置非常复杂,而且有大量概念性...

5

新加坡直连vps(新加坡直通车课程) 7分钟前

目录:1、香港vps和新加坡vps,大陆访问哪个更快2、请问老牌云拨号vps哪家最靠谱?3、【供】新加坡vps速度怎么样?新加坡国内使用最快速...

6

快速上手Linux uniq命令 10分钟前

Linux uniq命令用于检查及删除文本文件中重复出现的行列。uniq可检查文本文件中重复出现的行列。 格式 uniq[选项][file] 选项说明: -c,--count:...

7

virmach怎么样(virmach怎么用) 12分钟前

目录:1、在中国可以打开外国的网址吗?在中国可以打开外国的网址吗? 当然可以了。。只要没有被屏蔽,是不分国界的哦。。即使被国内...

8

数据库和Redis开发各系统独立的自增ID生成器使用方法 14分钟前

在分布式系统,需要生成唯一ID的系统不止一个,这些ID的生成在各自业务内是独立的,同时包含业务规则,如果要利用数据库自增主键生成...