linux rhel udev – How to Rename a Network Interface Using Udev

linuxrheludev

I just installed RHEL 6.3 on a Dell 1950 server.
This server as two GBit ports, Gb0 and Gb1.

For some obscure reason, udev chose to name Gb0 eth1 and Gb1 eth0.
This is definitly not a good find for me and just gives confusion.

So I modified the configuration in /etc/udev/rules.d/70-persistent-net.rules:

# PCI device 0x14e4:0x164c (bnx2)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", \
  ATTR{address}=="00:20:19:52:d3:c0",           \
  ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x14e4:0x164c (bnx2)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", \
  ATTR{address}=="00:20:19:52:d3:be",           \
  ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

I just changed the "NAME" field on the file in order to reflect what I want.
I rebooted the server and it didn't worked.

In the dmesg log I can read the following :

udev: renamed network interface eth1 to rename5
udev: renamed network interface eth0 to eth1
udev: renamed network interface rename5 to eth0

Any idea on what is wrong here?
Why is udev switching like this? I have another similar server, where I do not have this issue.

Best Answer

While this is rather late, I fixed my issue by removing the

KERNEL="eth*",

part of the rule in /etc/udev/rules.d/70-persistent-net.rules file. This works because, once UDEV has renamed the device to "rename*", this part will stop the rule matching. So, removing it allows the correct name to be assigned to the correct device regardless of what UDEV has called it in the meantime.

Related Question