**Foreword: **
In production, I received an alarm from the supervisor, and the network card of a server was switched back and forth, asking if it was abnormal. The reason is that when the server was in the test area, the dual network card mode was active-active, and it switched back and forth after it was in the production environment. This article simulates dual network card configuration and testing in an esxi environment.
**Environmental description: **
Hostname | operating system version | ip | ESXi version | remarks |
---|---|---|---|---|
client | Centos 7.6.1810 | 172.27.34.85 | 6.5.0 | Dual network card test host |
The system currently has only one network card, and a dual network card environment needs to be constructed.
Network card ifcfg-ens160 configuration:
[ root@client network-scripts]# more ifcfg-ens160
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
NAME=ens160
UUID=003981c1-76e4-4a67-9f84-f42cb033bbba
DEVICE=ens160
ONBOOT=yes
IPADDR=172.27.34.85
PREFIX=24
GATEWAY=172.27.34.1
IPV6_PRIVACY=no
DNS1=202.xxx.xxx.xxx
DNS fill in according to the actual situation
The existing environment has only one network card
Add a network card
[ root@client network-scripts]# touch ifcfg-bond0
[ root@client network-scripts]# more ifcfg-bond0
TYPE=Bond
BOOTPROTO=static
DEFROUTE=yes
DEVICE=bond0
USERCTL=no
ONBOOT=yes
IPADDR=172.27.34.85
PREFIX=24
GATEWAY=172.27.34.1
DNS1=202.xxx.xxx.xxx
BONDING_OPTS="miimon=100 mode=1"
Create a new network card file ifcfg-bond0 and configure it. mode=1: active/standby mode, only one network card works, when the main network card fails, it will switch to the standby network card; mode=0: [load balance] (https://cloud.tencent.com/product/clb?from=10680) mode, both network cards work, providing twice the bandwidth. The network card mode can be selected according to the actual production situation.
[ root@client network-scripts]# more ifcfg-ens160
TYPE=Ethernet
BOOTPROTO=static
NAME=eno2
HWADDR=00:0c:29:c8:de:24
DEVICE=ens160
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
[ root@client network-scripts]# touch ifcfg-ens190
[ root@client network-scripts]# more ifcfg-ens190
TYPE=Ethernet
BOOTPROTO=static
NAME=eno2
HWADDR=00:0c:29:c8:de:2e
DEVICE=ens190
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
Create a new network card file ifcfg-ens190 and configure
[ root@client ~]# systemctl restart network
Restart network or host
NIC bond0 has been tied to ip 172.27.34.85
[ root@client ~]# cat /proc/net/bonding/bond0
Dual network card mode is active and standby, the main network card is ens160
[ root@client ~]# ifdown ifcfg-ens160
Successfully disconnected the device'ens160'。
[ root@client ~]# cat /proc/net/bonding/bond0
At this time, the main network card is ens190, and the network connection is normal
[ root@client ~]# ifup ifcfg-ens160
The connection has been successfully activated (D-Bus activity path:/org/freedesktop/NetworkManager/ActiveConnection/11)
[ root@client ~]# cat /proc/net/bonding/bond0
Start ens160, the main network card is still ens190, and the network connection is normal
The test is complete, and the dual network card active/standby mode is valid.
**All scripts and configuration files in this article have been uploaded to github: **Centos7.6-for-Dual-network-card-settings
Recommended Posts