One can set consistent interface naming via mac address by modifying /etc/udev/rules.d/70-persistent-net.rules
.
- Can you establish consistent interface naming by PCI slot number? (I tried but failed)
- Is there any other method to define consistent interface naming rather than MAC address?
I am using Ubuntu 14.04.
Modifying 70-persistent-net.rules
per pci slot did not work in the case I had a 4 port NIC plugged into the top most pci slot:
$ lspci -D | grep -i ether
0000:04:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
0000:04:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
0000:05:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
0000:05:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
0000:0b:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
0000:0c:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
This is the file I used: /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x8086:0x10d3 (e1000e)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="aa:bb:cc:dd:ee:ff", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x8086:0x10d3 (e1000e)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:aa:bb:cc:dd:ee", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", KERNELS="0000:04:00.0", NAME="eth2"
SUBSYSTEM=="net", ACTION=="add", KERNELS="0000:04:00.1", NAME="eth3"
SUBSYSTEM=="net", ACTION=="add", KERNELS="0000:05:00.0", NAME="eth4"
SUBSYSTEM=="net", ACTION=="add", KERNELS="0000:05:00.1", NAME="eth5"
Now if I plug in a two port NIC in the same slot:
0000:02:00.0 Ethernet controller: Intel Corporation 82580 Gigabit Fiber Network Connection (rev 01)
0000:02:00.1 Ethernet controller: Intel Corporation 82580 Gigabit Fiber Network Connection (rev 01)
0000:06:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
0000:07:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
You can see the PCI slot numbers changed.