Reassign the name of network interface in Linux

Hello folks,

Sometimes, it creates problem, when you add a new Ethernet interface to your system/Virtual Machine, the name assigned to interface is something else not eth0/eth1 (in case of its your second interface). Actually, it depends on the Linux distribution, what name will be given to your newly added interface. For example, on one distro Intel Giga bit Ethernet card might be detected as eth0 and Broadcom card as eth1 while with another distro this might be reversed. This causes a lot of problem, when one uses automated scripts which hardcoded “eth0” and “eth1”.

One can choose “ip” command to make the changes temporarily. But to make the changes permanently it needs to be changed in udev. udev is a daemon which dynamically creates and removes device nodes from /dev/, handles hotplug events and loads drivers at boot time. First you have to check whether your distribution is using udev daemon or not.

Installing of udev

To install udev in Fedora or Red Hat Enterprise Linux, you can use Yum (Yellowdog Update Manager).

$ yum search udev 
libudev.ix86 : Dynamic library to access udev device information

Note that you must be the root/administrator to install the package. To install this package in Red Hat/Fedora Linux.

$ yum install libudev.i686

You can check the details of this package udev.

$ yum info libudev.i686

Changing the name of interface

Open the terminal and type the following command:

$sudo vim /etc/udev/rules.d/70-persistent-net.rules

Depending on the distribution, the name of network interface rule file may differ. In this file you will find the list of n/w adapters and their names. Change the field NAME=”eth0″ to NAME=”eth1″ or vice versa. Remember to rename the other adapter whose name you have borrowed. Restart the system and you will find the new names interchanged!

Advertisements

About bijolianabhi

Graduate from Engineering College Bikaner, India in 2010 and working as Open Source activist. I love programming and implementing interesting ideas. I have interest in Mozilla Firefox extension development. I am currently learning basics of python to develop some interesting applications.
This entry was posted in FOSS/GNU, Tutorials and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s