How to know the network name
Ralf Mardorf
kde.lists at yahoo.com
Sun Oct 24 11:58:52 UTC 2021
Hi,
this is a reply to several posts of this thread.
On Sun, 24 Oct 2021 09:55:56 +0100, Colin Law wrote:
>On Sat, 23 Oct 2021 at 22:26, Jerry Geis <jerry.geis at gmail.com> wrote:
>> ...
>> Thanks - is there a command that spits out these names on a system ?
>>
>
>For eth0 you can predict the new name using
>sudo udevadm test /sys/class/net/eth0 2>/dev/null |grep ID_NET_NAME_
In a script I'm using
basename $(ls -d /sys/class/net/enp?s0)
An example from a script I'm using with Arch Linux and Ubuntu:
dhcpcd $(basename $(ls -d /sys/class/net/enp?s0))
This works perfect, if the hardware has just a single device.
Almost all of the times on my machine the one and only device becomes
enp3s0, hence and older scrip doesn't use this workaround.
From my older script:
ip link set enp3s0 up
However, you can't rely on systemd (udev belongs to systemd), so very
seldom the ? of the workaround is for another single figure.
Btw. if you aren't familiar with systemd yet, don't waste too much time
with learning, since I'm quite sure it will get replaced with something
else by major distros soon or later. While nobody nowadays is wining
anymore, more and more users migrate away from systemd. Note, I'm
perfectly fine with systemd, so I don't make any moves to another init
system. It's just an observation.
Too funny, a strategy to handle the "predictable" new names:
"To find out what names udev would be choosing between if you switched
over to the new system, first get a list of the network devices the
system knows about:
echo /sys/class/net/*
For each device path (other than /sys/class/net/lo), ask udevadm what
NET_IDs it knows:
udevadm test-builtin net_id /sys/class/net/enp0s1 2>/dev/null" -
https://wiki.debian.org/NetworkInterfaceNames#THE_.22PREDICTABLE_NAMES.22_SCHEME
On Sun, 24 Oct 2021 19:34:32 +1100, Karl Auer wrote:
>If you have just dropped your system off the 'net due to an error while
>renaming your interfaces, it is extremely unlikely either that anyone
>will get the wall message, that you or anyone will want to wait before
>rebooting, or that anybody can log in.
FACK
On Sat, 23 Oct 2021 21:33:40 +0100, Ian Bruntlett wrote:
>Have you considered booting your CentOS system with a live Ubuntu media
>(DVD/USB memory stick) and finding this out at the Ubuntu command line?
Even if the OP should have physical access to the server, it's not
granted that those numbers are "predictable". I don't know what makes
the numbers inconsistent. Maybe it happened after inserting or removing
a PCI audio card or something else, maybe it happened completely
randomly.
My Linux multi-boot PC https://i.imgur.com/Hvc088P.jpg most of the
times gets enp3s0, but very seldom another number. In the past all my
PCs with a single hardware device got eth0, this was consistent, 100%
reliable.
Btw. relatively often systemd suffers from race conditions. Not too
often, but also not that seldom. Rebooting into a systemd environment
without physical access or any other emergency measures is asking for
trouble. I sometimes need to manually enable network access after
startup. Alternatively I can reboot.
Regards,
Ralf
More information about the ubuntu-users
mailing list