简体   繁体   中英

Linux: where does the kernel name the Network interface?

I am working on a troubleshooting of the Linux network interface naming.

Here I have some generic questions:

  1. If there are multiple NICs,they will be named as "eth0", "eth1", "eth2", etc. Which kernel code do the naming stuff?
  2. In some cases, the interfaces will be renamed , for example: mlx4_core 0002:00)02:0 enP2p0s2: renamed from eth2. Who triggered this renaming happen? Looks like it is netdev rename event, but who triggered that netdev event? (in this example, enP2p0s2 is the VF NIC interface name).
  3. In some cases, the interface will be renamed as " rename3 " for example. Why this would be happen? Caused by conflict MAC address? How do I prevent this renaming happening?

thanks!

Which kernel code do the naming stuff?

udev names interfaces.

Why this would be happen?

It depends on your system, but renames are governed by rules in /etc/udev/rules.d.

In some cases, the interface will be renamed as "rename3" for example. Why this would be happen? Caused by conflict MAC address? How do I prevent this renaming happening?

I can answer this part! Renaming to "rename3" is done by systemd-udevd when it wants to rename interface but the destination name is already taken. Funny enough, systemd purged the code that was doing renaming to temporary names in 2013! But the debian/ubuntu guys salvaged it and used it until 2019 — https://salsa.debian.org/systemd-team/systemd/commit/3d45a7af959cf260bffcb1ad0262973b5750ae36 . That is why you can see messages "renamed to rename3" even in ubuntu 18.04.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM