Change “eth0” interface name and reload udev rules without a reboot

by | Jan 15, 2015 | ESXi

Its possible to change the interface name in Linux and reload without a reboot. It usually happens in Virtual environment where you add / remove interfaces frequently. You need to take note of the interfaces before you do any changes. Make sure that there are no active connections going to the NIC as you are going to restart the network service for the chagesz to take effect. Again you would not need a reboot.

First take note of the interface name and MAC Address.

# ifconfig

Output:

[root@smtp-proxy ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:65:32:B2 ----------------------> Changing this Interface name
          inet addr:172.16.70.5  Bcast:172.16.70.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe65:32b2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:47 errors:0 dropped:0 overruns:0 frame:0
          TX packets:44 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:5953 (5.8 KiB)  TX bytes:6319 (6.1 KiB)

Interface name = eth0

MAC Address = 00:0C:29:65:32:B2

First bring down the interface.

# ifdown eth0

*NOTE: You will loose all active connections for that Interface.

Now go ahead modify the persisitant network rules via udev module.

# vi /etc/udev/rules.d/70-persistent-net.rules

Check the address for the above MAC and then edit NAME for it. So over here changing “eth0” to “etho.test”

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:65:32:b2", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0.test"

Now edit “ifcfg-eth0” file and modify DEVICE name.

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0.test

Then rename “ifcfg-eth0” to “ifcfg-eth0.test”

# mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.test

Now reload the changes via udev

# udevadm control --reload-rules
# udevadm trigger --attr-match=subsystem=net

That should reload the and bring up the interface.

# ifconfig
[root@smtp-proxy ~]# ifconfig
eth0.test Link encap:Ethernet  HWaddr 00:0C:29:65:32:B2   ----------------------> New Interafce name i.e. "eth0.test"
          inet addr:172.16.70.5  Bcast:172.16.70.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe65:32b2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:337 errors:0 dropped:0 overruns:0 frame:0
          TX packets:125 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:34516 (33.7 KiB)  TX bytes:18292 (17.8 KiB)

If it doesn’t bring up the interface then run any of these commands

# ifup eth0.test

(OR)

# service network restart

If you encounter any errors during the process, let us know via Contact Us and will try our best to help.

Related Articles….