Adding Virtual IP in Ubuntu

First of all check the ethernet device name, you may use the below command for the same.

$ ifconfig | grep eth

eth0      Link encap:Ethernet  HWaddr 70:5w:x6:2b:63:f9

To add virtual IP address edit the interfaces file

$ vi /etc/network/interfaces

And add the below data, ensure the IP which you are going to mention are in the same network as currently used IP address. Also ensure that the IP being added is not used in the network. Add the below entries to the end of the interfaces file.

auto eth0:1
iface eth0:1 inet static
address 192.168.1.50
netmask 255.255.255.0

Now it is time to restart the network

$ /etc/init.d/networking restart

Now to check if the new interface has come up you could use the first command itself

$ ifconfig | grep eth

eth0      Link encap:Ethernet  HWaddr 70:5w:x6:2b:63:f9

eth0:1      Link encap:Ethernet  HWaddr 70:5w:x6:2b:63:f9

So you have 2 interfaces on your machine now, with 2 different ips which can be accessed from your LAN.

Hope this was helpful 🙂

Leave a Comment