6

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.

5
  • Why would you want to do something like this?
    – womble
    Nov 10, 2009 at 13:21
  • 3
    Looks like you have a strange idea of what are interface names and how they work. Please, state exactly why you need this, what is the original requirement, and we will be able to tell you the correct procedure to configure your system.
    – Juliano
    Nov 10, 2009 at 13:27
  • 2
    Your application is broken, fix it. Interface names should be completely transparent to applications. The application just sets its source address with bind() and the kernel decides which interface to use. I guess your legacy application is broken in other ways too.
    – Juliano
    Nov 10, 2009 at 13:31
  • @Juliano: you assume he has the time, knowledge and access to the code to be able to fix it. Apr 29, 2011 at 11:24
  • It seems you may be confusing 'virtual network interface' with VLAN - is this possible?
    – jackweirdy
    Sep 24, 2013 at 13:50

4 Answers 4

6

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.

1

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.

0

When you create NIC aliases you must use the alias syntax. An ethN name cannot be used for aliases. You have to stick to the ethN:M scheme.

I've used NIC aliases in order to use different IPs (even in the non-routable range) for services running on the same machine, but that's just one use case. Generally, it adds much flexibility in the deployment of the services. Regarding Red Hat systems, I recommend this virtual NIC howto, which describes how to make the changes permanent on those systems.

2
  • That document doesn't appear to describe how to configure two separate interface names on the same physical device.
    – womble
    Nov 10, 2009 at 14:36
  • I had initially read the Q very quickly and totally missed that he wanted to use the name of the NIC device in place of a NIC alias (ethN:M scheme). Like all the documents you can find on google about the matter, my recommendation describes what is possible and not what is not possible. Nov 10, 2009 at 15:27
-1

Set up virtual machine with two virtual network cards and connect both to the same VLAN.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .