Linux: Reset network configuration on a cloned Ubuntu Bionic VM

I suppose I’m doing fairly well that this is the first major systemd trouble I’ve had, but here goes. I created an Ubuntu VM, updated it, configured everything how I want, then realized I had to do two more like it (to set up a test ElasticSearch cluster). No worries, I’ll just clone the VM twice! Leave aside issues of the cloned drives ending up where I didn’t want them, I had an absolute bastard of a time getting systemd to let go of the old DHCP lease, even though I reset the MAC addresses on the interfaces during the clone.

Turns out, it’s fairly easy:

Change hostname

  • Edit /etc/cloud/cloud.cfg to turn preserve_hostname on.
  • Use hostnamectl set-hostname to actually change the hostname.

Ditch the old DHCP lease

After ensuring that the MAC is actually different, simply blow away the relevant file(s) in /run/systemd/netif/leases/ and reboot. Maybe there’s a way to do it without the reboot? I have no idea, but as it wasn’t listening on the right IP address uptime wasn’t really important.

fwaggle

Published:


Modified:


Filed under:


Location:


Navigation: Newer Entry