brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: netplan try rolls your network change back if you lose the connection

Netplan
~/tips/tip-ubuntu-netplan-try

sudo netplan try

Applies a netplan change and automatically undoes it unless you confirm it in time.

Editing the network config of a remote server is one of those jobs where a typo means a drive to the datacenter. Netplan has a safety net, and many people skip it.

sudo netplan try

It applies the new configuration, then waits. If you do not confirm within 120 seconds, it reverts to the old one. Press Enter to accept the change. That is from the man page, and the timeout is configurable:

sudo netplan try --timeout 30

The scenario it saves you from: you change the IP or the gateway over SSH, the session freezes, and you cannot reach the machine to undo it. With try you wait for the countdown to run out and the old network comes back by itself.

I would use it every time on a remote box, even for a change I am sure about. Typing netplan apply is for the moments when I am physically in front of the screen.

Caveat: the revert only helps if you finish the change inside the window. A DHCP lease that takes a minute to arrive, or a router that needs a moment, can eat the time. Raise the timeout when that applies.

Further reading: netplan-try(8) man page (Ubuntu 24.04), On this site: netplan status shows what the network actually looks like right now

More Netplan tips – to: 192.168.3.0/24 hidden: true lacp-rate: fast link-local: [] wakeonlan: true All Netplan tips (21) All topics

Link