[FrontPage] [TitleIndex] [WordIndex

This is a read-only archived version of wiki.centos.org

Setting up many IP addresses on one physical network interface

In some cases you may need to setup several ip addresses to be served by the same physical network interface. For example, you may want to have DNS service running on your dedicated server with only one network card. Each domain must have two nameservers with two distinct IP addresses.

This can be accomplished by using so called virtual interfaces tied to a physical network adapter.

1. Method 1: Few IP addresses. Manual way.

If you want to setup only a few IP addresses, you may do the following:

cp /etc/sysconfig/network-scripts/ifcfg-eth0 cp /etc/sysconfig/network-scripts/ifcfg-eth0:0
nano -w /etc/sysconfig/network-scripts/ifcfg-eth0:0

We are just copying existing interface configuration file to a new one to create virtual interface. In this example, I supplose you want to add IP address to the interface named eth0. If you want to add addresses to another interfaces, type it's name everywhere instead of "eth0" in instructions.

In the opened editor window you need to replace "eth0" with "eth0:0" and old IP address with a new one. Save the file. To apply changes immediately you need to just issue the following command:

ifup eth0:0

Some people recommend to do

service network restart

but I don't think it is really necessary. This will also make all current network connections to server to be closed.

Ok, your new IP should now be working and you may test it with "ping". Please note, that your provider need to dedicate an IP address you are adding to your server. It needs to be included into your provider's routing tables and router configuration. So, before doing any configuration changes to your server, ensure your provider did all that.

To add more IP addresses repeat instructions above just changing "eth0:0" to "eth0:1" etc.

2. Method 2: Many IP sequential IP addresses. Automatic.

In case you want to assign many IP addresses to the same network interface (10, 100, 1000?) you may use the following technique. Issue the following command:

nano -w /etc/sysconfig/network-scripts/ifcfg-eth0-range0

Type the following lines into the file:


You can even create several ranges (ifcfg-eth0-range1, ifcfg-eth0-range2 etc.). Just take care of CLONENUM_START value for these ranges not to overlap. To apply configuration you will need to issue

service network restart

3. Notes

2023-09-11 07:23