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: a route-only domain gives you split DNS in one command

Network and access
~/tips/tip-dns-resolvectl-split

resolvectl dns wg0 10.0.0.1

Sends DNS queries for one domain to a VPN's DNS server and leaves the rest alone.

A VPN that hijacks all your DNS is annoying. You want the work names to go to the work DNS server and everything else to stay on your normal one.

With systemd-resolved you can attach a DNS server and a route-only domain to one network link. The ~ in front of the domain marks it as route-only: queries for that domain go to that link’s server, and it is not used as a search domain.

resolvectl dns wg0 10.0.0.1
resolvectl domain wg0 '~corp.example'
resolvectl status wg0

Replace wg0 with the name of your VPN interface and the domain with your own. Now only *.corp.example goes through the tunnel. Everything else uses the other links.

These settings live on the link. The manual says they are lost when the interface goes away, so a VPN client that recreates it will wipe them. Make it permanent in the VPN or network configuration, and undo it by hand with resolvectl revert wg0. Also, quote the tilde, or your shell will expand it.

Run resolvectl status wg0 afterwards to see the result. You should see the server and the route-only domain listed under that link. If a name still goes to the wrong place, the status output is where you see it, because the longest matching domain wins.

Further reading: resolvectl manual, On this site: turn on DNS over TLS in systemd-resolved, On this site: resolvectl flush-caches clears the DNS cache on Linux, On this site: Guide: send your tailnet's DNS through your own AdGuard Home with Tailscale split DNS

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