Sunday, August 9, 2009

Howto setup Second IP address or Virtual IP address to your Networkcard in ubuntu

If you are a Network Administrator some time you need to assign more than ONE ip address (second ipaddress) to your network card of Ubuntu machine. For this you need to edit the /etc/network/interfaces file by adding the following lines . See the example below and make change according to your ip address settings

#vi /etc/network/interfaces

auto eth0
iface eth0 inet static
address 192.168.0.5
netmask 255.255.255.0
network x.x.x.x
broadcast x.x.x.x
gateway x.x.x.x

auto eth0:1
iface eth0:1 inet static
address 192.168.0.50
netmask 255.255.255.0
network x.x.x.x
broadcast x.x.x.x
gateway x.x.x.x

after entering the values save this file and you need to restart networking services in ubuntu using the following command to take effect of our new ipaddress.

After entering all the details you need to restart networking services using the following command

#/etc/init.d/networking restart

5 comments:

Anonymous said...
This comment has been removed by a blog administrator.
ഇരുതലമൂരി said...

അടി പൊളി

Anonymous said...

uhm your example shows TWO seperate netword cards, not 2 addresses on one card.

Anonymous said...

The example I see (perhaps it has been
changed since you commented) has one
network card (eth0) with two addresses,
one assigned to the default interface
(eth0) and the second assigned to the first
virtual interface (eth0:1) on the same
card.

dr0x Ventures said...

You can also do this on the fly, using something like this:

ifconfig eth0:1 192.168.0.2 up

You won't have to issue '/etc/init.d/networking restart' but make sure that you setup the configuration file still because it won't survive a reboot.

InternetTechnology Research