LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Is it possible to create a virtual/clone interface to map to another existing interface ? (https://www.linuxquestions.org/questions/linux-networking-3/is-it-possible-to-create-a-virtual-clone-interface-to-map-to-another-existing-interface-4175655859/)

Mac83 06-17-2019 03:51 AM

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.

I am running RHEL 6.8, and I didn't find any solution to achieve this (I've seen some redhat documentation on alias an clone interfaces, but this isn't exactly what I'm looking for).

Do you know if it's possible ? Does someone has an idea how to make this ?

(and sorry for my approximate english ;-) )

nini09 06-17-2019 03:31 PM

Does VLAN interface meet your requirement?

Mac83 06-18-2019 03:34 AM

I don't know, I will have a look at it.
Thanks

Mac83 06-18-2019 04:06 AM

Well, VLAN interface didn't fit my need.

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.

Is it more clear ? Do you have ideas ?

scasey 06-18-2019 08:07 AM

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.

Mac83 06-18-2019 09:19 AM

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.

nini09 06-19-2019 02:25 PM

You can try netns tool to build your private network over physical network.

Mac83 06-21-2019 10:37 AM

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 !

Mac83 06-25-2019 03:47 AM

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.

nini09 06-25-2019 02:35 PM

Is the bond0 in bridge or router mode?

Mac83 06-27-2019 07:27 AM

I don't understand your question. My bond0 is in active-backup mode, I don't see how it can be in bridge or router mode.

nini09 06-27-2019 02:14 PM

For example, if there are two interfaces, eth0 and eth1, in your system, bond0 include eth0 and eth1.
Are eth0 and eth1 in bridge or router mode?

Mac83 07-02-2019 04:50 AM

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) :
Code:

# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
USERCTL=no
BOOTPROTO=none
MASTER=netdev-bond0
SLAVE=yes
ONBOOT=yes


nini09 07-09-2019 02:44 PM

If no mention, it is in router mode. So now, we can go back your question. You can't set IP address on netdev-bond0, can you?

Mac83 07-16-2019 11:05 AM

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.


All times are GMT -5. The time now is 05:09 AM.