I'm running Ubuntu 18.04 64-bit server. I do a clean install, set up all of my custom software, and all is good. I use clonezilla to create a master image, which I later clone. I deal with the machine-id file so that cloned instances on new hardware get a new MAC address and IP address. My issue is that now, on some recent hardware, the ethernet interface name is coming up different than on the original cloned image. So DHCP will not work automatically for example, because the config file in /etc/netplan is specifying the interface name of the old hardware, not the new hardware.

Is there a way to cause netplan to auto-config things on boot? Maybe remove all the yaml files in /etc/netplan? The issue is that the cloned image contains a netplan yaml file with configuration that do not apply to the new hardware. This must be a simple thing to fix, but I've failed to find it in searches online and in this forum. Thanks for any help!

  • "I do a clean install, set up all of my custom software, and all is good." --- perhaps you'd have a look at cloud-init; have a look at (the second handles some network/dhcp issues) help.ubuntu.com/community/CloudInit askubuntu.com/questions/1040820/… cloudinit.readthedocs.io/en/latest/topics/merging.html – db429 Jun 22 at 20:01
  • Thanks for the links. We were purposely not using cloud-init, we wanted a lighter install as this is for a fairly locked down medical device ultimately, so the fewer packages to keep track of the better. Previously (we started with 16.04) we were using systemd networking directly and it seemed perfectly happy to enable dhcp by default no matter what the interface name was at boot. We are ok with netplan being installed, as long as we can trigger some sort of re-scan to set up the config correctly, or use a minimal netplan config maybe. – MGD Jun 23 at 0:32
  • a systemd job running before netplan gets called, that runs sed s/enOLD/$(ip -a | grep en | sed <egex limbo>)/ /etc/netplan/WHATEVER.yaml -- would be what would come to my mind; the $(..) part could be a separat thing that gets passed as variable? – db429 Jun 23 at 0:54
  • or perhaps use the match: property in the original setup? - see netplan.io/… – db429 Jun 23 at 1:14

Got it working. db429's suggestion to use match was the answer (I'd give you credit but as a new user I could not figure it out).

Here's the new netplan config I'm using now:

# generic ethernet adapter config, matches any interface names beginning with "en"
  version: 2
  renderer: networkd
        name: en*
      dhcp4: yes

Basically, at early boot, netplan reads this config, and generates a file in /run/systemd/network called 10-netplan-eth0.network Note the eth0 in the file name which matches the block I provided in the netplan yaml config file.

The generated contents of 10-netplan-eth0.network are:




This generated network file is then used correctly to initialize any matching interfaces with dhcp. This .network file can also be used directly by systemd-networkd and in fact netplan.io could be removed later (I tested that also, as systemd-networkd is enabled on my server).

| improve this answer | |
  • my use of eth0 was a bad choice, I would recommend something more generic, like enwild or something. – MGD Jun 23 at 14:12

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.