netplan apply, systemctl restart networking, nmcli, ip link - which command you need depends not on the distro but on which renderer runs the network. Here is how to identify it and how to restart safely on a remote server.

The network on your server is gone: the site will not load, apt update hangs, and SSH may or may not still be alive. The reflex is to reboot the box, but that is blunt and does not always help. How to restart networking on Ubuntu and Debian depends not on the distribution but on which mechanism runs the network - and there are several. This guide shows how to identify yours in a couple of commands, how to restart each one, how to fix DNS separately from the network itself, and how not to lock yourself out over SSH.

In short. First identify the renderer: grep -R "renderer:" /etc/netplan/ and systemctl status systemd-networkd NetworkManager. Renderer systemd-networkd (typical Ubuntu Server): on a remote box use sudo netplan try (auto-reverts after 120 seconds if you lose the link) or the targeted sudo networkctl reconfigure eth0. Renderer NetworkManager (desktops, many Debian installs): sudo nmcli device reapply eth0 or sudo systemctl restart NetworkManager. ifupdown (minimal Debian): sudo ifdown eth0 && sudo ifup eth0 as one line - not systemctl restart networking, which drops SSH. If nothing responds: sudo ip link set eth0 down && sleep 2 && sudo ip link set eth0 up. "Ping by IP works, ping by name does not" is DNS, fixed separately.

Step 1. Work out how to restart networking on Ubuntu and Debian

Network configuration is handled not by one program but by a stack. And netplan is not the part that brings interfaces up: it is a config generator. You describe the network in YAML, netplan translates it into settings for a renderer, and the renderer actually runs the network. The renderer is one of two: systemd-networkd or NetworkManager. That is what decides the restart command, so do recon in this order.

First, whether netplan is present and which renderer it uses:

ls -l /etc/netplan/
grep -R "renderer:" /etc/netplan/ 2>/dev/null
netplan get renderer 2>/dev/null

  • .yaml files and a line renderer: networkd - the network is run by systemd-networkd.
  • A line renderer: NetworkManager - run by NetworkManager.
  • No renderer: line - the default applies: networkd on server installs, NetworkManager on desktop installs. netplan get renderer returns null here, so check which service is running (next command).

Check which networking service is actually active:

systemctl --no-pager status systemd-networkd NetworkManager

Usually exactly one of the two shows active (running). If it is NetworkManager, note that networkctl is nearly useless to you - it only shows networkd's view. Work through nmcli.

If /etc/netplan/ is empty or absent, look further:

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

  • *.network files in /etc/systemd/network/ and no netplan - this is pure systemd-networkd (common on Debian cloud images). List interfaces with networkctl list.
  • Stanzas like iface eth0 inet static or iface eth0 inet dhcp in /etc/network/interfaces (not just lo, the loopback) - this is ifupdown, config through one text file. That is how a minimal or server install of Debian 12 and 13 looks.

A universal state check, the same for every stack:

ip -br addr
ip -br link

ip -br addr prints each interface's addresses and status (UP / DOWN). This is what you look at after any restart to see whether the network is back.

What you found in the system

Stack and how to restart

