Need to change the name of ethernet interface then make a bridge

funkpunkt

New Member
Joined
Mar 28, 2025
Messages
6
Reaction score
1
Credits
55
So I have two USB ethernet devices connected to RPI CM5, SMSC 9500 and SMSC9512.
They are assigned the name eth1 and eth2 from the kernel, but I want to change this to usb1 and usb2, while I want to make a bridge with the name of eth1.

I have put this udev rule to change the names

Code:
ACTION=="add", SUBSYSTEM=="net", ATTR{type}=="1", DEVPATH=="*/usb*", NAME="usb%n"

It is able to change the names, but the problem that keeps happening is that eth1 and eth2 are not getting configured automatically but only after we are fully boot and we run systemctl restart systemd-networkd then they get the configurations.

Code:
root@CM5:~# networkctl
IDX LINK  TYPE     OPERATIONAL SETUP
  1 lo    loopback carrier     unmanaged
  2 eth0  ether    routable    configured
  3 wlan0 wlan     no-carrier  configured
  4 usb1  ether    off         configuring
  5 usb2  ether    off         configuring
  6 eth1  bridge   no-carrier  configured

When I restart the networkd, it gets configured:

Code:
root@CM5:~# systemctl restart systemd-networkd
[ 2841.291149] eth1: port 1(usb2) entered blocking state
[ 2841.296228] eth1: port 1(usb2) entered disabled state
[ 2841.301291] smsc95xx 5-1.2:1.0 usb2: entered allmulticast mode
root@CM5:~# [ 2841.307210] smsc95xx 5-1.2:1.0 usb2: entered promiscuous mode
[ 2841.314754] audit: type=1700 audit(1651170583.579:6): dev=usb2 prom=256 old_prom=0 auid=4294967295 uid=993 gid=990 ses=4294967295
[ 2841.315226] eth1: port 2(usb1) entered blocking state
[ 2841.326406] audit: type=1300 audit(1651170583.579:6): arch=c00000b7 syscall=206 success=yes exit=40 a0=3 a1=555573a53e70 a2=28 a3=0 items=0 ppid=1 pid=11749 auid=4294967295 uid=993 gid=990 euid=993 suid=993 fsuid=993 egid=990 sgid=990 fsgid=990 tty=(none) ses=4294967295 comm="systemd-network" exe="/lib/systemd/systemd-networkd" key=(null)
[ 2841.331484] eth1: port 2(usb1) entered disabled state
[ 2841.361408] audit: type=1327 audit(1651170583.579:6): proctitle="/lib/systemd/systemd-networkd"
[ 2841.375159] smsc95xx 5-1.1:1.0 usb1: entered allmulticast mode
[ 2841.381043] smsc95xx 5-1.1:1.0 usb1: entered promiscuous mode
[ 2841.386806] audit: type=1700 audit(1651170583.603:7): dev=usb1 prom=256 old_prom=0 auid=4294967295 uid=993 gid=990 ses=4294967295
[ 2841.398456] audit: type=1300 audit(1651170583.603:7): arch=c00000b7 syscall=206 success=yes exit=40 a0=3 a1=555573a54530 a2=28 a3=0 items=0 ppid=1 pid=11749 auid=4294967295 uid=993 gid=990 euid=993 suid=993 fsuid=993 egid=990 sgid=990 fsgid=990 tty=(none) ses=4294967295 comm="systemd-network" exe="/lib/systemd/systemd-networkd" key=(null)
[ 2841.428425] audit: type=1327 audit(1651170583.603:7): proctitle="/lib/systemd/systemd-networkd"
[ 2841.473476] smsc95xx 5-1.2:1.0 usb2: Link is Up - 100Mbps/Full - flow control off
[ 2841.493618] smsc95xx 5-1.1:1.0 usb1: hardware isn't capable of remote wakeup
[ 2841.500824] eth1: port 1(usb2) entered blocking state
[ 2841.503739] smsc95xx 5-1.1:1.0 usb1: Link is Down
[ 2841.505880] eth1: port 1(usb2) entered forwarding state

root@CM5:~# networkctl
IDX LINK  TYPE     OPERATIONAL      SETUP
  1 lo    loopback carrier          unmanaged
  2 eth0  ether    routable         configured
  3 wlan0 wlan     no-carrier       configured
  4 usb1  ether    no-carrier       configured
  5 usb2  ether    enslaved         configured
  6 eth1  bridge   degraded-carrier configured

6 links listed.
root@CM5:~#

These are my network configuration files:

eth1-bridge.network


Code:
[Match]
Name=eth1

[Network]
Address=192.168.0.1/24
Address=192.168.11.2/24
Address=192.168.17.2/24

DHCPServer=true
ConfigureWithoutCarrier=true

[DHCPServer]
ServerAddress=192.168.11.2/24
PoolOffset=128
PoolSize=127


eth1-bridge.netdev

Code:
[NetDev]
Name=eth1
Kind=bridge


usb1

Code:
[Match]
Name=usb1

[Network]
Bridge=eth1

usb2
Code:
[Match]
Name=usb2

[Network]
Bridge=eth1

I cannot change the name of eth1 as it is already described in all our applications and it is a mess changing all those applications. I cannot do restart of systemd-networkd at start because then it breaks few of our applications which needs the eth1 to have pingable addresses.
 


Which distro is this?

Is networking service enabled?
Bash:
sudo systemctl status networking

