[systemd-devel] Finding network interface name in different distro

Lennart Poettering lennart at poettering.net
Wed Oct 19 10:18:48 UTC 2022


On Di, 18.10.22 11:10, Etienne Champetier (champetier.etienne at gmail.com) wrote:

> > > I think I found what I need:
> > > bash-4.4# udevadm test /sys/class/net/em1 2>/dev/null | awk  -F=
> > > '/ID_NET_NAME=/ {print $2}'
> > > eno1
> >
> > The name depends on local and distro policy, systemd version,
> > kernel version and selected network naming scheme level (see
> > systemd.net-naming-scheme man page)
>
> When running in a chroot of the new system, only the kernel varies,
> we have the right policy, naming scheme level and systemd version.
> For "classic" amd64 servers does the kernel really have an impact on
> naming ?

As kernels are improved and developed they tend to expose more sysfs
attributes on devices, that the udev interface naming logic might pick
up then.

> > Use "udevadm info /sys/class/net/<iface>" to query the udev db for
> > automatically generated names.
> >
> > Relevant udev props to look out for are:
> >
> > ID_NET_NAME_FROM_DATABASE
> > ID_NET_NAME_ONBOARD
> > ID_NET_NAME_SLOT
> > ID_NET_NAME_PATH
> > ID_NET_NAME_MAC
> >
> > These using hwdb info, firmware info, slot info, device path info or
> > MAC addresss for naming.
>
> What I'm looking for is I think ID_NET_NAME,
> ie I don't want to read the policy myself and then go find the right
> ID_NET_NAME_*
> sadly ID_NET_NAME is not always present, so I don't have a good
> solution for now.
> (I'm assuming policy kernel can be ignored on amd64 servers, maybe
> I'm wrong)

udev will rename interfaces it finds based on the data in
ID_NET_NAME. I the ID_NET_NAME prop is never set, then udev won't
rename the interface.

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list