Under Linux sometimes need a network card to bind multiple IP, this article describes Redhat series (redhat, Fedora Core, Centos) in the implementation and a kind of Gentoo Linux and other commonly applied methods.
1, a single card to bind multiple IP in Redhat series implementation assumptions need to bind multiple IP network card is eth0, in the / etc / sysconfig / network-scripts directory create a file called ifcfg-eth0: 0 file,
Contents of the sample as follows:
| DEVICE = "eth0: 0"
IPADDR = "192.168.0.2"
BROADCAST = "220.127.116.11"
NETMASK = "255.255.255.0"
ONBOOT = "yes"
Where DEVICE is the device name, IPADDR this device's IP address, BROADCAST a broadcast address, NETMASK is the subnet mask, ONBOOT that start automatically at boot time.
If you need to bind more than one IP address, just put the file name and the DEVICE in the eth0: x-plus-one can.
LINUX can support up to 255 IP alias 2, universally applicable single-NIC binding multiple IP implementation ifconfig eth0: 1 192.168.0.3 broadcast 192.168.0.255 netmask 255.255.255.0
The command can be added to the startup file from running inside, is under Gentoo / etc / conf.d / local.start, and some versions of Linux is / etc / rc.d / rc.local.
3 more cards share a single IP implementations use multiple network cards into a virtual network card, have the same IP address. In fact, the technology already exists in the sun and cisco are called Trunking and etherchannel technology, linux , this technique called bonding. because the bonding has been included in kernel 2.4.x, and only at compile time to network device option selected in the Bonding driver support on it.
Then, recompile the kernel, restart your computer, execute the following command:
| ismod bonding
ifconfig eth0 down
ifconfig eth1 down
ifconfig bond0 ipaddress
ifenslave bond0 eth0
ifenslave bond0 eth1
Now has two network cards work the same as the one, this can increase the data transfer between the cluster nodes.
You'd better put a few words written in a script, then / etc / rc.d / rc.local or / etc / conf.d / local.start call for a boot on the force.
bonding for the server to be a better choice, when in the absence of Gigabit Ethernet, 100 MB card with twenty-three for bonding, can greatly improve the server to exchange bandwidth between machines. But the need to switch on the machine to set the connection bonding the two hole cards with a virtual interface map.