[systemd-devel] Antw: Re: [systemd‑devel] [EXT] Finding network interface name in different distro
>>> Brian Reichert schrieb am 18.10.2022 um 19:39 in Nachricht <20221018173901.ga5...@numachi.com>: >> > : >> > > 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. > > This doesn't answer the OP's question, but my trick for enumerating > network devices was to use something like: > > egrep ‑v ‑e "lo:" /proc/net/dev | grep ':' | cut ‑d: ‑f Trying your command here I get an error ("cut: option requires an argument -- 'f'"). I also tried an awk-variant that even seems to perform faster: # time awk '$1 ~ /:$/ { sub(":", "", $1); if ($1 != "lo") print $1 }' /proc/net/dev em1 em2 bond1 p4p1 bond0 p4p2 real0m0.001s user0m0.001s sys 0m0.000s # time egrep -v -e "lo:" /proc/net/dev | grep ':' | cut -d: -f1 em1 em2 bond1 p4p1 bond0 p4p2 real0m0.002s user0m0.002s sys 0m0.002s > > to get a list of non‑loopback interfaces. > > In my case, I went on to bury everything under a single bond0 > interface, so a) no software had to guess a NIC name, and b) in the > case of physical cabling, they would all Just Work. > > This was work done in my kickstart file, and worked through many > releases of Red Hat and CentOS. > > I adopted this tactic as Dell kept switching up how they would > probe/name devices... > > ‑‑ > Brian Reichert > BSD admin/developer at large
Re: [systemd-devel] [EXT] Finding network interface name in different distro
> > : > > > 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. This doesn't answer the OP's question, but my trick for enumerating network devices was to use something like: egrep -v -e "lo:" /proc/net/dev | grep ':' | cut -d: -f to get a list of non-loopback interfaces. In my case, I went on to bury everything under a single bond0 interface, so a) no software had to guess a NIC name, and b) in the case of physical cabling, they would all Just Work. This was work done in my kickstart file, and worked through many releases of Red Hat and CentOS. I adopted this tactic as Dell kept switching up how they would probe/name devices... -- Brian Reichert BSD admin/developer at large
Re: [systemd-devel] [EXT] Finding network interface name in different distro
Le mar. 18 oct. 2022 à 10:04, Ulrich Windl a écrit : > > >>> Etienne Champetier schrieb am 15.10.2022 um > 02:41 in Nachricht > : > > 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. > > Wasn't the idea of "BIOS device name" that the interface's name matches the > label printed on the chassis? Some HPE Gen10 servers have the first port as eno5, on some recent Dell servers the first port is eno8303. I would love to use eno1 everywhere, but it's a mess. > > 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 ? > > > > Thanks > > Etienne > > > >