Linux7nmtui双网卡绑定,centos 7.6 双网卡绑定 teaming 实现 mod=1 activebackup 主备模式

os: centos 7.6

centos7中双网卡绑定除了 bonding 技术外,还能使用 teaming 技术,配置也挺方便。

本次使用的工作方式为 activebackup - 主备模式

有多种模式runner

broadcast

roundrobin

activebackup

loadbalance

lacp (implements the 802.3ad Link Aggregation Control、Protocol)

网络接口

enp0s8,enp0s9不需要配置ip

# nmtui-edit

# ifup enp0s8;ifup enp0s9;

# nmcli dev

DEVICE TYPE STATE CONNECTION

enp0s3 ethernet connected enp0s3

enp0s8 ethernet connecting (getting IP configuration) enp0s8

enp0s9 ethernet connecting (getting IP configuration) enp0s9

lo loopback unmanaged --

# ip a

1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

valid_lft forever preferred_lft forever

2: enp0s3: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

link/ether 08:00:27:23:94:42 brd ff:ff:ff:ff:ff:ff

inet 10.0.2.25/24 brd 10.0.2.255 scope global noprefixroute dynamic enp0s3

valid_lft 1174sec preferred_lft 1174sec

3: enp0s8: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

link/ether 08:00:27:dd:ce:b1 brd ff:ff:ff:ff:ff:ff

4: enp0s9: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

link/ether 08:00:27:74:1a:f4 brd ff:ff:ff:ff:ff:ff

创建 team 类型的接口 team0,模式为 activebackup

# nmcli con show

NAME UUID TYPE DEVICE

enp0s3 54fe5543-f63f-48eb-ad29-48205128e109 ethernet enp0s3

enp0s8 c155dffa-104a-48ad-bacd-38c461439cb3 ethernet enp0s8

enp0s9 3c7a84a7-154f-36a0-8673-dee2366614c4 ethernet enp0s9

# nmcli con add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}'

Connection 'team0' (10992833-122e-4cb7-9808-77b68af04fdb) successfully added.

# nmcli con show

NAME UUID TYPE DEVICE

enp0s3 54fe5543-f63f-48eb-ad29-48205128e109 ethernet enp0s3

enp0s8 c155dffa-104a-48ad-bacd-38c461439cb3 ethernet enp0s8

enp0s9 3c7a84a7-154f-36a0-8673-dee2366614c4 ethernet enp0s9

team0 10992833-122e-4cb7-9808-77b68af04fdb team team0

添加物理网卡到 team0

# nmcli con add type team-slave con-name team0-port1 ifname enp0s8 master team0

Connection 'team0-port1' (0320bf56-1987-4b34-8b34-fa0790813d12) successfully added.

# nmcli con add type team-slave con-name team0-port2 ifname enp0s9 master team0

Connection 'team0-port2' (5833b612-8904-4501-8b4c-391174469d76) successfully added.

配置ip地址及网管,dns

# nmcli con modify team0 ipv4.address '192.168.56.119/24';

nmcli con modify team0 ipv4.gateway '192.168.56.1';

nmcli con modify team0 ipv4.method manual;

nmcli con modify team0 connection.autoconnect yes

nmcli con up team0;

nmcli con modify team0 ipv4.dns "8.8.8.8";

查看网络配置文件

# ls -l /etc/sysconfig/network-scripts/ |grep -i team0

-rw-r--r--. 1 root root 390 Aug 2 11:14 ifcfg-team0

-rw-r--r--. 1 root root 122 Aug 2 11:13 ifcfg-team0-port1

-rw-r--r--. 1 root root 122 Aug 2 11:14 ifcfg-team0-port2

重启网络服务

# nmcli con show

NAME UUID TYPE DEVICE

enp0s3 54fe5543-f63f-48eb-ad29-48205128e109 ethernet enp0s3

team0 10992833-122e-4cb7-9808-77b68af04fdb team team0

team0-port1 0320bf56-1987-4b34-8b34-fa0790813d12 ethernet enp0s8

team0-port2 5833b612-8904-4501-8b4c-391174469d76 ethernet enp0s9

enp0s8 c155dffa-104a-48ad-bacd-38c461439cb3 ethernet --

enp0s9 3c7a84a7-154f-36a0-8673-dee2366614c4 ethernet --

# teamdctl team0 state

setup:

runner: activebackup

ports:

enp0s8

link watches:

link summary: up

instance[link_watch_0]:

name: ethtool

link: up

down count: 0

enp0s9

link watches:

link summary: up

instance[link_watch_0]:

name: ethtool

link: up

down count: 0

runner:

active port: enp0s8

查看网卡

# ip a

1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

valid_lft forever preferred_lft forever

2: enp0s3: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

link/ether 08:00:27:23:94:42 brd ff:ff:ff:ff:ff:ff

inet 10.0.2.25/24 brd 10.0.2.255 scope global noprefixroute dynamic enp0s3

valid_lft 1096sec preferred_lft 1096sec

3: enp0s8: mtu 1500 qdisc pfifo_fast master team0 state UP group default qlen 1000

link/ether 08:00:27:dd:ce:b1 brd ff:ff:ff:ff:ff:ff

4: enp0s9: mtu 1500 qdisc pfifo_fast master team0 state UP group default qlen 1000

link/ether 08:00:27:dd:ce:b1 brd ff:ff:ff:ff:ff:ff

6: team0: mtu 1500 qdisc noqueue state UP group default qlen 1000

link/ether 08:00:27:dd:ce:b1 brd ff:ff:ff:ff:ff:ff

inet 192.168.56.119/24 brd 192.168.56.255 scope global noprefixroute team0

valid_lft forever preferred_lft forever

故障验证

打开一个窗口一直 ping

来自 192.168.56.119 的回复: 字节=32 时间<1ms TTL=64

来自 192.168.56.119 的回复: 字节=32 时间<1ms TTL=64

来自 192.168.56.119 的回复: 字节=32 时间<1ms TTL=64

来自 192.168.56.119 的回复: 字节=32 时间<1ms TTL=64

来自 192.168.56.119 的回复: 字节=32 时间<1ms TTL=64

来自 192.168.56.119 的回复: 字节=32 时间<1ms TTL=64

vmware 移除虚拟机的网卡 enp0s8

# teamdctl team0 state

setup:

runner: activebackup

ports:

enp0s8

link watches:

link summary: down

instance[link_watch_0]:

name: ethtool

link: down

down count: 0

enp0s9

link watches:

link summary: up

instance[link_watch_0]:

name: ethtool

link: up

down count: 0

runner:

active port: enp0s9

显示的 enp0s8 为 down, runner = enp0s9

参考:

https://blog.csdn.net/woodrow1994/article/details/79412340

https://www.cnblogs.com/heaven-xi/p/9559551.html

https://www.cnblogs.com/weijie0717/p/6910600.html

team 选项

# teamnl team0 options

删除 team

# nmcli con del team0 team0-port1 team0-port2

断开 team-slave

# nmcli dev dis enp0s8

# nmcli dev con enp0s8

# nmcli con add type team con-name CNAME ifname INAME [config JSON]

JSON语法格式如下:’{“runner”:{“name”:“METHOD”}}’

METHOD 是以下的其中一个:broadcast、activebackup、roundrobin、loadbalance 或者 lacp。

roundrobin - 轮询模式

# nmcli con add type team con-name team0 ifname team0 config '{"runner":{"name": "roundrobin"}}'

activebackup - 主备模式

# nmcli con add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}'

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值