There are times when you need to bind multiple IPs to a network adapter under Linux, this article describes the implementation methods in the Redhat series (Redhat,fedora Core,centos) and a method that is universally applicable in other Linux such as Gentoo.
1, single-NIC binding multi-IP in the Redhat series implementation method
Assuming that the NIC that needs to bind multiple IPs is eth0, create a file named ifcfg-eth0:0 in the/etc/sysconfig/network-scripts directory.
Examples of the content are:
Device= "Eth0:0″
Ipaddr= "192.168.0.2″
Broadcast= "172.168.0.255″
Netmask= "255.255.255.0″
Onboot= "Yes" is the device name, ipaddr the IP address for this device, broadcast is the broadcast address, netmask is the subnet mask, and Onboot indicates that it starts automatically when the system starts.
If you need to bind more than one IP address, simply add the file name and the eth0:x in the device in the file.
Linux can support a maximum of 255 IP aliases
2, universal application of single-NIC binding multi-IP Implementation method
Ifconfig eth0:1 192.168.0.3 broadcast 192.168.0.255 netmask 255.255.255.0
The above command can be added to the startup self-running file, under Gentoo is/etc/conf.d/local.start, and some versions of Linux is/etc/rc.d/rc.local.
3, multi-network card common single-IP implementation method
Use multiple NICs to become a network card with the same IP address. This technology is in fact already in Sun and Cisco, known as Trunking and EtherChannel technology, which is called bonding in Linux. Because Bonding is already included in the kernel 2.4.x, it is only possible to select the Bonding driver support in the network device option at compile time.
Then, recompile the core, restart the computer, and execute the following command: Ismod bonding
Ifconfig eth0 Down
Ifconfig eth1 Down
Ifconfig bond0 IPAddress
Ifenslave bond0 eth0
Ifenslave bond0 eth1 Now two NICs have worked like a piece, which can improve data transfer between cluster nodes.
You'd better write these sentences into a script, which is called by/etc/rc.d/rc.local or/etc/conf.d/local.start, so that it takes effect when you start the boot.
Bonding for the server is a better choice, in the absence of gigabit network card, with two or three 100 gigabit network card for bonding, can greatly improve the server to switch bandwidth. However, it is necessary to set the connection on the switch bonding network card two holes mapped to the same virtual interface.
Transferred from: http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=70565&id=2070951
Remove Alias
IP addr del 192.168.0.1 dev eth0:1
[Go] Linux network card alias multi-IP