How does NetworkManager get external devices?

Using Debian 12.2 with KDE Plasma 5.27.5

Where does nmcli device acquire the information about the external devices docker0, virbr0 ?

# nmcli device console output
DEVICE   TYPE      STATE                   CONNECTION
eno1     ethernet  connected               Wired_eno1
lo       loopback  connected (externally)  lo
docker0  bridge    connected (externally)  docker0
virbr0   bridge    connected (externally)  virbr0
enp5s0   ethernet  unavailable             --

For completeness, the content of ` is:

cat `/etc/network/interfaces

# console output
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback


ls -l /etc/NetworkManager/system-connections/

# console output
-rw------- 1 root root 322 Nov 15 09:15 Forti_VPN
-rw------- 1 root root 210 Nov 14 21:48 Wired_eno1

Reading Get started with NetworkManager on Linux. I learn that NetworkManager uses the information from D-Bus to initialize each NIC

The udev daemon creates an entry for each network interface card (NIC) installed in the system in the network rules file. D-Bus signals the presence of a new network device—wired or wireless—to NetworkManager. NetworkManager then listens to the traffic on the D-Bus and responds by creating a configuration for this new device. Such a configuration is, by default, stored only in RAM and is not permanent. It must be created every time the computer is booted.

But where does udev get the info about the network devices, physical like eno1, enp5s0 or virtual like docker0, virbr0 ?

For the sake of learning, what are the manual steps or commands that I could run to query udev for info about the network devices discovered by NetworkManager?

Asked By: Polymerase

||

The kernel generates an udev event for the addition, change or removal of any device, including network devices. Since udev monitors these events, it will become aware of all network devices as soon as the applicable driver detects the hardware.

To query udev for network devices, you cannot use udevadm info -q all -n <device node>, because network devices don’t have device nodes. But you can query them by using the sysfs path:

udevadm info -q all -p /sys/class/net/<interface name>

or

udevadm info -q all -a -p /sys/class/net/<interface name>

The former command will tell you all the possible names for the network interface using the new Predictable Network Interface Names scheme, with the various ID_NET_NAME_* environment variables.

The latter command will list all udev attributes for the network interface device and all its parents (if applicable), which may be useful if you need to write a custom udev rule, e.g. to assign a name for a network interface based on some unusual attribute.

Answered By: telcoM
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.