[Dnsmasq-discuss] Improve privacy by randomly selecting DNS server from a whitelist

Sam Kuper sam.kuper at uclmail.net
Tue Oct 11 19:08:24 BST 2016


On 10/10/2016, /dev/rob0 <rob0 at gmx.co.uk> wrote:
> On Mon, Oct 10, 2016 at 02:53:44PM +0100, Sam Kuper wrote:
>> I was setting up an OpenWRT router recently, and wanted to be able
>> to improve the privacy of DNS requests made from that router and
>> from the PCs on the LAN.
>>
>> By handing off all the requests to *one* DNS provider, whether
>> that provider is the ISP, or Google, or someone else, privacy is
>> obviously compromised: that provider can very easily record *all*
>> the DNS requests sent via that router
>
> The ISP could, and they could do it regardless of the DNS forwarder
> chosen.  The ISP could even redirect all outbound queries to their
> own resolver, and through the magic of NAT, reply as the destination
> resolver.

Thanks for pointing this out!

Would DNSCrypt and/or DNSSEC protect against this? (I intend to learn
more about both in due course, but haven't got far enough with this
yet to be entirely confident in my estimation of the answer to that
question, sorry...)

>> (except, perhaps, in cases where the client is configured not
>> to seek a DNS forwarder on the LAN).
>
> Redirection covers this.  Just as with many hotels and hotspots,
> enter ANY IP address as your resolver, and it will "work", through
> the ISP's resolver.

Ditto.

> There are ways to "defeat" such an attack (where "defeat" means to
> detect it and to break your own ability to resolve names, so it's
> certainly not a clear victory.)  More on that below. [...]
>
>> Fortunately, there are numerous public DNS servers that I trust,
>> more or less, to return accurate results to DNS queries. I'll call
>> this the "semi-trusted set".
>>
>> Therefore, it occurred to me that a better option than simply
>> relying on *one* provider, would be to supply the router with a
>> list of IP addresses for the servers in the semi-trusted set, and
>> then, for each DNS query the router cannot answer from its own DNS
>> cache, have the router send the query to a randomly selected DNS
>> server from that list.
>
> This functionality does not exist in dnsmasq at this time.  But a
> Linux-specific way to do it would be to DNAT some of the queries
> using the "statistic" match.  See "iptables -m statistic -h" and the
> iptables-extensions(8) manual.

Cool suggestion. I wasn't aware of the "statistic" match options in
iptables. Will look into this more. On the face of it, it looks a bit
more fragile, and more prone to my making an error in setting it up,
than having a suitable capability present in Dnsmasq would be; but as
the latter doesn't presently exist, iptables may well be my best bet
:)

>> That way, the clients would (I hope) receive trustworthy replies,
>> and none of the providers would be able to record more than a
>> random subset of the requests. This might come at the cost of
>> slightly slower average response times for DNS queries, but for my
>> use case, this would be perfectly acceptable.
>>
>> While searching for a way to do this, I learned that Dnsmasq is
>> included by default in OpenWRT. Learning, in turn, about Dnsmasq,
>> made me optimistic that it might be possible to configure or extend
>> Dnsmasq to achieve the desired functionality described above.
>>
>> I would be grateful to know:
>>
>> - whether, and if so, why, the desiderata I described are a Bad
>> Idea. (I hope not, but it's always good to have a sanity check.)
>
> It doesn't seem important to me, but I am a "full control" control
> freak who runs his own recursive resolver.  And that's how I defeat
> the redirection attacks.
>
> See, a recursive resolver makes queries directly to the various
> authoritative NS hosts.  Those queries do not have the "RD" bit
> (recursion desired) set, and the resolver will only accept replies
> which have the "AA" bit (authoritative) set.
>
> Replies from a recursive resolver do not have AA, so when my ISP gets
> that hare-brained idea again, to redirect queries to their broken
> resolver, immediately, I know.  (Because nothing resolves.)

Thanks for this, too. I was hoping for a solution that was more
lightweight than running my own recursive resolver, but it's an option
I will definitely consider.

> DNSSEC validation also helps here.  The root and most top-level zones
> are signed, and if those signatures are missing or broken, again, I
> will see that nothing resolves.

Understood.

>> - whether anyone on this list knows of a way to achieve the desired
>> functionality by configuring existing software available within
>> OpenWRT, and if so, how. (Maybe there's a package, or a setting,
>> that does exactly what I'm after, and I've just never heard of it.)
>> Please reply to me off-list if the answer is not relevant to
>> Dnsmasq.
>
> The iptables statistic match is probably not in stock openwrt, so
> that must be installed.

I think you are correct. On a stock OpenWRT CLI:

# iptables -h | grep -i statistic | wc -l
0

> What I do, and have posted before on this list about, is to run
> dnsmasq for DHCP and local names, using a local resolver (on an
> alternate port, because dnsmasq gets ports 53) as its one upstream
> server.
>
> I use BIND named(8) for this, with a simple configuration.  If you
> are interested in this and can't find it in the list archives, post
> again.  You won't have named in stock openwrt, so you would need to
> install it.

Thanks again. I guess this is the relevant thread:

http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2013q2/007320.html

> Any other recursive resolver could do it also; the only catch is that
> it must be able to bind on an alternate port.  I like BIND, but on an
> embedded platform it's probably much bigger than others.  Look at
> pdns-recursor and unbound.

Will do. Cheers!



More information about the Dnsmasq-discuss mailing list