How to Rename ethernet interface to eth0 in Linux

Today again i am going to discuss 1 more issue which i faced recently on Oracle Enterprise Linux – 6.3, may be there are many who could have faced this already.

So let me discuss about the problem first.

What’d caused the issue?
— I copied my VM Ware Machine- A from my current laptop to  different laptop and when i started it, my default eth0 was not coming up.
— So i decided to delete this from VM Ware Setting and add a new Adapter and i did the same and Started my Machine, i did not realize but i did this 2-3 times.
— So finally what i got this is my ethernet name was changed to eth3 though my configuration file which was ifcfg-eth0 before, was mistakenly deleted by me. Situation was like below:1

Even though i tried starting my Network but it was not coming up.

What i did to sort out my problem:

I created ifcfg-eth0 file manually, and the configuration file of eth0 was like the below:2

I again tried to restart my network and it started this time, however the ifconfig was still showing eth3, though configuration file eth0 was picked up.

3

Now, my motive was to change the name eth3 to eth0, for anyone it could be eth1 to eth0 or eth2-eth0, for me it was like eth3 to eth1.

Renaming your network interface to eth0:

Oracle Enterprise Linux, with many others, stores the network interface hardware configuration using udev. The network interface configuration is stored in the file /etc/udev/rules.d/70-persistent-net.rules. Open this file with editor (vim) and start editing. You’ll see configuration lines, like:4

As you can see, the system now has the configuration for four interfaces: eth0,eth1,eth2 and eth3. The eth0,eth1 and eth2 line contains the hardware (MAC) address of the old network card, the fourth line is the new one.  Because your network configuration scripts (where IP address settings are stored) are bound to a specific device (eth0) and the system doesn’t know about eth1, it can’t bring it up. To fix this, simply rename “eth3″ to “eth0″ in the NAME field, and remove or comment other lines.

7

Updating hardware MAC address in networking script:

Apart from the hardware configuration, there is also a networking configuration for the interface. This configuration is stored in /etc/sysconfig/network-scripts/ifcfg-eth0. In this file the IP address configuration is bound to the specific interface. This file most of the times also contains a specific hardware address, the MAC address of the interface the IP address should bind to. Look for the “HWADDR” line and update its value to the one you wrote down earlier from the udev configuration.

5

Reboot the system to update ethernet numbering.

Now check ifconfig and you will get what you expect.

6

 

That’s It..

Hope it helps..

Advertisements

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