A few days ago, a colleague asked me how I configure my network configuration for the respective workstations (home, Scheertower, wifi) because he finds it quite complicated to do something simple like that under Linux.

When I told him udev and systemd-networkd the confusion was complete. How is that supposed to work? he currently uses Networkmanager.

The Trick

Using udev rules, I can rename the network cards depending on the reported mac-address which must be different depending on the docking station connected. Some of you should now realize why I don't need anything other than udev and systemd-networkd that is already there.

I have defined the following 2 rules in /etc/udev/rules.d/10-network.rules mac-addresses randomized for security reasons

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="02:fa:1b:80:c3:a5", NAME="eth2", DRIVERS=="?*"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="04:46:08:a6:12:00", NAME="eth0", DRIVERS=="?*"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="00:2a:a5:5d:2c:b2", NAME="wlan0"

Lines 1 and 2 name the network card of the connected docking station according to eth2or eth0

systemd-networkd has a configuration for the respective, then existing network card in /etc/systemd/network/

RWill_2024-10-16%2016-12-15

the eth2.network file looks like this:

[Match]
Name=eth2

[Network]
DHCP=ipv4
DNS=192.168.0.1
Domains=local

Since udev renames the network card according to its mac-address, systemd-networkd sets the necessary settings accordingly. With this trick, no further services are required for the network configuration. Newer Versions of systemd-networkd understanding the MACAddress= Parameter in the Match Section so then a renaming is not necessary anymore but useful for Firewalls,VLAN and so on. The solution shown is also super-fast!

th-39118152

for Wifi Connections i use iwd Daemon which works pretty well.

Previous Post Next Post