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: systemctl reload applies WireGuard peer changes without dropping the tunnel

Network and access
~/tips/tip-wireguard-reload-syncconf

sudo systemctl reload wg-quick@wg0

Add or change a WireGuard peer without restarting the interface and cutting everyone off.

Adding a peer to wg0.conf and restarting the interface drops every connection on it, including the SSH session you used to make the change. There is a gentler way.

If the tunnel runs as wg-quick@wg0, a reload is enough:

sudo systemctl reload wg-quick@wg0

The unit file shows what that does under the hood, and you can run it yourself when the tunnel is not managed by systemd:

sudo bash -c 'wg syncconf wg0 <(wg-quick strip wg0)'

wg-quick strip prints the config without the wg-quick-only options, and wg syncconf compares it with the running interface and only changes what differs. Existing peers keep their sessions.

There is a limit to know. The stripped lines are things like Address, DNS, PostUp and the routes wg-quick creates from AllowedIPs. A reload does not apply those. A new peer with a new subnet may need its route added by hand, or a full restart when you have a quiet moment.

The bash wrapper is there because <( ) is a bash feature that plain sh and sudo on its own do not understand.

And if SaveConfig = true is in your config, the wg-quick man page warns your edits get overwritten when the interface goes down. I’d leave SaveConfig off for that reason.

Further reading: wg-quick(8) man page, wg(8) man page

Going deeper: Why a Tailscale device vanishes after 180 days, and how to stop it

More Network and access tips scp -3 alice@server-a:/var/backups/db.sql.gz bob@server-b:/srv/restore/ tailscale exit-node suggest tailscale lock sign nodekey:1abddef1 tlpub:abcdef12 wg genpsk > peer1.psk Table = off All Network and access tips (163) All topics

Link