Jump to: navigation, search

Secondary DNS Resolver

Secondary DNS Resolver[edit]

Introduction[edit]

By Whonix default, Tor is used for DNS resolution. If you suspect a Tor exit relay to tamper with DNS, you can get a second opinion from another non-Tor DNS server. This may also be useful, in special cases if you want to resolve types of DNS over Tor, which are unsupported by Tor itself, such as MX (required for some Mixmaster servers over Tor) or DNSSEC.

It's recommended against to use non-Tor DNS resolvers for an extended amount of time. Although it's technically possible to completely replace DNS resolution (not using Tor for DNS resolution anymore), it's recommended against. That would add too much power to a single DNS server. Using a permanent DNS server is recommended against just as using a permanent Tor exit relay is recommended against.

Note, that even if you correctly set up all settings, it might happen that this won't work. Sometimes Tor or the DNS server causes a timeout. This gets even worse, when you additionally tunnel the DNS request through an additional proxy (for example: Tor -> JonDonym -> DNS server).

Read first: Stream Isolation.

In the chapters below are examples how to use authenticated DNS (DNSSEC) or encrypted DNS (DNSCrypt or httpsdnsd). https://cloudns.com.au seems to support both, authentication (DNSSEC) and encryption (DNSCrypt).

Required knowledge:

  • Difference between encryption and authentication.
  • All traffic from Whonix-Workstation and Whonix-Gateway is routed over Tor. [1] [2] [3] [4] (<-- read the footnotes)

Related FAQ entries:

Authenticated DNS over Tor[edit]

DNSSEC over Tor[edit]

Example with CZ.NIC Labs DNS resolver[edit]

source for this chapter: CZ NIC LABS

The CZ.NIC Labs DNS resolver has been chosen as an example. Feel free to use and other DNS resolver at your own choice.

Installation[edit]

Everything inside your Whonix-Workstation.

Install unbound and socat.

sudo apt-get install unbound socat

Open /etc/unbound/unbound.conf.

sudo nano /etc/unbound/unbound.conf

Add the following lines.

#tcp-upstream goes under "server:" section
    tcp-upstream: yes

#put forward-zone somewhere at the end of file
forward-zone:
    name: "."
    forward-addr: 0.0.0.0@5353

Starting[edit]

Open a terminal and start socat.

socat TCP4-LISTEN:5353,bind=localhost,reuseaddr,fork SOCKS4A:10.152.152.10:217.31.204.130:53,socksport=9150

Open another terminal tab and restart unbound.

sudo service unbound restart

Using[edit]

Test with dig.

dig +dnssec nic.cz @localhost

Please refer to upstream documentation on how to interpret the DNSSEC test results.

Encrypted DNS over Tor[edit]

Introduction[edit]

This is different from DNSSEC.

DNSCrypt[edit]

Might not work anymore. More info:

Everything inside your Whonix-Workstation.

As the official DNSCrypt website states, DNSCrypt is available for many platforms, including Linux.

DNSCrypt has nothing to do with DNSSEC, although it works well together.

These instructions completely replace Tor's DNS resolver with a dnscrypt-enabled resolver for all users and the whole system. Not recommended for a longer amount of time, see warning above. Some hints are included how to do it only for a specific user account.

(1). Download the dnscrypt source code and unpack. You have to install libsodium before compiling it. Then, get into the dnscrypt directory cd dnscrypt-proxy-.... Configure ./configure, make "make, and install make install.

(2). Start dnscrypt-proxy. [5] [6] [7] [8] [9] [10]

sudo dnscrypt-proxy --tcp-only

(3). Edit your /etc/resolv.conf nano /etc/resolv.conf, comment out everything and add nameserver 127.0.0.1.

(4). Check if it's working. See test pages. Try sudo pkill -STOP dnscrypt-proxy and check that DNS resolution doesn't work any more. To resume, type sudo pkill -CONT dnscrypt-proxy.

(5). To shut it down you can use sudo pkill dnscrypt-proxy and don't forget to revert the changes in /etc/resolv.conf.

httpsdnsd by JonDos[edit]

Introduction[edit]

Source: anonymous-proxy-servers.net and also use it as a more verbose tutorial, but keep in mind that their tutorial is JonDonym specific, while this tutorial is Tor specific.

Installation[edit]

Everything inside your Whonix-Workstation.

Install dependencies.

sudo apt-get install libnet-ssleay-perl libnet-server-perl libnet-dns-perl libxml-simple-perl liblog-log4perl-perl

Download httpsdnsd. (See source above in case download link changed.)

wget https://anonymous-proxy-servers.net/downloads/httpsdnsd.tar.bz2

Unpack.

.    

Go into the httpsdnsd folder.

cd httpsdnsd

Install httpsdnsd. [11]

sudo install.sh

Add a new user for httpsdnsd.

sudo adduser --system --disabled-password --group httpsdns_daemon

Editing /etc/resolv.conf is not required. (You still could out comment everything against DNS leaks.)

Create a firewall script.

nano dns-fw.sh

Insert these firewall rules.

# Flush old rules
iptables -F
iptables -t nat -F
iptables -X

# Redirect DNS traffic to httpdnsd.
iptables -t nat -A OUTPUT -p udp -m owner --uid-owner anonuser --dport 53 -j REDIRECT --to-ports 4053

