Friday, May 18, 2012

Adding virtual IP in Ubuntu

Following are the steps I followed to add new virtual IP in Ubuntu

- Edit interfaces file and add following entry to add a second ip

Command to be used: $ vi /etc/network/interfaces


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

The new ip should be in the same network as currently using IP and it shouldn't be in use already.

Note : To check the ethernet device name, you can use following command

$ ifconfig | grep eth


- Now restart the network

$ /etc/init.d/networking restart


- If everything goes smoothly, you'll see following printed in console for above command


* Reconfiguring network interfaces...                                        
 ssh stop/waiting
ssh start/running, process 5436
start: Job failed to start
ssh stop/waiting
ssh start/running, process 5558
start: Job failed to start                                                                         [ OK ]

- Verify the change using one of the following commands

$ ifconfig | grep eth
$ ifconfig

Tips : For /etc/init.d/networking restart, sometimes you may come across following error


 * Reconfiguring network interfaces...                                        
SIOCSIFADDR: No such device
etho:1: ERROR while getting interface flags: No such device
etho:1: ERROR while getting interface flags: No such device
Failed to bring up etho:1

To solve this go to interface file ($ vi /etc/network/interfaces)


There your entry will look like........


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

Just enter tab before 3rd and 4th  lines....

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


And it will solve your issue....






No comments:

Post a Comment