1. Create a virtual NIC as a configuration file to bind the network port/ETC/SYSCONFIG/NETWORK-SCRIPTS/IFCFG-BOND0
The configuration content is as follows:
#cat/etc/sysconfig/network-scripts/ifcfg-bond0
Device=bond0 #虚拟网卡名称
Type=ethernet
Onboot=yes
Bootproto=static
ipaddr=192.168.11.130 #IP地址
netmask=255.255.255.0 #子网掩码
gateway=192.168.11.2 #网关
dns1=223.5.5.5 #DNS地址
dns2=223.6.6.6
bonding_opts=miimon=100 mode=0
2, modify the/etc/sysconfig/network-scripts/ifcfg-eth0 configuration, the content is as follows:
Device=eth0
Type=ethernet
Onboot=yes
Bootproto=none
Master=bond0
Slave=yes
Modify the/etc/sysconfig/network-scripts/ifcfg-eth1 configuration with the following content:
Device=eth1
Type=ethernet
Onboot=yes
Bootproto=none
Master=bond0
Slave=yes
3, modify the/etc/modprobe.d/dist.conf, configure the binding model, the configuration file finally added the following content
#tail-2/etc/modprobe.d/dist.conf
Alias Bond0 Bonding
Options Bond0 miimon=100 mode=0
#选项 Miimon Specifies how long it takes to monitor the link, in Ms.
#选项 mode indicates the working mode of the binding port, there are 0-6 total 7 modes, which are commonly used in 0 and 1 modes,
Mode=0 represents the "Round-robin" policy, and the two cards work simultaneously in a load-balanced state.
The mode=1 represents the "active-backup" policy, and the backup status of the two cards is one with one standby.
Use/etc/init.d/network Restart to restart the network after the above configuration has been modified.
To prevent the server from restarting, add the following to the/etc/rc.local:
#echo "Ifenslave bond0 eth0 eth1" >>/etc/rc.local
Check if join is successful
#tail-1/etc/rc.local
Ifenslave bond0 eth0 eth1
4. Testing
After any piece of network card is Ifdown, it does not affect the normal communication of the server
Linux Dual NIC Bindings