# Accept connections to the httpdnsd.
iptables -t filter -A OUTPUT -p udp -m owner --uid-owner anonuser --dport 4053 -j ACCEPT

# Reject all other traffic for anonuser.
iptables -t filter -A OUTPUT ! -o lo -m owner --uid-owner anonuser -j REJECT

Install Privoxy. [12]

sudo apt-get install privoxy

Open the privoxy configuration file.

nano /etc/privoxy/config

Add the following to your privoxy configuration file.

# Theoretically you can tunnel through any
# http or socks proxy. Local or remote proxy.
# Inside Whonix-Workstation, due to design,
# everything will be tunneled through Tor first.

# Using Tor's socks5 proxy, running on Whonix-Gateway. 
# Change the port, see above...
forward-socks5 / 10.152.152.10:9112 .

# Another example using a http proxy.
# (In this case, JonDo running on localhost.)
# forward / 127.0.0.1:4001

Restart privoxy to enable the changes.

sudo /etc/init.d/privoxy restart

Privoxy is now listening on 127.0.0.1:8118. [13]

Starting[edit]

Run httpsdnsd. [14] [15] [16] [17]

sudo httpsdnsd --https_proxy_port=8118 --runasdaemon

Activate the firewall. Shouldn't show any errors.

sudo ./dns-fw.sh

Using[edit]

Open a console and switch to anonuser.

su anonuser

Resolve DNS.

nslookup check.torproject.org

Footnotes[edit]

  1. Since Whonix 0.2.1 also the Whonix-Gateway traffic is routed over Tor. This prevents telling the world that the user is a Whonix user.
  2. To preserve anonymity of activities the user is doing inside Whonix-Workstation, it would not be required to torify Whonix-Gateway's own traffic.
  3. For your interest: if you were to change DNS settings on Whonix-Gateway in /etc/resolv.conf, this would only affect Whonix-Gateways's own DNS requests issued by applications using the system's default DNS resolver. Actually, by default, no applications issuing network traffic on Whonix-Gateway use the system's default DNS resolver. All applications installed by default on Whonix-Gateway issuing network traffic (apt-get, whonixcheck, timesync) are explicitly configured (or forced by uwt wrappers) to use their own Tor SocksPort (see Stream Isolation).
  4. Whonix-Workstation's default applications are configured to use separate Tor SocksPort's (see Stream Isolation), thus not using the system's default DNS resolver. Any applications on Whonix-Workstation, not configured for stream isolation (for example nslookup), will use the default DNS server configured in Whonix-Workstation in /etc/network/interfaces, which is Whonix-Gateway. Those DNS requests will be redirected to Tor's DnsPort by Whonix-Gateway's firewall. (Therefore Whonix-Gateway's /etc/resolv.conf does not affect Whonix-Workstation's DNS requests.
  5. --tcp-only is required since Tor does not support UDP. The UDP DNS request will immediately get truncated reply and a RFC-compliant resolver should repeat same query via TCP in this case. This is the case for Ubuntu's default DNS resolver. You can get some more information on UDP/TCP/DNS on the unrelated redsocks website.
  6. To start it later in background (after debugging) add --daemonize.
  7. --help to see all options.
  8. Start up takes a few seconds "INFO Generating a new key pair", this is normal, wait. Until it's done, DNS will not work.
  9. --user=username can and should be used to start the dnscrypt-proxy under a specific user account.
  10. Since this instructions completely replace Tor's DNS resolver with opendns's dnscrypt for all users and the whole system, you could add --local-port=5800 to let dnscrypt-proxy listen on port 5800. You would be able to add iptables rules to redirect only the DNS requests of a specific user account to the dnscrypt resolver, you can get some hints how to do that in the httpsdnsd by JonDos chapter below, which would be a very similar setup.
  11. It contains also a uninstall.sh, if you want to uninstall it later.
  12. torproject.org Wiki Version 95 of this site contains a working example using Polipo. Changed later to Privoxy, because Privoxy can be useful for other tasks as well. (Incoming: TransPort, http proxy; forwarding: http and socks.)
  13. For debugging you can enter this IP/port into Tor Browser as http proxy and try if you can still reach check.torproject.org. Deactivate after testing.
  14. For debugging, kill httpsdnsd and drop the --runasdaemon.
  15. Run httpsdnsd --help or man httpsdnsd for help.
  16. Httpsdnsd will by default listen on localhost port 4053 for DNS queries.
  17. --https_proxy_port=8118 will redirect traffic to port 8118, where Privoxy is listening. This is necessary because Tor offers a socks proxy and httpsdnsd requires a http proxy. Privoxy translates from http to socks.

Random News:

Know iptables? Want to contribute? Check out possible iptables improvements. Say hello in development forum.


Impressum | Datenschutz | Haftungsausschluss

https | (forcing) onion
Share: Twitter | Facebook | Google+
This is a wiki. Want to improve this page? Help welcome, volunteer contributions are happily considered! See Conditions for Contributions to Whonix, then Edit! IP addresses are scrubbed, but editing over Tor is recommended. Edits are held for moderation. Whonix (g+) is a licensee of the Open Invention Network. Unless otherwise noted above, content of this page is copyrighted and licensed under the same Free (as in speech) license as Whonix itself.