/etc/netplan/*.yaml, renderer: networkd or renderer unset on a server

netplan + systemd-networkd: netplan try / netplan apply, targeted networkctl reconfigure

/etc/netplan/*.yaml, renderer: NetworkManager

netplan + NetworkManager: nmcli device reapply, systemctl restart NetworkManager

/etc/systemd/network/*.network, no netplan

pure systemd-networkd: networkctl reconfigure, systemctl restart systemd-networkd

/etc/network/interfaces with iface stanzas

ifupdown: ifdown eth0 && ifup eth0 (one line)

50-cloud-init.yaml in /etc/netplan/

netplan, config written by cloud-init: netplan apply now; for reboots see the callout below

Cloud images and cloud-init. On cloud images the network is configured by cloud-init on first boot - it writes /etc/netplan/50-cloud-init.yaml. If you edit that file by hand, cloud-init may overwrite it on its next run: after a metadata change, a rebuild, sometimes on an ordinary reboot. Two ways to make edits stick. First, put your own file in /etc/netplan/ with a name that sorts later, say 99-custom.yaml: netplan applies files in order and the last one wins on matching keys. Second, take networking out of cloud-init entirely: echo 'network: {config: disabled}' | sudo tee /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg. Note: netplan apply applies the change now, but what happens after a reboot depends on whether cloud-init steps in.

Renderer systemd-networkd: Ubuntu Server and pure networkd

This section covers the netplan stack with the networkd renderer and pure systemd-networkd without netplan. systemd-networkd is the networking service on Ubuntu server installs. Its working files live in /etc/systemd/network/*.network (under netplan, generated from your YAML).

If the network is configured through netplan, "restart" means re-applying the YAML. On a box you only reach over the network, the main option is netplan try. It applies the config and starts a timer. Confirm in the terminal in time and the change stays. Lose the link and never press Enter, and after 120 seconds netplan restores the previous working config.

sudo netplan try

  • needs an interactive terminal; useless in a script;
  • --timeout 180 changes the rollback window (in seconds);
  • most reliable with the systemd-networkd renderer; with NetworkManager behaviour may differ - keep a spare SSH session or the panel console open.

What you see: a line Do you want to keep these settings? and a countdown Changes will revert in 120 seconds. Press Enter in time and you get Configuration accepted.

When you are at the console, or the change is already tested, apply it at once with no safety net:

sudo netplan apply

What you see: usually nothing - the command returns silently. A YAML error prints explicitly: Error in network definition ... with a line number.

To check the YAML even parses without touching the running network:

sudo netplan generate

Now networkd's own commands. First a status overview:

networkctl status

For each interface this shows its state (routable - has a route, degraded - up but no address, no-carrier - no link), address, gateway and DNS.

The gentle option - re-read changed files without touching interfaces that did not change:

sudo networkctl reload

The targeted option - re-apply settings to one interface: drop its addresses and routes, set them again, re-run DHCP. Take the name from networkctl status (often eth0, ens3, enp1s0):

sudo networkctl reconfigure eth0

The blunt option - tear down and rebuild everything networkd manages:

sudo systemctl restart systemd-networkd

Static addresses come back almost instantly; DHCP leases are re-requested. On a remote box prefer reconfigure for the interface you need - less risk of losing access.

What you see: after reconfigure, networkctl status eth0 should show State: routable and the address back within a few seconds.

Renderer NetworkManager: desktops and many Debian installs

NetworkManager runs the network on desktop Ubuntu and on Debian installed with a graphical environment; sometimes it is also the chosen netplan renderer. It calls each configuration a connection - a named profile: a Wi-Fi network, a wired link. List first:

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

Note the name of the connection you want from the first command - substitute it for "Wired connection 1" in the examples below.

Apply profile changes to the device without a full down/up - the least disruptive way:

sudo nmcli device reapply eth0

  • needs NetworkManager 1.14 or newer (present in Debian 12/13 and all current Ubuntu; check with nmcli --version);
  • some changes still need a brief link drop - use down/up below for those.

Restart one connection (quotes matter if the name has spaces):

sudo nmcli connection down "Wired connection 1" && sudo nmcli connection up "Wired connection 1"

Full reset: turn all of NetworkManager's networking off and on. Everything re-negotiates, DHCP included:

sudo nmcli networking off && sudo nmcli networking on

Restart the daemon - connections set to autoconnect come back on their own:

sudo systemctl restart NetworkManager

What you see: nmcli device status shows the device as connected, and nmcli -g IP4.ADDRESS device show eth0 prints an address.

ifupdown: older and minimal Debian

Older Debian, and any minimal or server install of Debian 12/13, keep network config in one text file - /etc/network/interfaces (plus snippets in /etc/network/interfaces.d/). The tool that reads it is ifupdown.

The first instinct - sudo systemctl restart networking - is dangerous on a remote server. It effectively runs ifdown -a and then ifup -a for every interface except lo. That drops an active SSH session even if your interface is marked auto. Do not use it remotely.

The right way is to bring one interface up by name, and in one line, so an SSH drop cannot leave it stuck down:

sudo ifdown eth0 && sudo ifup eth0

Why ifdown hangs or fails. Two common causes: it tries to release the DHCP lease but the link is already gone, so it waits on a timeout; or the state file /run/network/ifstate disagrees with reality, so ifdown says interface eth0 not configured and does nothing. The fix is a flag that ignores the state file:

sudo ifdown --force eth0 && sudo ifup eth0

If that still hangs, drop to the interface level (next section).

What you see: ip -br addr show eth0 prints a line like eth0 UP 192.0.2.10/24 once the interface is back.

Interface level: when the manager will not cooperate

If no manager helps, bounce the link directly. This works the same on every distribution because the command talks to the kernel, not to a config system. It reloads no config - you simply take the interface down and up.

sudo ip link set eth0 down && sleep 2 && sudo ip link set eth0 up

This is the network-card equivalent of unplugging the cable and plugging it back. Static config set by the manager usually survives; a DHCP address may need a renew. Over SSH run it as one line only (or via systemd-run / at): if you issue down as a standalone command, the up never runs - your session is already dead.

Interface name, if you do not remember it: ip -br link.

Renewing a DHCP address by hand. The right way depends on the stack:

  • systemd-networkd: sudo networkctl reconfigure eth0 re-runs DHCP;
  • NetworkManager: sudo nmcli device reapply eth0, or down/up the connection;
  • the old dhclient route: sudo dhclient -r eth0 to release, then sudo dhclient eth0 to request. On Ubuntu 24.04 dhclient is usually absent - systemd-networkd does DHCP there. On Debian 12/13 it depends: check command -v dhclient, and if needed install sudo apt install isc-dhcp-client.

What you see: ip -br addr show eth0 shows an address, and ip route shows a default via ... line.

DNS fails to resolve after a restart

Sometimes the link is up, ping 1.1.1.1 works, but ping google.com returns Temporary failure in name resolution. That is DNS, not the network. What comes next depends on whether systemd-resolved is running:

systemctl is-active --quiet systemd-resolved && echo "resolved active" || echo "resolved off"

If systemd-resolved is active (typical on Ubuntu), it handles name resolution:

resolvectl status

Shows the DNS servers per interface and the global settings. An empty or wrong Current DNS Server is your problem.

sudo resolvectl flush-caches

Clears the local DNS cache - stale or poisoned records. Does not touch config.

sudo systemctl restart systemd-resolved

Restarts the resolver; it re-reads DNS servers handed out by DHCP or set in netplan.

If systemd-resolved is off (common on Debian), the resolvectl commands will not work. Name resolution goes straight through /etc/resolv.conf:

cat /etc/resolv.conf

Check that it has nameserver lines. This file is rewritten by NetworkManager or ifupdown from the DHCP lease, so only edit it by hand if you are sure it will not be regenerated - otherwise your change is lost on the next network restart.

How not to lock yourself out over SSH

Restarting the network on a box you only reach over SSH is a classic way to lock yourself out. The restart drops your session; if the new config is wrong, nothing brings it back, and you are stuck outside until you reach a console. How to hedge.

1. Keep a second SSH session open. Just log in with a second window and leave it alone. If the first session dies, the second may live on for a few minutes - established TCP connections survive a brief blip. Cheap insurance.

2. On the netplan stack, apply through sudo netplan try. It reverts itself after 120 seconds if you do not confirm. Over a dead link you cannot confirm, so recovery happens automatically.

3. Run the command detached from the SSH session, and pick a targeted command rather than a full service restart. A deferred transient systemd unit that reconfigures one interface:

sudo systemd-run --on-active=1 --timer-property=AccuracySec=100ms networkctl reconfigure eth0

For the NetworkManager renderer, the same with nmcli:

sudo systemd-run --on-active=1 nmcli device reapply eth0

  • the command runs one second later in its own scope, not as a child of your shell;
  • even if SSH drops immediately, it still fires;
  • keep a full systemctl restart systemd-networkd or restart NetworkManager for when the targeted reconfigure does not help - and run that deferred too.

The same trick with at (needs sudo apt install at):

echo 'networkctl reconfigure eth0' | sudo at now + 1 minute

Or wrap it in tmux so the process has a home if you disconnect:

tmux new -d -s net 'sudo ifdown eth0 && sudo ifup eth0'

4. Know your rescue path in advance. WeaselCloud gives you a server console in the panel - screen-and-keyboard access that does not go over the server's network. With it you can fix a broken config even when networking is fully down. Open that item once, calmly, so you are not hunting for it in a panic.

What not to do: do not run sudo ip link set eth0 down or sudo ifdown eth0 as a standalone command over SSH expecting to bring the interface back up - the "up" half never runs. Chain both halves in one line, or run them deferred.

Symptom - command - why

  • Edited YAML in /etc/netplan, applying remotely. Command - sudo netplan try. Stack - renderer=networkd; it applies and auto-reverts after 120 s if the link is lost.
  • netplan tested, you are at the console. Command - sudo netplan apply. Stack - netplan with any renderer; applies at once, no safety net.
  • One interface stuck, address gone. Command - sudo networkctl reconfigure eth0. Stack - renderer=networkd or pure networkd; re-raises address and DHCP on one interface.
  • Network down as a whole. Command - sudo systemctl restart systemd-networkd. Stack - renderer=networkd or pure networkd; rebuilds everything networkd manages.
  • One connection dropped. Command - sudo nmcli connection down "name" && sudo nmcli connection up "name" (name from nmcli -t -f NAME,DEVICE connection show). Stack - renderer=NetworkManager; restarts one profile.
  • Need a full NetworkManager reset. Command - sudo nmcli networking off && sudo nmcli networking on. Stack - renderer=NetworkManager; everything re-negotiates, DHCP included.
  • Edited /etc/network/interfaces. Command - sudo ifdown eth0 && sudo ifup eth0 as one line. Stack - ifupdown; systemctl restart networking here equals ifdown -a + ifup -a and drops SSH even on an auto interface.
  • ifdown says not configured or hangs. Command - sudo ifdown --force eth0 && sudo ifup eth0. Stack - ifupdown; the flag ignores a stale state file.
  • Manager will not cooperate, need to bounce the link. Command - sudo ip link set eth0 down && sleep 2 && sudo ip link set eth0 up. Stack - any; goes straight to the kernel. Over SSH one line only or via systemd-run/at, otherwise "up" never runs.
  • Ping by IP works, by name does not, systemd-resolved active. Command - sudo resolvectl flush-caches, then resolvectl status. Stack - any; the problem is the DNS cache, not the network.
  • Same, but systemd-resolved is off. Inspect /etc/resolv.conf. Stack - common on Debian; resolution goes through that file, written by NetworkManager or ifupdown.
  • Restarting over SSH, worried about access. Command - sudo systemd-run --on-active=1 --timer-property=AccuracySec=100ms networkctl reconfigure eth0. Stack - renderer=networkd; the command lives apart from the session and is targeted, not a full restart.

FAQ

How do I restart networking on Ubuntu without a reboot?

A reboot is almost never needed. Identify the renderer (grep -R "renderer:" /etc/netplan/, systemctl status systemd-networkd NetworkManager) and restart it in a targeted way: sudo networkctl reconfigure eth0 for systemd-networkd, sudo nmcli device reapply eth0 for NetworkManager, sudo ifdown eth0 && sudo ifup eth0 for ifupdown. As a last resort, bounce the interface: sudo ip link set eth0 down && sleep 2 && sudo ip link set eth0 up.

What if I lose SSH after restarting the network?

The existing session will not come back - you need another way in. Open the server console in the WeaselCloud panel (screen access that bypasses the server's network) and check the config: ip -br addr, ip route, sudo netplan try. If it was a one-off glitch with no config changes, a reboot from the panel usually clears it. Next time: keep a second session open and apply changes through sudo netplan try, which reverts itself.

Why does netplan apply not apply my settings?

netplan apply exits silently even if the renderer did not pick up the settings. Check the syntax: sudo netplan generate reports YAML errors. Check which renderer is set (renderer: networkd or NetworkManager) and whether it is running: systemctl status systemd-networkd. Then sudo netplan --debug apply shows what is happening. Common causes: a wrong indent in the YAML, an interface name that does not exist (compare with ip -br link), or a cloud-init file that overrides yours.

How do I restart NetworkManager on Debian?

If Debian was installed with a desktop, NetworkManager runs the network. Restart the service with sudo systemctl restart NetworkManager; autoconnect connections come back on their own. Softer, without dropping the service: sudo nmcli device reapply eth0 or sudo nmcli connection down "Wired connection 1" && sudo nmcli connection up "Wired connection 1" (name from nmcli -t -f NAME,DEVICE connection show). On minimal Debian, NetworkManager is usually absent - it is ifupdown there.

How do I reset network settings on Linux to the original state?

There is no "factory" state as such - there is the config the provider or installer put in place. On the netplan stack that is the files in /etc/netplan/: restore the original and run sudo netplan apply. On a cloud image the original file is 50-cloud-init.yaml. On ifupdown, do the same with /etc/network/interfaces. If there is nothing to roll back to, the cleanest path is an OS reinstall from the WeaselCloud panel.

How do I restart networking on Ubuntu 24.04 - is it different from 22.04?

The commands are the same: netplan try, netplan apply, networkctl reconfigure, systemctl restart systemd-networkd. The differences are small: 24.04 images dropped dhclient (systemd-networkd does DHCP), and on the desktop netplan has used the NetworkManager renderer since 23.10. On the server, both versions run the same renderer - systemd-networkd - and restart the same way.

Tested on

The commands apply to Ubuntu 22.04 (systemd 249) and 24.04 (systemd 255), Debian 12 (systemd 252, NetworkManager 1.42) and Debian 13 (systemd 255+, NetworkManager 1.46+). On older systems some networkctl and nmcli subcommands may be missing - fall back to a full service restart or the interface level.

Takeaways

  • Look at the renderer, not the distro: grep -R "renderer:" /etc/netplan/ and which service is active - systemd-networkd or NetworkManager.
  • Renderer networkd: sudo netplan try remotely (auto-revert after 120 s), targeted sudo networkctl reconfigure eth0.
  • Renderer NetworkManager: sudo nmcli device reapply eth0; full reset is nmcli networking off/on.
  • ifupdown: sudo ifdown eth0 && sudo ifup eth0 as one line; systemctl restart networking drops SSH on a remote box.
  • Still nothing - the interface: sudo ip link set eth0 down && sleep 2 && sudo ip link set eth0 up.
  • "Ping by IP works, by name does not" is DNS: first systemctl is-active systemd-resolved, then either resolvectl flush-caches or /etc/resolv.conf.
  • Over SSH: a second session open, a targeted command via systemd-run, and know where the server console is in the WeaselCloud panel.

Next steps