When an application connects to a server on the Internet, it needs to resolve hostnames (i.e., www.antagonism.org) to IP addresses. To do this, the application sends the hostname to a DNS server for resolution. The DNS server sends the IP address for the hostname back to the application. This is normal business and is good for every day use. However, it is bad for business when you wish to conduct anonymous connections.
Let's examine an example of why DNS leaks are bad for anonymous connections. Let's say you exist in an oppressive regime and wish to browse a web site on the rergime's forbidden list. Your computer needs to resolve the hostname for forbidden web site, so it sends a request to its DNS resolver. The regime true to its repressive nature is monitoring the DNS servers for requests for forbidden sites. It correlates the request for the banned site with your IP address and stops by to arrest you for violating the law even though you made the connection using an anonymizing tool, such as Tor .
There are a couple of solutions to the issue of DNS leaks. The most common is the use of a SOCKS proxy. The second solution is to send your DNS requests through the Tor network. Due the possiblity of applications either not supporting SOCKS or implementing it poorly, I highly recommend you employ both solutions.
A SOCKS proxy operates as a transparent proxy to allow client-server applications to reach resources which may not be accessible otherwise. The Tor application provides a SOCKS proxy (listening by default on localhost:9050) to allow applications which support SOCKS to access the Tor network.
When using SOCKS 4a, you are able to provide hostnames, which Tor will resolve through the Tor network. Thus, your DNS requests are anonymized and the problem mentioned above is avoided. To allow those applications which support SOCKS to access TOR, one simply needs to configure the application to use the SOCKS proxy which the Tor application runs or a HTTP proxy which supports SOCKS (i.e. privoxy or polipo ). The following page covers how to configure many applications with Tor in order to prevent DNS leaks.
There are several problems which exist with the above solution. First, not all applications support SOCKS. This means you can not anonymize their DNS requests with the above method. Second, even though an application claims to support SOCKS, it may implement it incorrectly and still leak DNS requests. This page details how to determine if your application using SOCKS still leaks DNS requests. Lastly, the above method requires you to hand configure each and every application. While this may be a viable solution for a handful of machines, as the number of machines grows larger, the solution becomes more unwieldly.
Transparently proxying DNS requests will resolve the problems mentioned with the previous solutions. It will handle DNS requests for applications which either do not support SOCKS or implement it poorly and since it transparently proxies the requests, you do not have to configure each individual machine. There are two methods to do this. The first is to use your firewall software (iptables, pf) to redirect DNS requests from your network to dns-proxy-tor (note the previous link is only accessible through Tor). The second method is to use the your firewall software to redirect DNS requests from your network to the DNSPort of a server running Tor version 0.2.0.1-alpha or later. Since the 0.2.x series is still not considered stable, this example will cover the former.
For purposes of this example, the following assumptions are in effect:
In the Tor 0.1.x series, we need a proxy server to handle DNS requests which we wish to remain anonymous. dns-proxy-tor is just such a proxy server. With Tor 0.2.x, such a proxy server is not needed. This page covers how to make DNS requests anonymous with Tor 0.2.x. Below are instructions on how to install dns-proxy-tor .
% wget -c http://p56soo2ibjkx23xo.onion/trans-proxy-tor-0.1.0.tar.gz % tar zxvf trans-proxy-tor-0.1.0.tar.gz % cd trans-proxy-tor-0.1.0 % sudo cp dns-proxy-tor /usr/local/bin/dns-proxy-tor % sudo chmod 755 /usr/local/bin/dns-proxy-tor % sudo chown root.root /usr/local/bin/dns-proxy-tor
The router will need the changes below added to its torrc file. With these changes made, the router will be able to capture DNS traffic sent through it, redirect it to dns-proxy-tor and from there send the DNS request through the Tor network.
VirtualAddrNetwork 10.192.0.0/10 ControlPort 9051 CookieAuthentication 1 TransPort 9040 TransListenAddress 127.0.0.1 TransListenAddress 192.168.1.1
Before you make these changes to torrc, be sure you understand what the options do. The torrc options configured above do the following:
The Tor manual covers these options and many more. On making these additions to torrc, you need to restart Tor. The below example demonstrates how to restart Tor for RedHat systems.
% sudo /sbin/service tor restart
Once you have Tor configured, you need to start dns-proxy-tor . The example below demonstrates how to start dns-proxy-tor .
# dns-proxy-tor -b 192.1681.1.1:53 -t 127.0.0.1:9051 -s 127.0.0.1:9050 \ -c /var/lib/tor -k /var/lib/tor -u tor:tor -p /var/run/dns-proxy-tor.pid
Before starting dns-proxy-tor , make sure you understand what the command does. The dns-proxy-tor options configured above do the following:
These options and more may be accessed by reading the Perl documentation associated with dns-proxy-tor . This documentation may be read by running the following commands.
% perldoc /usr/local/bin/dns-proxy-tor
Below is an example of an iptables script which would handle the redirection of DNS packets sent to external networks to dns-proxy-tor . Note Do not implement this directly on your router unless you understand completely what the commands do. I am not responsible for mistakes which you make on your system by blinding implementing this script.
<!-- end /tail.shtml -->