How do I create a Linux virtual network interface (alias) with a real interface name?

I want to create a Linux virtual network interface (normally labeled eth0:0) using a real network interface name like eth1.

To put it another way, can I have eth0 and eth1 have different IP addresses but use the same physical network interface?

Is it possible? How?

I have a legacy application which expects two physical network interfaces (eth0 and eth1) which I want to install on a platform which has only one physical network interface.


What you describe are not virtual interfaces, those are just a way (the legacy way, these days you use ip addr from iproute) to assign more than one ip-address to a single interface. Technically, eth0:0 is just eth0.


One solution is to install XEN on your host (or QEmu, or some other virtualization tool) and to setup a virtual machine with two network interfaces. Then install your software on this virtual machine.

Another option could be to setup 2 VLANs on eth0. Say you decide to use VLANs 100 and 101, then you could setup your legacy software to use eth0.100 and eth0.101. Be aware that your traffic would be tagged (802.1q) upon exiting your host, which might not be what you want. If your host is connected to a router, it could untag the packets do the proper routing.

If you don't care about one of the network interfaces that your application requires (say it needs it to send log data that you don't care about, for example), then just create 1 VLAN (eth0.100 for example) and point your software to eth0 (actual useful trafic, untagged) and eth0.100 (tagged and ignored).

If your application just needs multiple local IP addresses, then just create aliases, such as:

ifconfig eth0:0 192.168.99.5 netmask 255.255.255.0

It would probably be best if you could tell us more about exactly what it is you want to do.