Monday, January 7, 2013

Want to know how and why Linux names its Ethernet adapters ?

I picked this up from a Raspberry Pi forum, whilst trying to get a USB wireless adapter to work with my Pi.

I cannot tell for certain why your device gets renamed from wlan0 to wlan1 but it might be worth looking into "/etc/udev/rules.d/70-persistent-net.rules". This file is created by udev to store the names of network interfaces and keep them consistent throughout the system. Udev should automatically put a comment before each rule, saying which driver is responsible for the interface.

I'd not looked into this before, but had wondered why, on one of my Red Hat Enterprise Linux VMs, the Ethernet card always comes up as eth4 rather than eth0.

When I checked the file: -

cat /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:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:87:e2:dc", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:07:2f:73", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:d1:94:31", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:60:44:f2", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:9c:4a:af", ATTR{type}=="1", KERNEL=="eth*", NAME="eth4"


I'm guessing that the MAC ( Media Access Control ) address has changed since I first spun up the VM, perhaps meaning that Linux has kindly created a new interface - eth4 - for the "new" MAC address.

I imagine that, if I wanted to change it back to eth0, I could simply "hack" this file, perhaps removing the first four entries, and renaming eth4 to eth0 on the one remaining line.

Still, it's good to know why it happens ….

No comments:

Post a Comment