Wednesday, July 9, 2008

Unix creating virtual network interface

Recently, I happened to be searching the man pages of ifconfig on how to add a virtual IP to a unix machine. The examples and the help text was not very helpful and I endedup googling for it. I came across a nice HOw TO article on this and I am providing the content and the link here. I followed the instructions and I was able to create an interface in minutes.


Let’s assume our network card is eri0, and we want to create a virtual interface called eri0:1

Create the virtual interface:
# ifconfig eri0:1 plumb

Configure the virtual interface:
# ifconfig eri0:1 179.164.83.161 netmask 255.255.255.0 broadcast 179.164.83.255

Check to make sure it worked:

# ifconfig -a

lo0: flags=1000849 mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
eri0: flags=1000843 mtu 1500 index 2
inet 179.164.83.160 netmask ffffff00 broadcast 179.164.83.255
ether 0:3:ba:9:63:9b
eri0:1: flags=1000842 mtu 1500 index 2
inet 179.164.83.161 netmask ffffff00 broadcast 179.164.83.255

Finally bring up your new virtual interface:
# ifconfig eri0:1 up

To make it come up on start:

create /etc/hostname.eri0:1 with hostname in it
make sure the hostname is in /etc/hosts

No comments: