DNSCrypt with BIND9 on Debian

bind

I'm stuck. I'm trying to leverage DNSCrypt in the wake of the recent changes with ISP laws in the USA. Here's my setup:

  • Two Debian Jessie servers with BIND 9.9.5-9, fully patched (using stable branch)
  • dnscrypt-proxy 1.9.4 (compiled from source with libsodium18 1.0.12)

For testing, I'm just trying to use the OpenDNS resolvers with DNSCrypt. My goal is to eventually send my traffic to a VPS I use to then forward to my desired DNS servers. It's important that the local BIND servers are able to respond to queries for internal DNS as well. I do have a zone I need to be able to resolve internally.

I'm executing the following command to start dnscrypt-proxy:

dnscrypt-proxy -R cisco -a 127.0.1.2 -d -L /usr/share/dnscrypt-proxy/dnscrypt-resolvers.csv -l /var/log/dnscrypt-proxy -m 6 -p /var/run/dnscrypt-proxy

(cisco is pre-defined in the included list of compatible resolvers. This is the OpenDNS servers).

I can test that this works with the following command:

dig @127.0.1.2 serverfault.com

It returns with a proper lookup.

I then configure BIND with the forwarder of 127.0.1.2 and this is where it stops working. If I now run a dig command against 127.0.0.1 I get a SERVFAIL error, but the dig against 127.0.1.2 still works.

In addition to this, performing a pcap from my router shows plenty of outbound DNS queries over port 53 (instead of the 443 used by dnscrypt) to the various root servers.

So ultimately:

  • What do I need to do to get BIND9 to properly forward queries through the DNSCrypt tunnel?
  • How do I disable BIND9 from sending data to the root servers (I've try configuring forward only; and recursion no; but that doesn't seem to work)?

Best Answer

recursion no is not what you want as forwarding is essentially considered a special case of recursion.

With forwarders defined and forward only BIND should send all recursion queries to your forwarders.

Ie, something like the following in options ought to work:

recursion yes;
forwarders { 127.0.1.2; };
forward only;

Regarding the SERVFAIL errors, do check the BIND logs to see what is actually going on. named-checkconf -zj may also be useful for validating the configuration itself.

That said, I do have an idea that may explain the issues.

If you must use OpenDNS, make sure you disable DNSSEC validation in BIND as the OpenDNS servvice is incompatible with DNSSEC.
The idea of censoring (changing) DNS data is fundamentally at odds with validating authenticity of DNS data, so I don't expect this to change.

Related Topic