Re: Finding network interface name in different distro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le dim. 16 oct. 2022 à 08:32, Lennart Poettering
<lennart@xxxxxxxxxxxxxx> a écrit :
>
> On Fr, 14.10.22 22:24, Etienne Champetier (champetier.etienne@xxxxxxxxx) wrote:
>
> > Le ven. 14 oct. 2022 ą 20:41, Etienne Champetier
> > <champetier.etienne@xxxxxxxxx> a écrit :
> > >
> > > Hi All,
> > >
> > > When changing distro or distro major versions, network interfaces'
> > > names sometimes change.
> > > For example on some Dell server running CentOS 7 the interface is
> > > named em1 and running Alma 8 it's eno1.
> > >
> > > I'm looking for a way to find the new interface name in advance
> > > without booting the new OS.
> > > One way I found is to unpack the initramfs, mount bind /sys, chroot,
> > > and then run
> > > udevadm test-builtin net_id /sys/class/net/INTF
> > > Problem is that it doesn't give me right away the name according to
> > > the NamePolicy in 99-default.link
> > >
> > > Is there a command to get the future name right away ?
> >
> > 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 ?
or is it more for other arch with device tree ?

> 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)

I just found someone with similar needs
https://github.com/systemd/systemd/issues/23661

Etienne

>
> Lennart
>
> --
> Lennart Poettering, Berlin




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux