Friday, July 15, 2011

Rename eth devices in Ubuntu

Been swapping PC units recently (because of hardware failure) and noticed that it's kinda annoying trying to remember the new eth numbering everytime the hardware changes. Did a little research on how to rename the eth to a better name.

First open the config file using vim (my preferred editor or you may use your own)
# vim  /etc/udev/rules.d/70-persistent-net.rules

Then you should see a sample below
# PCI device 0x10de:0x03ef (forcedeth)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:24:1d:61:50:1f", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth20"
 I colored the sample text above green to indicate that it is the one that I wish to change. Note that if the old config lines are not to be used anymore feel free to delete them. Don't worry because upon reboot the system should auto-detect them again if the need arises.

Now the new name I like is displayed below...

# PCI device 0x10de:0x03ef (forcedeth)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:24:1d:61:50:1f", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="OptimusPrime"


Now I changed the /etc/network/interfaces to match the new name above.
auto OptimusPrime
iface OptimusPrime inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1

or if you like dhcp...

auto OptimusPrime
iface OptimusPrime inet dhcp


Reboot and hope it works!!! (just kidding)

No comments: