All Categories


How to Rename an Ethernet Device

Rename eth1 to eth0

For this guide we are renaming eth1 to eth0 on a centos 6.5 server.

 

STEP#1 Find what ethernet devices exist and their MAC addresses

 

Using the ip command:
[root@melbourne1 ~]# ip a | grep eth
 2: eth1:  mtu 1500 qdisc htb state UP qlen 1000
     link/ether 00:25:90:e0:2d:4a brd ff:ff:ff:ff:ff:ff
     inet 103.8.29.30/24 brd 103.8.29.255 scope global eth0
 3: eth2:  mtu 1500 qdisc mq state DOWN qlen 1000
     link/ether 00:25:90:e0:2d:4b brd ff:ff:ff:ff:ff:ff
[root@melbourne1 ~]#
From this we can see 2 ethernet devices and their MAC addresses:
eth1 = 00:25:90:e0:2d:4a
eth2 = 00:25:90:e0:2d:4b

 

STEP#2 Edit File: /etc/udev/rules.d/70-persistent-net.rules

 

Opening with an editor of your choice:
[root@melbourne1 ~]# 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:0x1521 (igb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:25:90:e0:2d:4a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x8086:0x1521 (igb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:25:90:e0:2d:4b", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
[root@melbourne1 ~]# 
In order to change the name of eth1 to eth0 you need to edit line:
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:25:90:e0:2d:4a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
Simply replace eth1 with eth0 - to look like this:
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:25:90:e0:2d:4a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
Then simply save and reboot your PC / server, that's it.



About the Author

Administrator

Most Viewed - All Categories