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 netmask broadcast

Check to make sure it worked:

# ifconfig -a

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

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

1 comment:

Unknown said...

Hi, Your blog is really very informative and useful for me. Thanks for sharing this valuable blog.
Unix Training Institutes in Chennai