事先需要准备好网络yum源,保证服务器可正常上网
关闭防火墙,关闭selinux
本次实验虚拟机环境下模拟,网卡为nat模式,dhcp分配ip,现添加两张网卡,如图
登录服务器后,由于是后添加的网卡,发现/etc/sysconfig/network-scripts下没有新加网卡的配置文件,然后使用以下命令
nmtui
把有线连接改为对应网卡改为对应网卡名字
然后
cd /etc/sysconfig/network-scripts/
然后修改ifcfg-ens37,ifcfg-ens38配置文件(相当于末尾追加MASTER=bond0 SLAVE=yes,把BOOTPROTO改为none),如下
[root@localhost network-scripts]# cat ifcfg-ens37
HWADDR=00:0C:29:B2:F3:A9
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens37
UUID=f69a315d-2735-4489-b99e-7153f016e7b2
ONBOOT=yes
MASTER=bond0
SLAVE=yes
[root@localhost network-scripts]# cat ifcfg-ens38
HWADDR=00:0C:29:B2:F3:B3
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens38
UUID=3e20bf34-6f74-34ff-b702-7f0e74ed34bc
ONBOOT=yes
AUTOCONNECT_PRIORITY=-999
MASTER=bond0
SLAVE=yes
然后新加一个bond配置文件,这里选择mode 6,无需配置交换机
[root@localhost network-scripts]# cat ifcfg-bond0
TYPE=Bond
BOOTPROTO=dhcp
ONBOOT=yes
DEVICE=bond0
BONDING_MASTER=yes
BONDING_OPTS="mode=6 miimon=100"
然后重启网络
systemctl restart network
然后使用nmtui发现
[root@localhost network-scripts]# lsmod | grep bonding
bonding 152979 0
[root@localhost network-scripts]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: adaptive load balancing
Primary Slave: None
Currently Active Slave: ens37
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: ens37
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:b2:f3:a9
Slave queue ID: 0
Slave Interface: ens38
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:b2:f3:b3
Slave queue ID: 0
[root@localhost network-scripts]# ethtool bond0
Settings for bond0:
Supported ports: [ ]
Supported link modes: Not reported
Supported pause frame use: No
Supports auto-negotiation: No
Supported FEC modes: Not reported
Advertised link modes: Not reported
Advertised pause frame use: No
Advertised auto-negotiation: No
Advertised FEC modes: Not reported
Speed: 2000Mb/s
Duplex: Full
Port: Other
PHYAD: 0
Transceiver: internal
Auto-negotiation: off
Link detected: yes