[systemd-devel] Antw: Re: [systemd‑devel] [EXT] Finding network interface name in different distro
Ulrich Windl
Ulrich.Windl at rz.uni-regensburg.de
Wed Oct 19 09:05:38 UTC 2022
>>> Brian Reichert <reichert at numachi.com> schrieb am 18.10.2022 um 19:39 in
Nachricht <20221018173901.GA5754 at numachi.com>:
>> > <CAOdf3goQ5+TNf7mTKCix_59AboWeoQWzpGfuWasJhtpr+ZmOwg at mail.gmail.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
real 0m0.001s
user 0m0.001s
sys 0m0.000s
# time egrep -v -e "lo:" /proc/net/dev | grep ':' | cut -d: -f1
em1
em2
bond1
p4p1
bond0
p4p2
real 0m0.002s
user 0m0.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 <reichert at numachi.com>
> BSD admin/developer at large
More information about the systemd-devel
mailing list