Is it possible to create a virtual/clone interface to map to another existing interface ?
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is it possible to create a virtual/clone interface to map to another existing interface ?
Hello,
I would like to define a network interface, called "specific-network" for example, that corresponds to a real interface (like eth2) or a bonding (called bond0, that uses eth0 and eth1).
My idea is to use this virtual interface in an application's configuration, in order to be able to change the network interface that is really used (eth2 or bond0) without modifying application's configuration (the modification will be made in the OS configuration). My application uses ethernet frames, this is why I need configure the network interface to use.
To precise my need, I have a network, my host, and a specific equipment (communicating with protocol based on ethernet) which is only communicating with an application on my host. Because of the ethernet based protocol, my application need to know the device to use.
I would like my application to run in 2 differents cases with the same configuration :
- case 1 : my specific equipment is connected to the network, so my application must use bond0 (my host is connected to the network with a bonding),
- case 2 : my specific equipment is connected to my host, so my application must use eth2.
My idea is to create a virtual device to use in my application's configuration, and configure this virtual device as myNetwork=bond0 for case 1, or myNetwork=eth2 for case 2.
Why have you dismissed aliasing. We use it this way: The email server is at IP address 192.168.0.26, the web server is at IP address 192.168.0.27, the ssh server is at IP address 192.168.0.28, the dns server is at IP address 192.168.0.29.
There is only one NIC. All those addresses are "aliased" on that NIC.
One cannot get a web connection on 28 or a ssh connection on 26 or 27.
My problem is not related to IP address : my host has one IP address and it's fine, so aliases don't helps me.
I want to use a unique interface name (let's say "specific-network") to access my ethernet equipment, whether this equipment is connected to the network or directly to my host.
Interesting concept I didn't know !
I found this article to know what it is. I have to dig into it to see what I could use (it mentions virtual ethernet device, that could feeds my need).
Thanks !
After reading the previous article, I searched for documentation on interface types and I found this page that gives an overview of the different interface types. Very instructive !!!
I made tests with a MACVLAN link in passthru mode, that I can build over eth2 or bond0, and it works fine :-).
I also found this code that allow me to use ifcfg-xxx files to create my MACVLAN link at boot.
I only get a side effect : the IP address initially affected to bond0 is no more usable when I create the MACVLAN link over bond0 (I suppose it's due to the passthru mode). So in this case I have to set the IP address on my MACVLAN link, and that's OK.
I did a test with the bridge mode of MACVLAN link, and my application that uses ethernet protocol didn't work, so I suppose my application needs to use the promiscuous mode on my new device (and I guess that the passthru mode permits promiscuous mode, opposed to the bridge mode which doesn't).
I also tried to create a new bond over eth2 and bond0, but I found that bond over bond is not supported by Linux. What a pity ! A bond with primary device eth2 would have been perfect : it would have used eth2 if the NIC is plugged, or bond0 in the other case.
So I've got a solution, but if I could let my IP address affected to bond0 it would be almost perfect. Do you have idea about it ?
Otherwise I will mark the post as resolved in few days.
Right, my bonding is over eth0 and eth1.
My config of eth0 and eth1 don't mention bridge or router mode. Here is the content of ifcfg-eth0 (my real bonding name is netdev-bond0, even if I called it bond0 in this thread) :
I can set IP address on netdev-bond0 and it works until I add my MACVLAN link over netdev-bond0 (I tested with a ping to the gateway).
My IP address is visible with ifconfig, but not working.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.