Search domains with wg-quick

Caleb Spare cespare at
Thu Jan 24 04:37:20 CET 2019

I use Wireguard in a typical sort of "corp VPN" scenario. I use
wg-quick to bring my wg0 up and down.

What is the best way to add a search domain when my wg0 is up?

After reading the wg-quick source, I came up with this proof of
concept that *does* work on my machine:

PostUp = echo 'search' | resolvconf -a -m 0 -x
PreDown = resolvconf -d

However, there are some problems:

- That "" string is just something I made up after seeing
the "tun.wg0" that wg-quick uses. What should I put there?
- I don't even know how the -m 0 -x flags work, or whether they're
necesary. (There was an interesting discussion between Jason and
Lennart Poettering over here, though:
- I guess I need to take some different approach in macOS; some
googling talks about "networksetup -setsearchdomains"?

Anyway, would it be reasonable to teach wg-quick about search domains,
or is doing some kind of PostUp/PreDown stuff going to be my only

BTW in OpenVPN we do this with

push "dhcp-option DOMAIN"
push "dhcp-option DNS"


More information about the WireGuard mailing list