Article title: Principles and implementation of binding an IP address to a Linux dual-Nic. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Dual-Nic binding technology in Linux for load balancing and failure protection
Cgweb
Maintaining the high availability of servers is an important factor in the enterprise IT environment. The most important thing is the high availability of server network connections. NIC binding helps ensure high availability and provide other advantages to improve network performance.
We will introduce how to bind two NICs in Linux to a virtual network card. the aggregated device looks like a separate Ethernet interface device, in general, two NICs have the same IP address, and parallel links are aggregated into a 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. The earliest application of bonding technology was on the cluster beowulf, designed to improve data transmission between cluster nodes. Next we will discuss the principles of bonding. what is bonding? it should start with the promisc mode of the NIC. We know that, under normal circumstances, the network adapter only receives the target hardware Address (MAC Address) as its own Mac Ethernet frame, and filters out all other data frames to reduce the burden on the driver. However, the NIC also supports another mode called hybrid promisc, which can receive all frames on the network. for example, tcpdump runs 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.
After talking about the theory for half a day, the configuration is actually very simple. There are four steps in total:
The operating system of the experiment is Redhat Linux Enterprise 3.0.
Prerequisites: the chipset model is the same, and the NIC should have its own independent BIOS chip.
Topology of dual Nic bonding
1. new/etc/sysconfig/network-scripts/ifcfg-bond0 file
DEVICE = bond0
ONBOOT = yes
BOOTPROTO = static
IPADDR = 192.168.0.23
NETMASK = zookeeper
GATEWAY = 192.168.128.233
USERCTL = no
Do not specify the IP address, subnet mask, or Nic ID of a single NIC. Specify the above information to the virtual adapter (bonding.
2. change/etc/sysconfig/network-scripts/ifcfg-eth0 Nic properties
DEVICE = eth0
ONBOOT = yes
BOOTPROTO = none
MASTER = bond0
USERCTL = no
3. change the properties of the/etc/sysconfig/network-scripts/ifcfg-eth1 Nic
DEVICE = eth1
ONBOOT = yes
BOOTPROTO = none
MASTER = bond0
USERCTL = no
Source: DIY tribe
4 # vi/etc/modules. conf
Edit the/etc/modules. conf file and add the following line to enable the system to load the bonding module at startup. the external virtual network interface device is bond0.
Add the following two rows
Alias bond0 bonding
Options bond0 miimon = 100 mode = 1
Note: 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. The value of mode indicates the working mode, which has a total, two or three modes, commonly used: 0, 1.
Mode = 0 indicates that the load balancing (round-robin) method is load balancing, and both NICs work.
Mode = 1 indicates that fault-tolerance (active-backup) provides redundancy, working in the active/standby mode. that is to say, by default, only one network card 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.
5 # vi/etc/rc. d/rc. local
Add two rows
Ifenslave bond0 eth0 eth1
Route add-net 172.31.3.254 netmask limit 255.255.0 bond0
6. after the configuration is complete, restart the machine.
The following information is displayed after restart, indicating that the configuration is successful.
................
Bringing up interface bond0 OK
Bringing up interface eth0 OK
Bringing up interface eth1 OK
[1] [2] Next page