Linux  ·  high  ·  Networking, DNS & SSH

Netplan changes do nothing, or take the network down

Netplan is a front end. The configuration is only real once it has been rendered to the back end that is actually running.

What you see

An edited YAML file has no effect after netplan apply, or the machine drops off the network entirely and has to be recovered at the console.

What is actually wrong

Two configuration files where the later one wins, cloud-init rewriting the file at boot, or a renderer mismatch — the YAML naming networkd while NetworkManager is the thing actually managing the interface.

Codes and articles

netplan applynetplan tryrenderer networkd50-cloud-init.yaml

Fixes (3)

Find which file is actually winning
Root shell15 minuteslow riskreversible

The apply succeeds and nothing changes.

  1. List every file netplan will read. They are processed in lexical order and later files override earlier ones.

    Shell
    ls -l /etc/netplan/

    A hand-written 01-static.yaml is overridden by the 50-cloud-init.yaml that ships on most cloud and Ubuntu Server images. Editing the wrong one is the single most common cause of this.

  2. See what netplan produces from all of them together.

    Shell
    netplan getsudo netplan generate --debug 2>&1 | tail -30
  3. Check which renderer is in use and which is actually running.

    Shell
    grep -r renderer /etc/netplan/systemctl is-active systemd-networkd NetworkManager
  4. Consolidate into a single file with correct permissions — netplan warns about world-readable files that contain Wi-Fi keys.

    Shell
    sudo chmod 600 /etc/netplan/*.yaml
  5. Apply and confirm.

    Shell
    sudo netplan applyip -brief addr showip route show
Confirm it workedThe address and routes match the configuration and survive a reboot.
Shell
ip -brief addr; ip route; resolvectl status | head -20
If you need to undo itKeep a copy of each file before editing: sudo cp -a /etc/netplan /root/netplan-backup.
Apply safely, and recover when it goes wrong
Console access20 minutesmedium riskreversible

The change took the network down — or before making one on a remote machine.

  1. Use netplan try rather than netplan apply on any remote machine. It reverts automatically after 120 seconds unless confirmed.

    Shell
    sudo netplan try --timeout 120

    This is the difference between a mistake that costs two minutes and one that costs a trip to the site. It exists for exactly this and almost nobody uses it.

  2. If you are already locked out, get to the console — the hypervisor console, IPMI, or physical.

  3. Restore the backup and apply.

    Shell
    sudo cp -a /root/netplan-backup/* /etc/netplan/sudo netplan apply
  4. With no backup, bring the interface up by hand to restore access while you fix the file.

    Shell
    sudo ip addr add 192.168.1.50/24 dev ens18sudo ip link set ens18 upsudo ip route add default via 192.168.1.1
  5. Check the YAML for the usual errors: tabs instead of spaces, a missing colon, or an interface name that does not exist.

    Shell
    sudo netplan generate 2>&1ip -brief link show
Confirm it workedThe machine is reachable and the configuration survives a reboot.
Shell
sudo netplan apply && ip -brief addr
If you need to undo itThe backup copy restores the previous state exactly.
Stop cloud-init rewriting the network configuration
Root shell15 minutesmedium riskreversible

The configuration reverts on every reboot.

  1. Confirm cloud-init is responsible.

    Shell
    head -5 /etc/netplan/50-cloud-init.yamlcloud-init status --long
  2. Disable its network module rather than removing cloud-init, which does other useful things.

    Shell
    echo 'network: {config: disabled}' | sudo tee /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

    Deleting 50-cloud-init.yaml alone does not work — cloud-init simply writes it again at the next boot. This file is the supported way to tell it not to.

  3. Write the real configuration in a file of your own.

    Shell
    sudoedit /etc/netplan/60-static.yaml
  4. Apply and reboot to confirm it persists.

    Shell
    sudo netplan applysudo reboot
Confirm it workedAfter a reboot, the address is the configured one and 50-cloud-init.yaml has not reappeared with different contents.
Shell
ip -brief addr; ls -l /etc/netplan/
If you need to undo itRemove /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg to hand control back to cloud-init.

Where this stops. This write-up was written and checked by hand. It says what each step changes, how to confirm it worked and how to reverse it, and anything destructive is flagged before you reach it. If it does not match what your machine is doing, search the Support Centre for the exact code or message — and when something needs a person, get in touch.