4

I have a custom version of CENTOS that I'm importing into Hyper-V on a Windows Server. Whenever I import it however, the mac addresses of eth1 and eth2 are now different. So they get incremented to eth3 and eth4.

I've written a script that can detect when this happens and edit the /etc/udev/rules.d/70-persistent-net-rules file so that it reverts to eth1 and eth2 after a reboot.

But a better way of doing this, I think, would be to find the new mac addresses early at boot, then edit my /etc/udev/rules.d/70-persistent-net-rules file before udev loads at all. That way it'll boot with the recommended settings.

Static mac addresses are not an option for this.

Is there a way for me to get the new mac addresses before they're assigned? Also is there a way to predict which eth they're going to be assigned to?

1

It's not exactly the answer. But I solved my problem by removing the information about all of the devices in /etc/udev/rules.d/70-persistent-net-rules before rebooting. The file just contained:

"# This file was automatically generated by the /lib/udev/write_net_rules

# program, run by the persistent-net-generator.rules rules file.

#

# You can modify it, as long as you keep each rule on a single

# line, and change only the value of the NAME= key."

Then upon reboot, my devices were set to eth0 and eth1 again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.