Linux RHEL 7.9网卡配置bond0(主备模式)

一、实验环境准备及规划

系统:RHEL 7.9
网卡bond0(主备模式):
	ens33
	ens37
	bond0:192.168.100.40
vmware虚拟机网卡:仅主机模式

二、方法1(nmcli命令行配置)操作步骤

# 1、创建bond0虚拟网卡接口
[root@localhost network-scripts]# nmcli connection add type bond con-name bond0 ifname bond0 mode active-backup miimon 100
连接 "bond0" (b64b136c-e2d4-4d79-98d6-7022e2a9bc0e) 已成功添加。


# 2、将ens33网卡和ens37添加到bond0虚拟网卡组中
[root@localhost network-scripts]# nmcli connection add type bond-slave ifname ens33 con-name bond0-1 master bond0 
连接 "bond0-1" (708b9336-d09d-47ab-baaf-f15c93fd5dc7) 已成功添加。
[root@localhost network-scripts]# nmcli connection add type bond-slave ifname ens37 con-name bond0-2 master bond0 
连接 "bond0-2" (f0204cc0-2be3-4f23-a88f-593bf0cf1280) 已成功添加。

# 3、为bond0虚拟网卡配置IP地址、网关、开机自启等
[root@localhost network-scripts]# nmcli connection modify bond0 ipv4.addresses 192.168.100.40/24 ipv4.gateway 192.168.100.1 ipv4.method manual connection.autoconnect yes

# 4、重启bond0和网卡服务
[root@localhost network-scripts]# nmcli connection up bond0
连接已成功激活(master waiting for slaves)(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/19)
[root@localhost network-scripts]# systemctl restart network

# 5、查看网卡信息、bond信息,验证是否配置成功
[root@localhost network-scripts]# ifconfig 
bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
        inet 192.168.100.40  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::c9c9:48ca:d7ab:190b  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:78:3a:f1  txqueuelen 1000  (Ethernet)
        RX packets 4  bytes 240 (240.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 40  bytes 5057 (4.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether 00:0c:29:78:3a:f1  txqueuelen 1000  (Ethernet)
        RX packets 16  bytes 3104 (3.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 162  bytes 18332 (17.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens37: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether 00:0c:29:78:3a:f1  txqueuelen 1000  (Ethernet)
        RX packets 14  bytes 903 (903.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 86  bytes 8666 (8.4 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 1000  (Local Loopback)
        RX packets 220  bytes 18764 (18.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 220  bytes 18764 (18.3 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:84:25:5a  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 network-scripts]# 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: ens33
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: ens33
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:78:3a:f1
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:78:3a:fb
Slave queue ID: 0

三、方法2(nmtui图形页面配置)操作步骤

1、在命令行终端使用nmtui命令,进入nmtui页面

image-20220712162226582

2、添加bond组,如图所示

image-20220712165733451

3、配置bond信息,如图所示

image-20220712170222694

4、选择add时,在bond0设备中添加网卡时,需分别添加ens33和ens37,具体配置如下

image-20220712170526642

 

image-20220712191033005

5、添加完成后,在网卡页面会新增一个bond类型的网卡,如图所示

image-20220712185937829

6、重启激活bond0网卡

image-20220712190045406 image-20220712190114987

7、登陆终端验证bond0网卡是否生效

#1、查看bond状态信息
[root@localhost ~]# 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: ens33
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: ens33
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:78:3a:f1
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:78:3a:fb
Slave queue ID: 0

#2、查看本地IP情况,验证设置的bond0是否生效
[root@localhost ~]# ifconfig
bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
        inet 192.168.100.40  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::10d:90b:59bb:a41f  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:78:3a:f1  txqueuelen 1000  (Ethernet)
        RX packets 102  bytes 11808 (11.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 110  bytes 23827 (23.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether 00:0c:29:78:3a:f1  txqueuelen 1000  (Ethernet)
        RX packets 9911  bytes 933898 (912.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4312  bytes 1347298 (1.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens37: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether 00:0c:29:78:3a:f1  txqueuelen 1000  (Ethernet)
        RX packets 2600  bytes 237471 (231.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 115  bytes 12729 (12.4 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 1000  (Local Loopback)
        RX packets 430  bytes 36710 (35.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 430  bytes 36710 (35.8 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:84:25:5a  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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

一只晨兴夜不得寐的运维人

你的打赏,是我今晚餐桌上的鸡腿

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

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

打赏作者

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

抵扣说明:

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

余额充值