Wednesday, January 2, 2013

Linux Rename Eth0/Eth1 Network Interface Card Name [ Udev ]


We can use udev to change these settings.

Step #1: Find out the MAC address of the Ethernet device

Type the following command:
# ifconfig -a | grep -i --color hwaddr

Sample outputs:

#ifconfig -a | grep -i --color hwaddr
eth1      Link encap:Ethernet  HWaddr 00:0C:29:CD:5A:7F 
virbr0    Link encap:Ethernet  HWaddr 52:54:00:7F:E6:58 
virbr0-nic Link encap:Ethernet  HWaddr 52:54:00:7F:E6:58 

Note down the MAC address.

Step #2: Rename eth0 as wan0

To rename eth0 as wan0, edit a file called 70-persistent-net.rules in /etc/udev/rules.d/ directory, enter:
# vi /etc/udev/rules.d/70-persistent-net.rules

The names of the Ethernet devices are listed in this file as follows:

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


Locate and identify the line with the NIC from step 1 (look for the MAC address). It may look like above. In this example, the interface eth1 will be renamed to wan0 (change NAME="eth1" to NAME="wan0"):


# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:cd:5a:7f", ATTR{type}=="1", KERNEL=="eth*", NAME
="wan0"

Save and close the file. Reboot the system to test changes:
# reboot

Verify new settings:
# ifconfig -a
# ifconfig wan0

No comments:

Post a Comment