Mirror physical interface to virtual interface

Kernels & Hardware, configuring network, installing services

Mirror physical interface to virtual interface

Postby Talkabout » 2020-02-02 13:03

Hi guys,

I have a networking issue and hope that somebody is able to help.

Following situation:

Existing interfaces:

eth0 => physical interface
eth0.30 => virtual interface (vlan 30)
eth0.50 => virtual interface (vlan 50)
eth0.100 => virtual interface (vlan 100)

I want to run a tool that connects to network interfaces on the "raw" level but does not handle vlan tagging correctly (KEA DHCP server). That means if I bind it to all interfaces, tagged traffic will arrive at interface eth0.x AND eth0. By removing "eth0" from the list of bound interfaces everything works as expected, but I need it also to listen to eth0.

My idea now is to create a virtual interface that basically mirrors traffic of eth0 and can be used by the tool. Because on kernel level the tagged traffic will be correctly forwarded to the tagged interface and thus only reaches the new interface if the traffic is untagged (in theory).

After several unsuccessful tries with bridging I am now at a point where I need some help.

Following questions:

1. is my idea about the virtual interface a possible solution or is there something better?
2. how do I configure my network interfaces correctly to work the way I need it to (with systemd-networkd)?
3. what other things do I need to consider?

If possible I would like to avoid changes in my network infrastructure!

Thanks for everybody trying to help!

Bye
Talkabout
 
Posts: 5
Joined: 2019-06-23 09:40

Re: Mirror physical interface to virtual interface

Postby Talkabout » 2020-02-03 16:46

Hi all,

for anybody who might have a similar issue, I was able to solve mine in the following way:

- Create a macvlan device via systemd-networkd:

eth1.netdev
Code: Select all
[NetDev]
Name=eth1
Kind=macvlan
MACAddress=xx:xx:xx:xx:xx:xx (generate a unique mac address and put it here)

[MACVLAN]
Mode=bridge


eth1.network
Code: Select all
[Match]
Name=eth1

[Network]
Address=192.168.xx.xx/24 (put a valid ip from your subnet for all 3 values)
Gateway=192.168.xx.x
DNS=192.168.xx.xx
IPForward=yes


- on the physical device definition you need to define that it belongs to the created mac vlan:
Code: Select all
[Match]
Name=eth0 (your physical device)

[Network]
... (keep previous values)
MACVLAN=eth1
...


When now systemd-networkd gets restarted, eth1 device is considered a separate network interface with a valid hardware address and ip. Now creating a "raw" bind on that device does not interfere with the vlan any more.

Hope that helps!

Bye
Talkabout
 
Posts: 5
Joined: 2019-06-23 09:40


Return to System configuration

Who is online

Users browsing this forum: No registered users and 15 guests

fashionable