Cloned Linux system and /etc/udev/rules.d/70-persistent-net.rules

50,589

I've run into this exact same problem under CentOS from time to time when I've cloned virtual machines (VM's). The problem stems from the original VM getting an entry put into this file to setup the Ethernet device eth0.

Sample .rules file

# 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.

# net device () (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="54:52:00:ff:ff:dd", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

The problem rears its ugly head when you clone the first VM, this causes a new MAC address to be created, under some virtualization technologies such as KVM for one. This new MAC address is auto detected when the cloned VM is booted and viewed as a new Ethernet device by /lib/udev/write_net_rules, and so a 2nd entry is added to the above file.

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="54:52:00:ff:ff:de", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

I usually open this file, 70-persistent-net.rules, in an editor and simply consolidate the lines so that the new MAC address is assigned to the eth0 device and reboot.

...
# net device () (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="54:52:00:ff:ff:de", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

EDIT #1

The OP followed up the question with the following new information.

Item #1: Hmmm. That won't work in my case because I'm running software with a flex license that ties to the mac address. Constantly changing addresses render said software useless..

@Zobal - I'm familiar with Flex. Since it's a VM you can change the VM's MAC (in the VM software - VirtualBox, KVM, etc.).

NOTE: Flex is a licensing technology that's provided by Flexera. They used to be called GlobeTrotter Software. This technology allows software to be either tied to a physical host, or can have licenses managed from a central server as "tokens" where clients can check the tokens out for a period of time. The licenses are typically tied to a host, and this host is usually identified by a unique number that you can find using the command hostid.

For example:

$ hostid
a8c0c801

Item #2: In my case it's not a VM. I've cloned one physical system onto another physical system.

To which I responded: Well then your only option is to change the new system's MAC address to the same as the other system's MAC. Realize that these 2 systems cannot exist on the same network, otherwise they will conflict with each other. Also Flex licensing typically does not use the MAC, they use the number that's identifiable using the command hostid!

References

Share:
50,589

Related videos on Youtube

Zobal
Author by

Zobal

Updated on September 18, 2022

Comments

  • Zobal
    Zobal over 1 year

    I set up an Ubuntu system and configured it properly, including defining eth0 in /etc/network/interfaces. I then imaged that system and cloned it on a new system.

    When I booted up the system the first time all was good, but a few reboots later I was greeted with the network config timing out. When I logged in I found that eth0 was not available.

    My initial research let me to try ifdown -a and ifup -a which I did a few times to no apparent effect.

    Research eventually pointed me to /etc/udev/rules.d/70-persistent-net.rules, where I discovered that the MAC address for the new system had created eth1. Good idea, but not what I wanted to happen.

    When I booted up just now, I found that /etc/udev/rules.d/70-persistent-net.rules now has six entries for six different HW Addresses, which I find strange as there is only one interface.

    My question is: did my use of ifup -a somehow create new MAC addresses to be created? If not, are there any thoughts on how this happened? I altered /etc/udev/rules.d/70-persistent-net.rules to name the current HW Address eth0 and it seems to be working, but can I be assured that the address won't change again on a reboot?

    • slm
      slm over 10 years
      Future visitors of this Q: This is not a VM, it's a physical system that the OP cloned onto new hardware!
  • Zobal
    Zobal over 10 years
    Hmmm. That won't work in my case because I'm running software with a flex license that ties to the mac address. Constantly changing addresses render said software useless...
  • slm
    slm over 10 years
    @Zobal - I'm familiar with Flex. Since it's a VM you can change the VM's MAC (in the VM software - VirtualBox, KVM, etc.).
  • Zobal
    Zobal over 10 years
    In my case it's not a VM. I've cloned one physical system onto another physical system.
  • slm
    slm over 10 years
    @Zobal - well then your only option is to change the new system's MAC address to the same as the other system's MAC. Realize that these 2 systems cannot exist on the same network, otherwise they will conflict with each other. Also Flex licensing typically does not use the MAC, they use the number that's identifiable using the command hostid!
  • Zobal
    Zobal over 10 years
    the flex licenses are licenses that we created to tie our software to a specific machine, and in this case it does use the MAC. New Development: I reinstalled UBUNTU from scratch (not from and image) and am getting the same behaviour. It actually only shows up on dirty shutdowns (the power gets yanked). Any thoughts?
  • slm
    slm over 10 years
    @Zobal - let me think about it wrt to the dirty shutdowns.
  • Zobal
    Zobal over 10 years
    Thanks a lot. I'll ask about it in a new question as well.