udev rename predictable network interface names

I tried to rename an ethernet interface name with the following udev rule in config.json

“os”: {
“udevRules”: {
“70”: “SUBSYSTEM==\“net\”, ACTION==\“add\”, DRIVERS==\”?*\“, ATTR{dev_id}==\“0x0\”, ATTR{type}==\“1\”, KERNEL==\“enp6s0\”, NAME=\“eth_cam2\”\n”
}
}
This doesn’t work somehow. I also tried it with ATTR{address} and the MAC address, but that doesn’t work either. On ubuntu this rule works as expected.

hello there,

what devic type and os version are you using?

Hi!
balenaOS 2.108.19
genericx86-64 device

Hey there, have you tried removing the dev_id and DRIVERS filters from your rules to see if it gets a match? You could also try increasing the base number to 85 or similar so it runs a little later in the udev rules.

With the existing rule did you verify that /etc/udev/rules.d/70.rules is created on the host and appears to be formatted correctly as per the docs?

You can also run udevadm control --reload-rules and udevadm test /sys/class/net/enp6s0 to see if your rule would have run.

I removed dev_id and DRIVERS, but it does not work either. Here is the output:

enp3s0: /etc/udev/rules.d/99.rules:1 NAME 'eth_cam2'
enp3s0: Network interface 'enp3s0' is already up, refusing to rename to 'eth_cam2'

For this output did you change your rule to 99? What was the output when the rule was 70? or 80?

It seems like we need to run your rule before network interfaces are brought up so 99 must be too late.

Always the same. Refusing to rename interface.