Linux 7双网卡绑定

linux 7通过nmtui工具可以很方便的进行双网卡绑定,不需要像之前版本那样繁琐的修改配置文件,并且可用在安装操作系统时直接配置,本文主要记录使用nmtui工具配置双网卡绑定的过程。

使用root用户执行nmtui命令,启动nmtui工具管理界面,和之前版本的setup工具相似。

[root@SL010A-IVDB01 ~]# nmtui

e339de014c30ec42b322ba8e7198a210.png

选择Add按钮,回车。

1ff31f91f3385e9e1851216e8d929cee.png

选择添加类型为Bond,即双网卡绑定。

41f229be128611b09cc5af59dc330092.png

最上部设置双网卡绑定的名字,中部模式选择Active Backup,然后选择Add按钮添加要绑定的网卡,回车。

4c07d390eda1e1f473c39e54b64390ba.png

这里选择网卡类型,因为要绑定的网卡是千兆以太网,所以这里选择Ethernet,回车。

8ca928913a52f6249d32d7bb32bd9cb0.png

这里设置要绑定网卡的名字,然后选择OK按钮,回车。

966b493bf07c2b972a670ef29d2043e6.png

同上,再添加第二块网卡,选择OK按钮,回车。

f0a80e8372e55d00a67a3377528a7dbd.png

添加完两块网卡,基本就是上图 这样,如果要在这个页面直接配置IP,选择Show按钮,回车。

6b685052ffec409bd206f2c0c3d29516.png

然后填写IP地址和网关即可,这里没有填写MASK地址的选项栏,需要在配置IP地址的时候在IP的后面直接写上, 255.255.255.0是/24,例如192.168.100.98/24。然后选择OK按钮,回车。

664d6f7a83d4af7cc938205623f946b0.png

回车后,返回初始界面,选择OK,回车结束配置即可。这样双网卡绑定就结束了。可以通过ifconfig命令查看到网卡的信息。

[root@SL010A-IVDB01 ~]# ifconfig

bond0: flags=5187 mtu 1500

inet 192.168.100.98 netmask 255.255.255.0 broadcast 192.168.100.255

inet6 fe80::224e:a422:6672:56e2 prefixlen 64 scopeid 0x20

ether 98:be:94:35:74:80 txqueuelen 1000 (Ethernet)

RX packets 0 bytes 0 (0.0 B)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 10 bytes 1180 (1.1 KiB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eno1: flags=6211 mtu 1500

ether 98:be:94:35:74:80 txqueuelen 1000 (Ethernet)

RX packets 0 bytes 0 (0.0 B)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 10 bytes 1180 (1.1 KiB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eno2: flags=6211 mtu 1500

ether 98:be:94:35:74:80 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

enp0s29f0u2: flags=4163 mtu 1500

ether 9a:be:94:35:f4:83 txqueuelen 1000 (Ethernet)

RX packets 1077 bytes 70075 (68.4 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

ens2f0: flags=4099 mtu 1500

ether 90:e2:ba:6a:66:c8 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

device memory 0xc0700000-c077ffff

ens2f1: flags=4099 mtu 1500

ether 90:e2:ba:6a:66:c9 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

device memory 0xc0780000-c07fffff

ens3f0: flags=4163 mtu 1500

inet 10.0.2.98 netmask 255.255.255.0 broadcast 10.0.2.255

inet6 fe80::e5bf:ef44:c11b:ad0 prefixlen 64 scopeid 0x20

ether 90:e2:ba:8c:5c:e8 txqueuelen 1000 (Ethernet)

RX packets 23158 bytes 1472551 (1.4 MiB)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 3378 bytes 1419406 (1.3 MiB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

ens3f1: flags=4099 mtu 1500

ether 90:e2:ba:8c:5c:e9 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

lo: flags=73 mtu 65536

inet 127.0.0.1 netmask 255.0.0.0

inet6 ::1 prefixlen 128 scopeid 0x10

loop txqueuelen 1000 (Local Loopback)

RX packets 336 bytes 31332 (30.5 KiB)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 336 bytes 31332 (30.5 KiB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

virbr0: flags=4099 mtu 1500

inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255

ether 52:54:00:63:fe:75 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

可用通过查看/proc/net/bonding/bond0文件来查看双网卡绑定的状态。

[root@SL010A-IVDB01 ~]# cat /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (active-backup)

Primary Slave: None

Currently Active Slave: eno1

MII Status: up

MII Polling Interval (ms): 100

Up Delay (ms): 0

Down Delay (ms): 0

Slave Interface: eno1

MII Status: up

Speed: 1000 Mbps

Duplex: full

Link Failure Count: 0

Permanent HW addr: 98:be:94:35:74:80

Slave queue ID: 0

Slave Interface: eno2

MII Status: up

Speed: 1000 Mbps

Duplex: full

Link Failure Count: 0

Permanent HW addr: 98:be:94:35:74:82

Slave queue ID: 0

可以看到当前活跃的网卡是eno1,可用关闭/启动这个网卡来测试双网卡绑定是否成功。

[root@SL010A-IVDB01 ~]# nmcli connection down eno1

[root@SL010A-IVDB01 ~]# nmcli connection up eno1

[root@SL010A-IVDB01 ~]# cat /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (active-backup)

Primary Slave: None

Currently Active Slave: eno2

MII Status: up

MII Polling Interval (ms): 100

Up Delay (ms): 0

Down Delay (ms): 0

Slave Interface: eno2

MII Status: up

Speed: 1000 Mbps

Duplex: full

Link Failure Count: 0

Permanent HW addr: 98:be:94:35:74:82

Slave queue ID: 0

Slave Interface: eno1

MII Status: up

Speed: 1000 Mbps

Duplex: full

Link Failure Count: 0

Permanent HW addr: 98:be:94:35:74:80

Slave queue ID: 0

可以看到活跃网卡切换到了eno2网卡,可用使用其他机器ping绑定后的网卡的IP,进行连通性测试。如果网卡切换后,网络一直通,则配置完成。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

月梦工作室

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值