How to determine "Predictable Name" of network interface

Solution 1:

Details of the naming scheme are in the source code: udev/udev-builtin-net_id.c. Previously, this had a nice readable comment block explaining things, but since a refactor removed that a better reference is at man systemd.net-naming-scheme.

Some common schemes are PCI physical, PCI hotplug, and onboard. Your enp interface suggests physical.

Stripping out exotic and irrelevant bits from the comments leaves these rules:

 * Two character prefixes based on the type of interface:
 *   en — Ethernet
 *
 * Type of names:
 *   [P<domain>]p<bus>s<slot>[f<function>][n<phys_port_name>|d<dev_port>]
 *                                         — PCI geographical location
 *
 * All multi-function PCI devices will carry the [f<function>] number in the
 * device name, including the function 0 device.
 *
 *
 * When using PCI geography, The PCI domain is only prepended when it is not 0.

That PCI bus name is formatted as domain:bus:slot.function.

Assuming it is not a multifunction device, pci@0000:41:00.0 appears as enp65s0, since hex 41 converts to decimal 65.

Solution 2:

There are some (new) possibilities to find the predictable network interface name directly. You can use udevadm info for this. Additionally you get some more info, which might be useful.

The command can export it as key-value pairs for easy use in scripts. See ID_NET_NAME in this example:

# udevadm info --export --query=property --path=/sys/class/net/eth0
DEVPATH='/devices/pci0000:00/0000:00:0d.0/0000:02:00.0/net/eth0'
INTERFACE='eth0'
IFINDEX='2'
SUBSYSTEM='net'
USEC_INITIALIZED='3750679'
ID_NET_NAME_MAC='enx0012345678'
ID_OUI_FROM_DATABASE='Super Micro Computer, Inc.'
ID_NET_NAME_PATH='enp2s0f0'
ID_BUS='pci'
ID_VENDOR_ID='0x8086'
ID_MODEL_ID='0x10c9'
ID_PCI_CLASS_FROM_DATABASE='Network controller'
ID_PCI_SUBCLASS_FROM_DATABASE='Ethernet controller'
ID_VENDOR_FROM_DATABASE='Intel Corporation'
ID_MODEL_FROM_DATABASE='82576 Gigabit Network Connection'
ID_PATH='pci-0000:02:00.0'
ID_PATH_TAG='pci-0000_02_00_0'
ID_NET_DRIVER='igb'
ID_NET_LINK_FILE='/lib/systemd/network/99-default.link'
ID_NET_NAME='enp2s0f0'
SYSTEMD_ALIAS='/sys/subsystem/net/devices/eth0'
TAGS=':systemd:'

Reminder: This example is for interfaces which still have the name "eth[0-9]". Otherwise the predictable name is the interface name.