If networking service is enabled it could be responsible.

Another possible reason is that udevadm rules are processed later than systemd-networkd unit does it's thing.

edit:
See section "CUSTOM SCHEMES USING .LINK FILES" below:

So the solution is to remove udev rules and use *.link files to name your NIC's
 
Last edited:
Which distro is this?

Is networking service enabled?
Bash:
sudo systemctl status networking

If networking service is enabled it could be responsible.

Another possible reason is that udevadm rules are processed later than systemd-networkd unit does it's thing.

This is a custom Yocto (Kirkstone) with Kernel 6.6.63-v8-16k. networking is not available in my distro.

Yes, udevadm rules are processed later, but is there any way that you can think of that can solve this issue for me? maybe delaying systemd-networkd till udevadm are applied? is it possible that USB initialization is taking more time?
 
Which distro is this?

Is networking service enabled?
Bash:
sudo systemctl status networking

If networking service is enabled it could be responsible.

Another possible reason is that udevadm rules are processed later than systemd-networkd unit does it's thing.

edit:
See section "CUSTOM SCHEMES USING .LINK FILES" below:

So the solution is to remove udev rules and use *.link files to name your NIC's

[Match]
Path=-usb-0:1.1:1.0
Type=ether


[Link]
Name=usb2
I have already done that, it was my first solution but it also do the same behavior.
 
yocto doesn't let you include networkManager in your image?
 
Last edited:
yocto doesn't let you include networkManager in your image?
It has networkmanager available but we do not want it as it is heavier than systemd-networkd and we are making this image for embedded Linux and we want to make it light.
 
It has networkmanager available but we do not want it as it is heavier than systemd-networkd and we are making this image for embedded Linux and we want to make it light.
Have you been able to configure *.link files?
*.link files are part of systemd and a standard way to manage NIC's with systemd-networkd.

Let us know if you need help.
 
Have you been able to configure *.link files?
*.link files are part of systemd and a standard way to manage NIC's with systemd-networkd.

Let us know if you need help.
Yes, I was able to configure .link file, as I have mentioned above. This is the example of what I had done. It works as expected but it also shows me the same problem. Which is that networking is stuck on configuring. In systemd-analyze plot, it shows that while usb1 and usb2 are running before systemd-networkd, the virtual network aka bridge is not running before systemd-networkd.

1743168465610.png

I have put the rules file in lib directory rather than etc directory so it is changing the names to usb1 and usb2 before systemd-networkd but somehow bridge is not getting configured.

[Match]
Path=-usb-0:1.1:1.0
Type=ether


[Link]
Name=usb2
 
@funkpunkt
*.link files are only one part of the complex, you also want to configure *.network files:

I've never done this for this use case, but systemd requires reading docs to configure things properly.
I have few sample configurations but not approriate to share because does not match your setup.
 
@funkpunkt
*.link files are only one part of the complex, you also want to configure *.network files:

I've never done this for this use case, but systemd requires reading docs to configure things properly.
I have few sample configurations but not approriate to share because does not match your setup.

As you can see from my first post, I have shared the network files, bridge files etc. I have setup the network file, rules files, and also .link files (which I have deleted afterwards because I am using udev now). I have read the documentation but I am not able to find the solution for my problem.
 
It has networkmanager available but we do not want it as it is heavier than systemd-networkd and we are making this image for embedded Linux and we want to make it light.

It's "slightly" heavier because it's more powerful and easily does what you are trying to accomplish.
In the meantime, you can try this.

Code:
/etc/udev/rules.d/70-persistent-net.rules

Code:
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="<MAC_ADDRESS_1>", NAME="usb1"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="<MAC_ADDRESS_2>", NAME="usb2"

Replace <MAC_ADDRESS_1> and <MAC_ADDRESS_2> with the actual MAC addresses of your SMSC 9500 and SMSC 9512 devices. You can find the MAC addresses using the ifconfig or ip a command.

Code:
sudo udevadm control --reload-rules
sudo udevadm trigger

I assume you have already added this to your yocto build, if not...
Code:
IMAGE_INSTALL_append = " bridge-utils"

Edit this file
Code:
/etc/systemd/network/bridge-br0.netdev

This will create a bridge named br0
Code:
[NetDev]
Name=br0
Kind=bridge

Next edit this file
Code:
/etc/systemd/network/br0.network

Code:
[Match]
Name=br0

[Network]
DHCP=yes

Edit these files.
Code:
 /etc/systemd/network/usb1.network
 /etc/systemd/network/usb2.network

Add this to both files
Code:
[Match]
Name=usb1

[Network]
Bridge=br0

Finally just restart
Code:
systemctl restart systemd-networkd

I could do all of this in two lines in nmcli.
 
Last edited:
It's "slightly" heavier because it's more powerful and easily does what you are trying to accomplish.
I find systemd-networkd very feature rich and it integrates better with system than NetworkManager.

In the end one is used for servers while other is used for workstations.
I have them both enabled for different purposes. NetworkManager for WiFi and systemd-networkd for virtual machines.
 
What do you find lacking? or what makes NetworkManager better in your opinion?

It does lack several things that NetworkManager has, but the bigger thing, is the ease of configuration.
For example...
NetworkManager can create and manage VPN connections, which is a feature not supported by systemd-networkd

However I agree, it uses more resources, and can be less secure in some cases.
 
Last edited:



Top