Today inadvertently learned that a network card can bind multiple IP settings, and then want to see others about this kind of document, and found the network card binding application and settings, and some detailed one card multi-IP configuration, in this summary;
One NIC binds multiple IPs
Sometimes we do have such a demand, because I am a novice encountered not much, I encountered is in the high availability of the main standby cluster, because to set up a mobile (virtual) IP, so on the original network card configured with a virtual IP;
Nic Eth0:192.168.1.103 netmask:255.255.255.0
Temporary configuration
Ifconfig eth0:0 192.168.0.1 netmask 255.255.255.0 up
Ifconfig eth0:1 192.168.0.2 netmask 255.255.255.0 up
Test
Ping 192.168.0.1
Ping 192.168.0.2
Change the eth0 to Eth0:x (x=0-255), eth0:x is called the virtual network interface, is based on the network Interface (eth0) top;
The temporarily configured IP will disappear after the restart.
Permanent configuration
Method One: Add the above command to the automatic execution of the/etc/rc.d/rc/local script;
Law two: Write a configuration file for the virtual network card
cd/etc/sysconfig/network-scripts/
CP Ifcfg-eth0 ifcfg-eth0\:0 \ de-righteousness character
Vim ifcfg-eth0:0 Copy the Ifcfg-eth0 content to the past and change the following
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/74/57/wKiom1YaQzXTLqnmAAC4B7FrJWE862.jpg "title=" TE. PNG "alt=" Wkiom1yaqzxtlqnmaac4b7frjwe862.jpg "/>
Just change the device and ipaddr, whatever.
As long as the device name and IP are not the same, you can add 255 such IP, but it will not be necessary, the same configuration method;
Multi-NIC Binding
Linux under the dual-NIC binding technology to achieve load balancing and failure protection, not only increased the reliability of the server, but also increased the available network bandwidth, to provide users with uninterrupted key services.
The two-Nic binding implementation is to use two network card virtual become a network card;
In fact, this technology has long existed in sun and Cisco, known as Trunking and EtherChannel technology, which is also used in the Linux 2.4.x kernel, known as bonding.
Under normal circumstances, the network card only receives the destination hardware address (MAC addresses) is the Ethernet frame of its own Mac, filtering out other data frames to reduce the burden on the driver. But the NIC also supports another mode called promiscuous Promisc, which can receive all the frames on the network, such as Tcpdump, which is running in this mode.
Bonding also runs in this mode, and modifies the MAC address in the driver, changing the MAC address of the two NIC to the same, and receiving data frames for a particular Mac. The corresponding data frames are then routed to the bond driver for processing.
Binding condition: The chipset model is the same, and the NIC should have its own independent BIOS chip
Edit the virtual network interface configuration file, specify the network card IP
cd/etc/sysconfig/network-scripts/
CP Ifcfg-eth0 IFCFG-BOND0
Vim ifcfg-bond0 changes the first line to Device=bond0
Device=bond0
Bootproto=static
ipaddr=172.31.0.13
netmask=255.255.252.0
broadcast=172.31.3.254
Onboot=yes
Type=ethernet
Note Here, do not specify the IP address of a single network card, subnet mask or network card ID, to DHCP dynamic acquisition of IP;
Configuring the boot loader module
Vi/etc/modules.conf
Add to:
Alias Bond0 Bonding
Options Bond0 miimon=100 mode=1
The Miimon is used for link monitoring. For example: miimon=100, then the system every 100MS monitoring link connection status, if one line is not connected to another line; Mode value indicates the mode of operation, he has 0,1,2,3 four modes, commonly used for 0, 12 kinds.
The mode=0 indicates that load balancing (round-robin) is balanced, and both NICs work.
Mode=1 indicates that fault-tolerance (active-backup) provides redundancy, working in a way that the primary and standby means
By default, only one NIC works and the other is backed up.
Bonding can only provide link monitoring, i.e. whether the link from the host to the switch is connected. If the switch external link is down, and the switch itself is not faulted, then bonding will assume that the link is not a problem and continue to use
Configuring the Boot Execution script
Vi/etc/rc.d/rc.local
Add to
Ifenslave bond0 eth0 Eth1 Specify the order of work
Route add-net 172.31.3.254 netmask 255.255.255.0 bond0 set static routes
Reboot: See the following message to indicate that the configuration was successful
................
Bringing Up interface Bond0 OK
Bringing Up interface eth0 OK
Bringing Up interface eth1 OK
Mode=1 work in the main standby mode, when a network interface fails, there will be no network interruption, the system will follow the cat/etc/rc.d/rc.local in the order of the specified network card, the machine can still serve the external services, played a function of failure protection.
Ifconfig Verifying the configuration information of the NIC
Bond0 Link encap:ethernet HWaddr 00:0e:7f:25:d9:8b
inet addr:172.31.0.13 bcast:172.31.3.255 mask:255.255.252.0
Up broadcast RUNNING MASTER multicast mtu:1500 metric:1
RX packets:18495 errors:0 dropped:0 overruns:0 frame:0
TX packets:480 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1587253 (1.5 Mb) TX bytes:89642 (87.5 Kb)
Eth0 Link encap:ethernet HWaddr 00:0e:7f:25:d9:8b
inet addr:172.31.0.13 bcast:172.31.3.255 mask:255.255.252.0
Up broadcast RUNNING SLAVE multicast mtu:1500 metric:1
RX packets:9572 errors:0 dropped:0 overruns:0 frame:0
TX packets:480 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:833514 (813.9 KB) TX bytes:89642 (87.5 KB)
Interrupt:11
eth1 Link encap:ethernet HWaddr 00:0e:7f:25:d9:8b
inet addr:172.31.0.13 bcast:172.31.3.255 mask:255.255.252.0
Up broadcast RUNNING noarp SLAVE multicast mtu:1500 metric:1
RX packets:8923 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:753739 (736.0 Kb) TX bytes:0 (0.0 b)
Interrupt:15
In the Mode=0 load balancing operation mode, he can provide twice times the bandwidth, in this case a network card failure, will only be the server egress bandwidth drop, and will not affect network use.
Ifconfig
Bond0 Link encap:ethernet HWaddr 00:0e:7f:25:d9:8b
inet addr:172.31.0.13 bcast:172.31.3.255 mask:255.255.252.0
Up broadcast RUNNING MASTER multicast mtu:1500 metric:1
RX packets:2817 errors:0 dropped:0 overruns:0 frame:0
TX packets:95 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:226957 (221.6 KB) TX bytes:15266 (14.9 KB)
Eth0 Link encap:ethernet HWaddr 00:0e:7f:25:d9:8b
inet addr:172.31.0.13 bcast:172.31.3.255 mask:255.255.252.0
Up broadcast RUNNING SLAVE multicast mtu:1500 metric:1
RX packets:1406 errors:0 dropped:0 overruns:0 frame:0
TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:113967 (111.2 KB) TX bytes:7268 (7.0 KB)
Interrupt:11
eth1 Link encap:ethernet HWaddr 00:0e:7f:25:d9:8b
inet addr:172.31.0.13 bcast:172.31.3.255 mask:255.255.252.0
Up broadcast RUNNING SLAVE multicast mtu:1500 metric:1
RX packets:1411 errors:0 dropped:0 overruns:0 frame:0
TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:112990 (110.3 KB) TX bytes:7998 (7.8 kb)
Interrupt:15
By looking at the working status of BOND0, we can understand the working status of bonding in detail.
[Email protected] bonding]# cat/proc/net/bonding/bond0
bonding.c:v2.4.1 (September 15, 2003)
Bonding mode:load Balancing (round-robin)
MII Status:up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0
Multicast Mode:all Slaves
Slave interface:eth1
MII Status:up
Link Failure count:0
Permanent HW addr:00:0e:7f:25:d9:8a
Slave Interface:eth0
MII Status:up
Link Failure count:0
Permanent HW addr:00:0e:7f:25:d9:8b
Two places are not very clear:
First Route add-net 172.31.3.254 netmask 255.255.255.0 bond0?
Is the second pair of bond0 eth0 eth1 configured for dynamic DHCP acquisition?
My understanding is that three NICs are configured as DHCP, the IP that configures the static route is pointing to three network cards, but the problem is that the following ifconfig get
IP, but it's 172.31.0.13, why?
Application of network card and IP