Home > Article > System Tutorial > Detailed explanation of dual network card master and backup mode configuration under CentOS
1 Brief description
Set the active and backup mode through dual network cards, so that when one network card fails, the other network card can automatically replace the failed network card to ensure normal network access.
2 Implementation
2.1. View network card information
Execute ifconfig -a command
2.2. Modify the network card configuration file
Switch working directory
cd /etc/sysconfig/network-scripts/
Modify the network card configuration file ifcfg-eth0 and ensure that the following contents are correct:
TYPE=Ethernet
BOOTPROTO=dhcp
ONBOOT=yes
MASTER=bond0
SLAVE=yes
Modify the network card configuration file ifcfg-eth1. If it is not created, ensure that the following contents are correct (same as above):
DEVICE=eth1
TYPE=Ethernet
BOOTPROTO=dhcp
ONBOOT=yes
MASTER=bond0
SLAVE=yes
2.3. Virtual network card file configuration
Create a file
touch ifcfg-bond0
Edit the file and add the following content:
DEVICE=bond0
TYPE= Ethernet
ONBOOT=yes
BOOTPROTO=none
IPADDR="192.168.137.243"
NETMASK="255.255.255.0"
GATEWAY="192.168.137.1"
DNS="192.168.137.1"
NAME=bond0
BONDING_OPTS=”miimon=100 mode=1”
Note: If BONDING_OPTS is in a virtual machine, you need to add fail_over_mac=1 such as BONDING_OPTS=”miimon=100 mode=1 fail_over_mac=1”
The following items should be set according to the network environment:
IPADDR="192.168.137.243"
NETMASK="255.255.255.0"
GATEWAY="192.168.137.1"
DNS="192.168.137.1"
PREFIX=24
2.4. Restart the service
implement :
service network restart
Or reboot to restart the server
2.5. Check status
ifconfig
View active and backup information:
2.6. Test
Close the network card eth0
ifconfig eth0 down
Ping the ip to see if it can be connected.
Check whether the primary and secondary switches are switched:
Finish
The above is the detailed content of Detailed explanation of dual network card master and backup mode configuration under CentOS. For more information, please follow other related articles on the PHP Chinese website!