How to have two IPs on one interface
Wednesday, February 27th, 2008Recently 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:
- Go to command prompt
- Be sure that you are root. Otherwise type su - to become.
- Type - cd /etc/sysconfig/network-scripts/
- 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.
- Then we will copy the file to different name - cp ifcfg-eth0 ifcfg-eth0:0
- Next step is to edit newly created file and put the IP we needed.
- If needed repeat steps 5 and 6 with different numbers after”:” (1,2,…) to add additional addresses.
- 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.
- That’s it.
Comments are welcome.