Operating System - Linux
1823724 Members
3535 Online
109664 Solutions
New Discussion

ethernet device name gets changed after reboot.

 
vijay alur alur
Frequent Advisor

ethernet device name gets changed after reboot.

Hello All.

 

i have a server running redhat linux 6.3 OS. Its primary IP is binded with 2 ethernet card (eth0 and eth1) and using bond0. Whenever the server is rebooted, the eth0 and eth1 gets renamed to eth2 and eth3 respectively. because of this the server does not comes on network since bond0 looks for the eth0 and eth1 devices.

 

so to fix this issue what we do is delete the file /etc/udev/rules.d/70-persistent-net.rules and reboot the server. after reboot the the ethernet devices gets the name eth0 and eth1 and hence the issue gets fixed.

 

I am looking for a way by which we do not have to do the above manual work everytime we reboot the server.

 

Regards,

Vijay

Lead Engineer, IMS.
iGATE
4 REPLIES 4
Matti_Kurkela
Honored Contributor

Re: ethernet device name gets changed after reboot.

For legacy compatibility reasons, RHEL 6.x has actually two overlapping mechanisms for assigning the eth* names to NICs persistently.

 

First, and the more modern one, is the /etc/udev/rules.d/70-persistent-net.rules, which you already know.

 

The other is the "HWADDR=" lines in /etc/sysconfig/network-scripts/ifcfg-eth* files.

 

I think RHEL is transitioning to the udev method (which is apparently becoming the de facto standard across enterprise Linux distributions), but RHEL 6.x still may use the HWADDR= lines too.

 

I would guess that your server has HWADDR= lines with incorrect MAC addresses in /etc/sysconfig/network-scripts/ifcfg-eth0 and .../ifcfg-eth1. When you remove the 70-persistent-net.rules file, remove the HWADDR= lines too. Alternatively, make sure that the correct MAC addresses are associated with correct interface names in both places.

 

Alternatively, is your server a virtual machine? In that case, some VM hosts can cause the MAC addresses of the guest's virtual NICs to vary each time the guest is stopped and restarted at the VM level. In that case, you will need to remove the HWADDR= lines and also do something about the /lib/udev/rules.d/75-persistent-net-generator.rules file. A comment at the beginning of that file says:

# do not edit this file, it will be overwritten on update

 

So, editing or removing the 75-persistent-net-generator.rules file won't help, since the standard version will come back whenever the udev RPM is updated.  But "man udev" custom files in /etc/udev/rules.d/ will override identically-named standard files in  /lib/udev/rules.d. In other words, to permanently disable the /lib/udev/rules.d/75-persistent-net-generator.rules file, run this command:

echo "# network interface name/MAC persistence is intentionally disabled" >/etc/udev/rules.d/75-persistent-net-generator.rules

After that, if you delete the 70-persistent-net.rules file, it will not be re-created.

 

I think the installation of VMware Tools does something like this on VMware guests running Linux RHEL 6.x.

MK
vijay alur alur
Frequent Advisor

Re: ethernet device name gets changed after reboot.

Hi Matti,

 

Thanks for the reply!!

 

This is a physical server Environment.

 

The file /etc/sysconfig/network-scripts/ifcfg-eth0 and /etc/sysconfig/network-scripts/ifcfg-eth1 have the HWADDR line commented.

 

do you suggest me to have that line HWADDR added in the file /etc/sysconfig/network-scripts/ifcfg-eth*??

 

OR do i have to always rely on removing the file /etc/udev/rules.d/70-persistent-net.rules?

 

please suggest.

 

 

Regards,

Vijay

Lead Engineer, IMS.
iGATE
Matti_Kurkela
Honored Contributor

Re: ethernet device name gets changed after reboot.

To stop the auto-creation of /etc/udev/rules.d/70-persistent-net.rules, create a file named /etc/udev/rules.d/75-persistent-net-generator.rules. The filename must be exactly that.

 

(Technically, it can be an empty file, but it is better to write just a comment in it, to indicate the reason why the file has been created. Someone might wonder why there is an empty file in /etc/udev/rules.d, assume that it is useless, and then delete it.)

 

Then delete the /etc/udev/rules.d/70-persistent-net.rules one final time, and it won't be re-created any more.

 

The 75-persistent-net-generator.rules file in /etc/udev/rules.d will override the file with the same name in /lib/udev/rules.d, so the automatic creation of the 70-persistent-net.rules file won't happen any more.

 

The procedure above is better than modifying or deleting /lib/udev/rules.d/75-persistent-net-generator.rules, because any update of the udev RPM will overwrite the files in /lib/udev/rules.d,and that would undo the modification and cause the problem to happen again.

MK
vijay alur alur
Frequent Advisor

Re: ethernet device name gets changed after reboot.

Hi Matti,

 

Thanks for the suggestion.

 

I will try this option and let you know.

 

Regards,

Vijay

Lead Engineer, IMS.
iGATE