BKJIA exclusive Article] bind an IP address to a Linux dual Nic. The essence of the work is to use two NICs as a virtual one. Using the same IP address is a better and faster service. 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. This article uses Debian as an example to introduce the implementation of this technology.
Bonding principles
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 another mode called hybrid mode that can receive all frames on the network. For example, many packet capture tools need to run the NIC in this mode. Bonding also runs in this mode, and modifies the MAC address in the driver, changing the MAC address of the two NICs to the same, can receive data frames of a specific MAC. Then, the data frame is sent to the bond driver for processing.
How the bonding module works
There are seven bonding Modes: 0-6. The common working modes are 0, 1, and 6:
Mode = 0: indicates that load balancing (round-robin) is required for both network adapters in Server load balancer mode. However, the switch must support and be configured on the switch.
Mode = 1: indicates that fault-tolerance (active-backup) provides redundancy, working in the active mode, that is, by default, only one network card works, and the other is used for backup.
Mode = 6: indicates that load balancing (round-robin) is required for both network adapters in Server load balancer mode.
Bonding configuration
Run the following command to install bonding.
srv10:~# apt-get install ifenslave
Run the following command to enable the system to automatically load the module bonding. The miimon parameter 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. The value of mode indicates bonding mode.
srv10:~# sh -c "echo bonding mode=6 miimon=100 >> /etc/modules"
Modify the/etc/network/interfaces file as follows.
Auto loiface lo inet loopback auto scaling bond0 inet static # virtual network card TCP/IP configuration address 255.255.255.255.0gateway 255.192.168.159.1post-up ifenslave bond0 eth0 eth1pre-down ifenslave-d bond0 eth0 eth1
If the computer is not restarted after ifenslave is installed, you must manually load the bonding module.
srv10:~# modprobe bonding mode=6 miimon=100
Run the following command to restart the NIC.
srv10:~# /etc/init.d/networking restart
Author profile: Zhang Qin blog), MCSE, mcba, RHCE, engaged in software development (Delphi, Java), project management, system integration. He has participated in many Windows and Linux-based large-scale system integration projects and published technical articles on multiple well-known IT websites in China.