Recently I got into problem to assign 2 IPs on one physical NIC.

There was nothing mentioned in official documentation so I did some research and find the solution.

It is really simple if you are not afraid from command line and VI editor. Unfortunately I did not find a GUI.

Here it is:

  1. Go to command prompt
  2. Be sure that you are root. Otherwise type su – to become.
  3. Type – cd /etc/sysconfig/network-scripts/
  4. Then type ls to see the contents – you should have file ifcfg-eth0 if you have just one interface otherwise if you have multiple interfaces there you’ll find other files like ifcfg-eth1…n.
  5. Then we will copy the file to different name – cp ifcfg-eth0 ifcfg-eth0:0
  6. Next step is to edit newly created file and put the IP we needed.
  7. If needed repeat steps 5 and 6 with different numbers after”:” (1,2,…) to add additional addresses.
  8. If you issue ifconfig you will not see newly created interface, because it is no activated – you need to restart network /etc/init.d/network restart will do it for you.
  9. That’s it.

Comments are welcome.


One Response to “How to have two IPs on one interface”

  1. J on December 30th, 2010 10:26 am

    One thing is missing in your steps. In step 5, you need to change the IP, but also change the “DEVICE” field to “eth0:0”. Without this extra step, the ifcfg-eth0:0 file will override the network settings of the ifcfg-eth0 file when going up.

    I think the official documentation is in “sysconfig.txt”, but it isn’t documented very well.

Leave a Reply

You must be logged in to post a comment.