Praveen's Blog

An Eternal Quest for Incremental Improvement

Naming your network interfaces in linux using udev

Normally when people have more than one network interface on their PC or laptop and using linux, they may face a problem of network interface names eth0 and eth1 getting swapped betweeen the the interfaces on every reboot. The fact that which interface is getting what name is not predictable under normal scenario.

I also faced the same problem with my laptop that had two interfaces. One is the Marvell Yukon Gigabit ethernet adapter and the other one is the Intel Pro Wireless 2200. Each time of the boot, I will randomly get eth0 for Marvell Yukon and vice-versa. This makes it difficult to make interface name specific configurations.

As the modern 2.6.11+ kernels use 'udev' for loading the modules, the naming of the interfaces could be done by setting an udev rule. To achieve this, create a file /etc/udev/rules.d/010_netinterfaces.rules and add the following contents to it.

SUBSYSTEM=="net", SYSFS{address}=="MAC address of eth0", NAME="eth0"
SUBSYSTEM=="net", SYSFS{address}=="MAC address of wlan0", NAME="wlan0"

Please note that the MAC address should contain lower case alphabets for hexa-decimal digits a to f. Otherwise, this will not work properly.

You can name the interfaces as however you want and extend the above example to the your scenario.


Comments