My-Tiny.Net :: Networking with Virtual Machines
Virtual Ethernet Interfaces
While we're on the subject of kernel capabilities, virtual ethernet interfaces (Veth here, some refer to these as Virtual IP addresses or VIPs) allow you to use multiple IP addresses on a single physical network interface. The main advantage of this is that you don't need to have a physical adapter attached to each IP, but instead you can create multiple or many virtual interfaces (aliases) to a single physical card. This is commonly done to allow webservers to host multiple SSL encrypted web sites on a single webserver, or to allow VPNs to communicate on a dedicated IP address
There are two ways to create Veth on Linux hosts. The first method is to use ifconfig, which most everyone is familiar with. This command will create a Veth named eth1:0
ifconfig eth1:0 192.168.1.28
This creates an apparently separate device from eth1 with
it's own IP address, netmask, and broadcast address.
Notice there is no gateway - usually you can only have one gateway per machine.
After creating the Veth, update the routing table with arping, using the real interface to bind this Veth to and the IP address which was assigned in the ifconfig statement
arping -q -U -c 3 -I eth1 192.168.1.28
This Veth can now be used to host services and servers, fielding connections to clients or other hosts. To remove the Veth, simply execute ifconfig with the down option for the device:
ifconfig eth1:0 down
The second method is to use iproute2, a tremendously powerful tool set used to administer many advanced IP routing features in the kernel. Since its power is its great flexibility, and with great flexibility comes great complexity ... however, it has particular advantages for managing Veth.
To {create or delete} a Veth using the ip command:
ip addr {add | del} 192.168.1.28 dev eth1
To see all IP addresses that are assigned to an interface:
ip addr show dev eth1
Leave off dev ethN to get the information for all interfaces on the system.
This alone makes it worth installing,
it is not possible to do this with ifconfig.
Changes made as we did here will be lost when the machine is rebooted. Add the commands to the network up and down script /etc/rc.d/rc.inet1 or to /etc/rc.d/rc.local when you are satisfied with the outcomes of your experiments.