问题原文
原帖链接 · pymkin · CC BY-SA 4.0
I am setting up a new server and installed Ubuntu Bionic, which uses Predictable Network Interface Names.
The installer is running on a rescue system, which still uses old interface names like eth0, eth1, but the newly installed system has configured the first network card as enp8s0.
Using lshw, the bus info for this card is:
bus info: pci@0000:08:00.0
I would like to set up the other network interfaces without booting into the newly installed system yet, but don't know how to determine the predictable network interface names for the other cards.
Using lshw, I found another network card, which is currently disabled:
bus info: pci@0000:41:00.0
Is it possible to determine the predictable network interface name from this? Would it be something like enp41s0?
I have searched for a while and could not find any tool which would simply list all the devices together with their predictable names.
Edit: Why do I not want to boot the new system to find out? Because this would add an extra step to the setup process. Using the old interface naming, I could run a script to set up the server from the rescue system provided by the hosting company and it was ready for use. Now I would have to set up the server minus the additional network config first. Then I have to set up networking manually once the new system has booted, just to know the names of the interfaces.
社区高分解答
原帖链接 · Marco · CC BY-SA 4.0
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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
