Unable to rename ethernet device to a specific name.

Hello.

Config :
leap_15.2 beta
laptop asus rog strix
test running on a virtualbox vm Version 6.1.8 r137981 (Qt5.9.7) but should be also use on real system.
Using NetworkManager

I want to change the interface name of the Ethernet card to a name of my choice.
I have written a script to do that but that failed.
I have read a lot of things on internet but nothing help me very much.

List of things I have tried :
1-)
Create a /etc/udev/rules.d/99-persistent-net.rules with :

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:27:8c:4d:4b:a4", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="my_name"

2-)
or as suggested by deano_ferrari in https://forums.opensuse.org/showthread.php/531093-Changing-the-Ethernet-card-name

ATTR{address}=="08:27:8c:4d:4b:a4", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="my_name"

Note : Assigning a name ‘eth0’ to a mac address works but not assigning ‘my_name’

3-)
as suggested by Sauerland in the same thread and reading
https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
and
https://www.freedesktop.org/software/systemd/man/systemd.link.html

I try a link like example 2 in /etc/systemd/network/10-my_name.link

[Match] MACAddress=08:27:8c:4d:4b:a4

[Link]
Name=my_name

4-)
or as suggested by deano_ferrari in https://forums.opensuse.org/showthread.php/528075-Predictable-device-names-vanished-returned-to-ethX-!
post #2 (concern leap 42.3)

/usr/lib/udev/write_net_rules -v -c my_name -n my_name -o /etc/udev/rules.d/70-persistent-net.rules

but got an error :

missing $INTERFACE

note :

During my test i have tried to remove any reference to eth0 by removing any config files ( /etc/sysconfig/network, /etc/NetworkManager, /etc/udev/rules.d/99-persistent-net.rules )
typing

nmcli con show

always return a reference to eth0

Any help is welcome.

I’m pretty sure you can’t actually specify a custom network interface name and certainly not for the network device… Too many system functions depend on the standard naming conventions which would be broken if the name changed.

But,
It’s possible to create a symbolic link (ie an alias but is not the same as “ip aliasing”) so you can refer to the interface by some custom name.
Note that if you do this, you should be able to use the custom name for your own purposes, but if you want to run common network utilities like ip tools, you’d still have to use the real names.
Since you don’t describe how you want to use this custom name, I can’t say if this will work but AFAIK it’s the only approximate solution to your post.

Although you can read the MAN page for ip-link,
Looks like the following top answer is very nice, the author extracted only what is essential to provide a distilled answer

https://unix.stackexchange.com/questions/391535/how-to-add-an-alternative-name-for-the-interface

HTH,
TSU

I am very surprise that any computer running any linux distro will fail into problem if an Ethernet card is named “my_lovely_card” rather than “eth0”
From my great ignorance the string naming a device has nothing to do with the device itself.

If all computer and/or network software are now based only on name ‘eth0’ or ‘wlan0’ then I can assure you that we will run into disaster.

That said I will read your link.
Thank you for your comments.

Works here (both with PCI address and MAC):

bor@10:~> ip l
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: my_net: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether de:ad:be:ef:01:03 brd ff:ff:ff:ff:ff:ff
bor@10:~> cat /etc/udev/rules.d/99-my-net.rules 
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="virtio-pci", ATTR{dev_id}=="0x0", KERNELS=="0000:00:03.0", ATTR{type}=="1", KERNEL=="eth*", NAME="my_net"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="virtio-pci", ATTR{dev_id}=="0x0", ATTR{address}=="52:54:00:12:34:56", ATTR{type}=="1", KERNEL=="eth*", NAME="my_net"
bor@10:~> 

When is driver for your ethernet controller loaded? If in initrd, you need to recreate initrd so it includes your rule.

“my_lovely_card” is at the limit of allowed name length so it will certainly be an issue if you try e.g. create VLAN on top of it.

I will try this quickly.

ps : “my_lovely_card” is just a wink.

Maybe renaming will work OK for someone,
But maybe you’re confusing what is a device, what is an interface and the names that can be associated with the device or interface?
Each are different, and are hooked into different parts of the system, some not easy to modify.

TSU

Recreating initrd do the job.

Great help

How to find this info ?

Looking at journald I found that the driver seems loaded by kernel.
But how to know if it is loaded by initrd mechanism ? or something else ?.

I have read opensuse doc “9 Introduction to the Boot Process” but that don’t help me.

Is your driver module or built into kernel?
If it is module - “lsinitrd /boot/initrd” - is your driver listed?

No and I have found nothing that look likes ‘e1000’ or ‘82540’

But lspci -v show :

00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
        Subsystem: Intel Corporation PRO/1000 MT Desktop Adapter
        Flags: bus master, 66MHz, medium devsel, latency 64, IRQ 19
        Memory at e8600000 (32-bit, non-prefetchable) [size=128]
        I/O ports at c1a0 [size=8]
        Capabilities: [dc] Power Management version 2
        Capabilities: [e4] PCI-X non-bridge device
        Kernel driver in use: e1000
        Kernel modules: e1000

Yast hardware graphical show the same

        Driver : e1000
                  Kernel Driver: e1000

[/size][/size]

Well, I actually do have it in initrd but still my rules worked without recreating initrd. So it probably depends on whether something keeps busy interface preventing renaming.