Operating System CentOS

Fix Network Configuration After Restoring a Snapshot to a New Server

Restore connectivity when a snapshot boots on a new server with a different MAC or IP address: Ubuntu 26.04, Debian 13, AlmaLinux 9 and Rocky Linux 9.

When you restore a snapshot onto a new server, or clone a server from one, the virtual network card usually gets a new MAC address and often a new IP address. A system whose network configuration is tied to the old values then boots without connectivity. This guide shows how to get back in through the console and correct the configuration on Ubuntu 26.04 and 24.04 LTS, Debian 13 and 12, and AlmaLinux 9 or Rocky Linux 9, and how to prepare a server so that future snapshots restore cleanly.

Why the network breaks

Older tutorials tell you to empty /etc/udev/rules.d/70-persistent-net.rules because the restored system renamed its card from eth0 to eth1. That file is not generated on current releases: interface names are now derived from the device's position (for example enp1s0 or ens3) or fixed as eth0 by the image, so a new MAC address alone no longer renames the interface. The causes today are different:

  • The configuration matches the interface by its old MAC address (netplan match: macaddress, NetworkManager mac-address or HWADDR).
  • A static IP address, gateway or IPv6 address from the original server is written in the configuration.
  • cloud-init is missing, disabled for networking, or did not notice that it is running on a new instance.
  • Two clones share the same machine ID and therefore the same DHCP client identifier.

Step 1: Log in through the console and look

SSH is unavailable, so open the server's web console (VNC/KVM) in your hosting control panel and log in. Then compare what the system has with what the control panel says it should have:

ip -br link
ip -br addr
ip route

Note the interface name, its current MAC address (third column of ip -br link), and whether it is DOWN or simply has no address. Also note the IP address, netmask and gateway that your provider assigned to the new server.

Step 2: Fix the configuration

Ubuntu 26.04 and 24.04 (netplan)

Ubuntu keeps its network configuration in YAML files under /etc/netplan/; on cloud images the file is usually 50-cloud-init.yaml. Look for a stale MAC address or static address:

sudo grep -rn -e macaddress -e addresses /etc/netplan/

Edit the file so that it matches the interface by name instead of by MAC address. A DHCP configuration looks like this (use the interface name from Step 1):

network:
  version: 2
  ethernets:
    ens3:
      dhcp4: true
      dhcp6: true

If your provider requires a static address, replace the dhcp lines with the new values:

network:
  version: 2
  ethernets:
    ens3:
      addresses:
        - 203.0.113.10/24
      routes:
        - to: default
          via: 203.0.113.1
      nameservers:
        addresses: [198.51.100.53]

Apply it. netplan try rolls back automatically unless you confirm, which protects you from a typo:

sudo netplan try

If the file was written by cloud-init, your edit is replaced the next time cloud-init regenerates it; see Step 3.

Debian 13 and 12

Check which system the image uses. If /etc/netplan/ contains YAML files (common on cloud images), follow the Ubuntu section. A classic installation uses ifupdown with /etc/network/interfaces and the files in /etc/network/interfaces.d/:

cat /etc/network/interfaces /etc/network/interfaces.d/* 2>/dev/null

Make sure the interface name matches Step 1 and correct any static values. A DHCP stanza is:

auto ens3
iface ens3 inet dhcp

Then restart networking:

sudo systemctl restart networking

AlmaLinux 9 and Rocky Linux 9 (NetworkManager)

List the connection profiles and see which one, if any, is bound to the device:

nmcli -f NAME,UUID,DEVICE connection show
nmcli device status

A profile that shows no device is usually pinned to the old MAC address. Profiles live in /etc/NetworkManager/system-connections/ (keyfiles, mac-address=) or, on images that still use the legacy format, in /etc/sysconfig/network-scripts/ifcfg-* (HWADDR=). Clear the MAC address, bind the profile to the interface name instead, and bring it up. Replace System eth0 and eth0 with your profile and device names:

sudo nmcli connection modify "System eth0" 802-3-ethernet.mac-address "" connection.interface-name eth0
sudo nmcli connection up "System eth0"

For a static address, set the new values on the same profile:

sudo nmcli connection modify "System eth0" ipv4.method manual ipv4.addresses 203.0.113.10/24 ipv4.gateway 203.0.113.1 ipv4.dns 198.51.100.53
sudo nmcli connection up "System eth0"

Windows Server

Windows treats the new card as a new adapter and configures it with DHCP, so it normally comes up by itself. Static addresses set on the old adapter are not carried over and have to be entered again on the new one.

Step 3: Let cloud-init handle it

On most provider images cloud-init writes the network configuration from the provider's metadata each time it detects a new instance, which is exactly what a restored snapshot needs. Check that it is installed and what it did:

cloud-init status --long

If it is missing, install the cloud-init package with apt or dnf once the network works again. If it is present but the old configuration survived, look for a file that turns its network handling off:

sudo grep -rn -A2 "^network" /etc/cloud/cloud.cfg /etc/cloud/cloud.cfg.d/

A network: {config: disabled} entry means the network files are yours to maintain by hand, as in Step 2. Otherwise you can make cloud-init treat the server as a fresh instance and regenerate its configuration on the next boot:

sudo cloud-init clean --logs --reboot

Be aware that this reruns all first-boot tasks, not just networking. Depending on the image and your provider's metadata that can include regenerating SSH host keys and resetting the default user's authorized keys or password.

Step 4: Verify

ip -br addr
ip route
ping -c 3 203.0.113.1
ping -c 3 example.com

The interface should be UP with the address from your control panel, there should be one default route, and both the gateway and a host name should answer. Reboot once to confirm that the configuration persists.

Prepare a server before taking a snapshot

If the snapshot is meant as a template for new servers, clean it first so that every clone starts with its own identity:

  • Remove MAC addresses from network configuration files and match by interface name, or leave networking to cloud-init.
  • Reset cloud-init and the machine ID, then shut down and take the snapshot while the server is off:
sudo cloud-init clean --logs --machine-id
sudo shutdown -h now

A unique machine ID matters because systemd-networkd derives its DHCP client identifier from it; clones with the same ID can be handed the same lease. On a clone that already shares an ID, generate a new one and reboot:

sudo rm /etc/machine-id
sudo systemd-machine-id-setup
sudo reboot

Frequently asked questions

Do I still need to delete 70-persistent-net.rules?

No. Current Ubuntu, Debian and RHEL 9 family releases do not create that file. If it exists on a system that was upgraded in place for many years, removing it is harmless, but it is not the reason a restored server has no network.

IPv4 works after the restore but IPv6 does not. Why?

Automatically configured IPv6 addresses are often derived from the MAC address, so the new server has a different address from the one in your DNS records or firewall rules. A static IPv6 address or gateway copied from the original server can also be wrong for the new one. Compare ip -6 addr with the IPv6 details in your control panel.

Why does SSH warn that the host key changed, or not changed, after cloning?

A restored snapshot carries the original server's SSH host keys, so two clones present the same identity unless cloud-init regenerates the keys on first boot. If it did, your client warns because the IP address now maps to a new key; remove the old entry with ssh-keygen -R 203.0.113.10. If it did not, regenerate the keys on the clone so the servers cannot impersonate each other.

The private network interface is missing after the restore. What should I check?

Secondary interfaces are frequently configured by hand with a MAC match and a static private address. Attach the new server to the private network in the control panel, find the new interface with ip -br link, and update its stanza or profile the same way as the primary one.

Share story:

Continue reading other guides on How VPS.