Setting up a virtual interface in Linux

In linux setting up a virtual interface is a piece of cake. You just need to issue two commands, and you are done.

first you need to assign an ip to the cirtual interface.

/sbin/ifconfig interface:virtual# IPADDRESS

or

/sbin/ifconfig eth0:1 192.168.1.2

Then you set up a route for this interface so that your computer can see it.. With out the route command you will not be able to reach the new interface, but the rest of the network can. So this step is just to keep things tidy on the hosts side.

/sbin/route add IPADDRESS dev interface:virtual#

or

/sbin/route add 192.168.1.2 dev eth0:1

That's basically it. remember this interface will go away when you reboot, so read up on your distro and see how to add an interface on startup. I got lazy on my box and created /etc/virtuals/rc.virtuals which is just a script that sets up my virtual interfaces, and is called at the end of rc.local

-Fratm

Powered by Drupal - Design by artinet