In Linux, dual-nic binding is achieved by virtualizing two NICs into one Nic. In other words, two NICs have the same IP address, and parallel links are aggregated into one logical link. In fact, this technology already exists in Sun and Cisco, known as Trunking and Etherchannel technology. It is also used in Linux 2.4.x kernel, known as bonding.
Under normal circumstances, the network adapter only receives the target hardware Address (MAC Address) as the Ethernet frame of its Mac, and filters out other data frames to reduce the burden on the driver. However, the NIC also supports the promisc mode to receive all frames on the network. tcpdump and bonding run in this mode and modify the mac address of the driver, change the Mac address of the two NICs to the same one to receive data frames of a specific mac. Then, the data frame is sent to the bond driver for processing.
When the dual Nic is working, it is represented as a virtual NIC (bond0). The virtual NIC also needs a driver named bonding.
Check whether the kernel supports dual-nic binding
Vim/boot/config-2.6.18-164.e15
This network mode is supported, and BOUNDING is a built-in module.
Enter
After the network card is bound to a uniform ip address, you do not need to set the ip address for eth0 and eth1.
1. Edit the virtual network interface configuration file and specify the nic ip Address
# Cd/etc/sysconfig/network-scripts/
# Cp ifcfg-eth0 ifcfg-bon0
Modify the ifcfg-bon0 information as follows:
DEVICE = bond0
BOOTPROTO = static
IPADDR = [IP]
NETMASK = [MASK]
BROADCAST = [BROADCAST]
GATEWAY = [GATEWAY]
ONBOOT = yes
TYPE = Ethernet
2. Configure the real Nic
Modify ifcfg-eth0 as follows:
DEVICE = eth0
BOOTPROTO = none
ONBOOT = yes
MASTER = bond0 # If no write is performed, step 4 is required.
SLAVE = yes # if not written, step 4 is required.
USERCTL = yes
Similar repair ifcfg-eth1 is as follows:
DEVICE = eth1
BOOTPROTO = none
ONBOOT = yes
MASTER = bond0 # If no write is performed, step 4 is required.
SLAVE = yes # if not written, step 4 is required.
USERCTL = yes
3. Load the module so that the system supports bonding
By default, the kernel supports bonding. You only need to modify the configuration file/etc/modprobe. conf to add two lines.
Alias bond0 bonding
Options bond0 miimon = 100 mode = 1
Note:
Mode specifies the bond0 working mode. 0 and 1 are commonly used to indicate the load balancing mode. 1 indicates the master-slave mode. You can configure it as needed. Commonly used are 0, 1. Mode = 0 indicates that load balancing is a load balancing method, and both network adapters work. Mode = 1 indicates that active-backup provides redundancy and adopts the active/standby mode. That is, by default, only one Nic works and the other is used for backup. Bonding can only provide link monitoring, that is, whether the link from the host to the switch is connected. If the external link of the switch is down and the switch is not faulty, bonding considers that the link is correct and continues to be used. Miimon is used for link monitoring. For example: miimon = 100, The system monitors the link connection status every Ms. If one line fails, it is transferred to another line.
4. Add boot script
Add/etc/rc. d/rc. local
Ifenslave bond0 eth0 eth1
If both eth0 and eth1 write MASTER and SLAVE, the above steps do not matter.
5. Restart
Reboot or service network restart can see the results.
Recommended reading:
RedHat Enterprise Linux AS 4 dual Nic Server Load balancer
Solution to the problem that the dual Nic IP address in RHEL cannot be accessed at the same time
Bind a CentOS dual-nic to achieve load balancing and Failover
Bind a single IP address to a dual-nic in Linux [CentOS]
RedHat 6.2 dual Nic binding