Centos7.6 dual network card configuration and switching test

**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

1. Constructing a dual network card test environment##

The system currently has only one network card, and a dual network card environment needs to be constructed.

1. Existing environment view###

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

2. Add a new network card

The existing environment has only one network card

Add a network card

3. View newly added network card

Two, dual network card configuration##

1. New ifcfg-bond0

[ 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.

2. Configure network card ifcfg-ens160

[ 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

3. Configure ifcfg-ens190

[ 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

4. Restart network###

[ root@client ~]# systemctl restart network

Restart network or host

5. View network

NIC bond0 has been tied to ip 172.27.34.85

Three, dual network card switch test##

1. Main network port view

[ root@client ~]#  cat /proc/net/bonding/bond0 

Dual network card mode is active and standby, the main network card is ens160

2. Close 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

3. Start ens160

[ 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

Centos7.6 dual network card configuration and switching test
CentOS8 network card configuration file
CentOS6/CentOS7 dual network card configuration bonding
CentOS7.0 network configuration
CentOS 7.0 network configuration
CentOS7 modify network card name and network repair
Ubuntu 18.04 network card configuration
Tencent cloud centos 8.0 single network card configuration multiple IP
Centos mysql installation and configuration
Centos7 installation and configuration prometheus
CentOS 7 installation and configuration PPTP
CentOS installation and configuration cmake
Centos7.5 installation and configuration MongoDB4.0.4
CentOS 7 installation and configuration PPTP
Implementation of CentOS8.0 Network Configuration
Centos7 installation and configuration of Jenkins
CentOS 8 install Git and basic configuration
Centos7 hadoop cluster installation and configuration
CentOS7 modify the network card name
Detailed examples of Centos6 network configuration
Java-JDK installation and configuration under CentOS
CentOS 7 Tomcat service installation and configuration
Centos 7 RAID 5 detailed explanation and configuration
Centos7 change the network card name
CentOS NTP server installation and configuration
Centos7 mysql database installation and configuration
CentOS 7 system installation and configuration graphic tutorial
Tomcat installation and configuration under CentOS 7 (Tomcat startup)
Installation and configuration of redis under centos7
Centos7 hive stand-alone mode installation and configuration
Centos7 configuration host name and IP address
VMware Fusion install CentOS7 and configure the network
CentOS 6.5 system installation and configuration graphic tutorial (detailed graphic)
CentOS7 and Docker configuration Chinese character set problem
CentOS 7 installation and configuration graphic tutorials under VMware10
Install svn and configuration through yum under CentOS
Installation and configuration of rsync server under CentOS 6.5
Installation and configuration of CentOS 7 in VMware Workstation
Installing CentOS 6 and SSH configuration under Windows 8 Hyper-V
IP and network settings of CentOS Linux 7 VMware
MySQL 8.0 installation, deployment and configuration tutorial on CentOS 8
CentOS6.5 network settings
CentOS7 basic configuration
Centos MySQL8 configuration
Environment configuration of JDK, mysql and tomcat under Centos7
Linux firewall related configuration commands and operations (centos and ubuntu)