From: Eric Light <eric@ericlight.com>
To: wireguard@lists.zx2c4.com
Subject: Re: Fixing wg-quick's DNS= directive with a hatchet
Date: Thu, 26 Oct 2017 15:54:02 +1300 [thread overview]
Message-ID: <1508986442.581908.1151315616.1C72E382@webmail.messagingengine.com> (raw)
In-Reply-To: <CAHmME9q0m1rEfc_CFsb3qv6oQ97QOjtPDxe6yY+D+0aAApE9Yg@mail.gmail.com>
It looks ... really elegant to me. That said, it could end up being
super confusing. I definitely second Kalin's comments about adding a
comment header to /etc/resolv.conf.wg-quick.wg0
I was going to ask about unlinking, but you've addressed that in your
follow-up.
All that's left is for me to hat-tip your Paulsen reference. I still
have that book at home, probably been 20 years since I've read it.
Linux certainly has an abundance of porcupines buried in the terrain.
E
--------------------------------------------
Q: Why is this email five sentences or less?
A: http://five.sentenc.es
On Thu, 26 Oct 2017, at 11:43, Jason A. Donenfeld wrote:
> Hi,
>
> A sensible way to manage DNS on a distribution is via openresolv's
> resolvconf(8) [1]. Various networking utilities can call resolvconf
> with various arguments, and resolvconf will handle everything.
>
> Resolvconf offers two useful options: metric via -m and exclusive via
> -x. The metric options imply controls the order of entries in the
> subsequent /etc/resolv.conf. The exclusive option sets the provided
> nameserver to be the _only_ one listed in /etc/resolv.conf. This
> general system works great and is what wg-quick(8) uses at the moment.
>
> Debian (and by extension Ubuntu), however, ship with a butchered
> resolvconf [2] that silently ignores the -m and -x options. Instead,
> Debian's resolvconf orders the entries of /etc/resolv.conf according
> to some pre-defined interface naming heuristics, and does not allow
> for an exclusive mode at all. wg-quick thus uses openresolv's -m 0 and
> -x arguments, described above, but does so for an interface called
> "tun.wg0". The "tun." prefix tricks Debian's resolvconf into ordering
> WireGuard entries first, but still not exclusively.
>
> Meanwhile, Fedora does not ship resolvconf at all, and instead either
> uses NetworkManager or dhclient-script, depending on the configuration
> of a variable inside of some file in /etc/sysconfig/network-scripts/.
> I haven't really looked at how to coherently interface with all the
> possibilities, and I'm kind of reluctant to look.
>
> So I have three options: 1) require openresolv, 2) punt the issue to
> distro package managers, by making wg-quick "source" a file in
> /usr/lib/wg-quick/dns.bash that provides the distro-specific
> DNS-setting function, or 3) the hatchet, described below.
>
> Before I describe the hatchet, though, it might be worthwhile to
> remind ourselves of the three goals of DNS setting in this
> environment: a) be the exclusive DNS entry, b) restore the previous
> settings when the wireguard interface is removed, and c) not allow
> other things on the system (like roving dhcp daemons) to overwrite our
> settings.
>
> The hatchet works as follows. On interface addition:
>
> # echo nameserver 1.2.3.4 > /etc/resolv.conf.wg-quick.wg0
> # [ -f /etc/resolv.conf ] || touch /etc/resolv.conf
> # mount -o ro --bind /etc/resolv.conf.wg-quick.wg0 /etc/resolv.conf
> # unlink /etc/resolv.conf.wg-quick.wg0
>
> On interface removal:
>
> # umount /etc/resolv.conf
>
> This achieves all goals. Goal (a) is achieved because we're mounting
> over the existing /etc/resolv.conf, so we blow away old entries. Goal
> (b) is achieved because unmounting reveals the original file just
> below it. Goal (c) is achieved because we're mounting as read-only; we
> can't even remove the file without unmounting.
>
> So, I'm leaning over going with (3) the hatchet rather than (2) the
> distros, because I think this will likely work more universally.
> However, it's a hatchet. And hatchets have sharp dangerous blades, and
> Linux is not the rewarding bush terrain of Gary Paulsen.
>
> Can anybody think of any potential issues with this?
>
> Thanks,
> Jason
>
>
> [1] https://roy.marples.name/projects/openresolv
> [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=860564
> _______________________________________________
> WireGuard mailing list
> WireGuard@lists.zx2c4.com
> https://lists.zx2c4.com/mailman/listinfo/wireguard
next prev parent reply other threads:[~2017-10-26 2:52 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-25 22:43 Fixing wg-quick's DNS= directive with a hatchet Jason A. Donenfeld
2017-10-25 23:37 ` Kalin KOZHUHAROV
2017-10-26 0:55 ` Jason A. Donenfeld
2017-10-26 1:32 ` [PATCH] wg-quick: use bind mount for DNS when no openresolv Jason A. Donenfeld
2017-10-26 1:53 ` Kalin KOZHUHAROV
2017-10-26 1:54 ` Jason A. Donenfeld
2017-10-26 13:41 ` [PATCH v2] " Jason A. Donenfeld
2017-10-26 2:54 ` Eric Light [this message]
2017-10-26 3:21 ` Fixing wg-quick's DNS= directive with a hatchet Jason A. Donenfeld
2017-10-26 13:11 ` Jason A. Donenfeld
2017-10-26 16:56 ` Joe Doss
2017-10-26 17:24 ` Jason A. Donenfeld
2017-10-26 21:22 ` Jason A. Donenfeld
2017-10-27 10:07 ` Martin Hauke
2017-10-27 13:22 ` Jason A. Donenfeld
2017-10-27 14:47 ` Joe Doss
2017-10-27 14:51 ` Jason A. Donenfeld
2017-10-27 15:02 ` Jason A. Donenfeld
2017-10-27 15:38 ` Joe Doss
2017-10-27 22:04 ` Bruno Wolff III
2017-10-27 15:38 ` Joe Doss
2017-10-27 17:15 ` Jason A. Donenfeld
2017-10-27 17:52 ` Jason A. Donenfeld
2017-10-27 22:06 ` Daniel Kahn Gillmor
2017-10-28 2:24 ` Jason A. Donenfeld
2017-10-28 2:39 ` Jason A. Donenfeld
2017-10-28 14:35 ` Daniel Kahn Gillmor
2017-10-28 17:57 ` Jason A. Donenfeld
2017-10-29 12:21 ` Geo Kozey
2017-10-29 17:07 ` Jason A. Donenfeld
2017-10-30 11:58 ` Daniel Kahn Gillmor
2017-10-30 12:10 ` Daniel Kahn Gillmor
2017-10-29 22:06 ` Jason A. Donenfeld
2017-10-30 12:16 ` Daniel Kahn Gillmor
2017-10-31 10:49 ` Jason A. Donenfeld
-- strict thread matches above, loose matches on Subject: below --
2017-10-26 19:58 Geo Kozey
2017-10-26 21:11 ` Jason A. Donenfeld
2017-10-26 22:01 ` Geo Kozey
2017-10-26 22:19 ` Jason A. Donenfeld
2017-10-26 22:52 ` Geo Kozey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1508986442.581908.1151315616.1C72E382@webmail.messagingengine.com \
--to=eric@ericlight.com \
--cc=wireguard@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox