StefanoA
Posts: 5
Joined: Tue Sep 10, 2019 2:09 pm

Ethernet virtual interface on raspian buster

Tue Sep 10, 2019 2:30 pm

Hi,
I need to create an ethernet virtual interface with raspian buster (..and the make it in a bridge with eth0)

i read a lot thread with differnet answers made me a bit confusing and without a solution :shock: :

I understand I have to use dhcpcd.conf and the interfaces file but the test I've done did'nt work.

the thread "Configuring virtual eth interfaces using dhcpcd.conf" help me to understand a little bit..

Could you help me please?

thanks

epoch1970
Posts: 3537
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Ethernet virtual interface on raspian buster

Tue Sep 10, 2019 4:23 pm

What kind of virtual ethernet interface do you need? veth?

You have 2 solutions:
  • The quick and dirty one, in /etc/rc.local, e.g.

    Code: Select all

    ip link add name br0 type bridge
    ip link add name veth0 type veth peer name veth1
    ip link set veth0 master br0
    ...
    ip link set br0 up
    
    or
  • The nice one, in /etc/systemd/network/ (documentation)
    - create a veth.netdev and a bridge.netdev file for the non-physical interfaces,
    - create .network files for each bridge member, e.g. eth0-br0.network, veth0-br0.network etc.
    You'll need to enable networkd ("systemctl enable systemd-networkd") to get your interfaces to be created at boot.
In both cases when dhcpcd sees an interface in "up" state it tries to give it an IP address. To block that behavior on bridge member interfaces, add e.g. "denyinterfaces eth0 veth0" to the beginning of the file.

Do not hesitate to reboot frequently during setup.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

StefanoA
Posts: 5
Joined: Tue Sep 10, 2019 2:09 pm

Re: Ethernet virtual interface on raspian buster

Wed Sep 11, 2019 6:45 am

thanks,
after i read your istruction I understood I was wrong: I don't need a virtual ethernet,
I need a simple alias of the eth0, with buster i'm having some problems to find a solution

epoch1970
Posts: 3537
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Ethernet virtual interface on raspian buster

Wed Sep 11, 2019 9:24 am

Do you mean a secondary IP address on one interface?
If it is static, try this: https://www.raspberrypi.org/forums/view ... 6&t=251092

If it is via DHCP, then the thread you started from is the right one. To get another DHCP address you have to trick the client into thinking there is one more interface to configure. DHCP relates with the MAC address of client interfaces. Macvlan is a kind of virtual interface that can be built from a physical interface, and has its own MAC address. Run a DHCP client on a macvlan interface and it will get an IP address (as long as the parent interface is connected)

Perhaps you can explain what you’re trying to do.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

StefanoA
Posts: 5
Joined: Tue Sep 10, 2019 2:09 pm

Re: Ethernet virtual interface on raspian buster

Wed Sep 11, 2019 12:44 pm

With Jessie I had
in /etc/networl/interfaces i had

Code: Select all

iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.5.255

face eth1 inet manual
auto br0
iface br0 inet dhcp
bridge_ports eth0 eth1
now, on buster I have to use /etc/dhcp.d but, till now, i wasn't be able to understand how to nuild tre fit

thanks

epoch1970
Posts: 3537
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Ethernet virtual interface on raspian buster

Wed Sep 11, 2019 1:20 pm

StefanoA wrote:
Wed Sep 11, 2019 12:44 pm
With Jessie I had
in /etc/networl/interfaces i had

Code: Select all

iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.5.255

face eth1 inet manual
auto br0
iface br0 inet dhcp
bridge_ports eth0 eth1
There is no trace of virtual ethernet interface in there... A bridge and 2 physical ethernet adapters.

On Buster do this to create the bridge and add the interfaces as bridge members:
  1. sudo nano /etc/systemd/network/bridge-br0.netdev

    Code: Select all

    [NetDev]
    Name=br0
    Kind=bridge
  2. sudo nano /etc/systemd/network/br0-members.network

    Code: Select all

    [NetDev]
    Name=eth0 eth1
    
    [Network]
    Bridge=br0
  3. sudo systemctl enable systemd-networkd
In /etc/dhcpcd.conf, add at the beginning of the file

Code: Select all

denyinterfaces eth0 eth1
This will give a DHCP address to br0.

(The config you pasted was wrong. Bridge member interfaces, eth0 namely, do not have an IP configuration. Only the bridge does.)
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

StefanoA
Posts: 5
Joined: Tue Sep 10, 2019 2:09 pm

Re: Ethernet virtual interface on raspian buster

Wed Sep 11, 2019 3:12 pm

Thaks you are very kind and sharp
I'm going to apply your istruction

Just 2 dubt:
I only have one physical eth0 Ethernet port and I need an alias eth"x" port to bridge with. Then i have a program that log some ethernet traffic thaks to the bridge.
1) I'm able to have the alias network writing the file /etc.../interfaces, but how I can configure dhcpcd.conf instead?
2) How I can test the bridge?

thanks

epoch1970
Posts: 3537
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Ethernet virtual interface on raspian buster

Wed Sep 11, 2019 3:44 pm

So you have a single interface. Fine, you still can bridge it, although the bridge is a bit useless then.

For the second interface, I simply do not understand what you're saying. The /etc/network/interfaces file you posted is not operational and further gives no hint at what the mysterious "eth1" might be.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

StefanoA
Posts: 5
Joined: Tue Sep 10, 2019 2:09 pm

Re: Ethernet virtual interface on raspian buster

Fri Sep 13, 2019 1:39 pm

Great! bridge is up.
I'm moving an old raspbian release configuration (done by someone else) to rasbian buster on a rasberry device

Now with the bridge configuration I have to assign a static Ip address to eth0

but setting on etc/network/interface it doesn't work, then
I tried left iface in etc/network/interface and configure dhcpcd.conf for a static IP but nothing

epoch1970
Posts: 3537
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Ethernet virtual interface on raspian buster

Fri Sep 13, 2019 1:43 pm

Configure IP addresses in dhcpd.conf only. Remove everything from the interfaces file.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Raspbian”