Goodbye, ifrename

從 udev 0.090-1 開始,預設會在 /etc/udev/rules.d 產生 z45_persistent-net-generator.rules 這個檔案,裡面是關於 net interfaces 的命名。

以前總是因為 eth1, eth2 每次開機都不一樣而需要用 ifrename, nameif 等工具來固定住它們。現在自動在 z45_persistent-net-generator.rules 產生一行

# PCI device 8086:4220 (ipw2200)
ACTION=="add", SUBSYSTEM=="net", SYSFS{address}=="00:0e:35:49:99:57", NAME="eth2"

就解決了,在也不需要 ifrename 或是 nameif。

引用 README.Debian

Network Interfaces

After receiving events about network interfaces, net.agent will call ifupdown using the –allow=hotplug option. This makes the program act only on interfaces marked with the “allow-hotplug” statement. E.g: “allow-hotplug eth0” instead of the usual “auto eth0”. The loopback interface must always be configured with “auto lo”.

The persistent names of network interfaces by default are automatically written to /etc/udev/rules.d/z25_persistent-net.rules . Users can add their own rules there or at any other place before z45. Generation of rules for persistent names can be disabled by removing the z45_persistent-net-generator.rules symlink.

Beware: programs which rename network interfaces like ifrename and nameif will let udev relay events for the old names and should not be used.