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 enable wg-quick@wg0 brings a WireGuard tunnel up at boot

Network and access
~/tips/tip-wireguard-wg-quick-systemd

sudo systemctl enable --now wg-quick@wg0

Start a WireGuard interface automatically at boot with the unit that ships with wg-quick.

Running wg-quick up wg0 by hand is fine for a test. For a tunnel that should survive a reboot, wireguard-tools ships a systemd template unit that does the same.

sudo systemctl enable --now wg-quick@wg0

The part after the @ is the name of the config file, so this uses /etc/wireguard/wg0.conf. --now also starts it right away. If you already brought it up by hand, run sudo wg-quick down wg0 first, or the start fails because the interface exists.

The unit waits for the network to be online, and it keeps retrying the endpoint’s DNS name instead of giving up. That matters when your endpoint is a dynamic DNS name and the box boots before the network is fully there.

Check it with:

systemctl status wg-quick@wg0
journalctl -u wg-quick@wg0

The journal shows the exact ip commands wg-quick ran, which helps when a route or DNS setting from the config did not apply.

Once the service owns the interface, I’d stop using wg-quick up and down for it and go through systemctl, so systemd’s idea of the state matches reality. For several tunnels you enable one instance per config file.

Further reading: [email protected] unit, wg-quick(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