apenwarr/sshuttle — pull request #22 by Narthorn (2013-04-30 04:19:28+00:00)
Title: Add --dns-hosts command-line option.

The --dns switch adds firewall rules to intercept queries only for
nameservers found in resolv.conf ; This command-line option allows
the user to explicitly specify the nameservers to create firewall
redirection rules for.

This is useful when using a local DNS forwarder to redirect DNS queries
to different nameservers.

Example:

We can use sshuttle to access a private subnet 172.30.0.0/16, which hosts
a local DNS server resolving private domain names in that subnet.

Currently, the only way to be able to resolve those domain names is to use
the --dns switch. However, all DNS queries will then go through the remote
nameserver, which might not be desirable especially if said nameserver
does not know how to resolve every query.

One solution is to run a local DNS forwarder, which knows that the private
domain names can be resolved through a private IP, say 172.30.128.40.

Now, we can run :

sshuttle -r ssh.remoteserver.com -i 172.30.0.0/16 --dns-hosts 172.30.128.40

DNS queries for private domain names will get forwarded to 172.30.128.40,
intercepted by the firewall rule and sent through the tunnel to the nameserver
used by the remote endpoint (which might or might not be 172.30.128.40 !).

Notes :

* There is nothing preventing --dns-hosts from being used together with
--dns, in which case the nameservers found in resolv.conf will also be
added to the firewall rules as usual. This defeats the purpose of the
example, however.
There might be some weird use-case where this is useful ?

* Since there is no control over which nameserver the query gets sent to
after it has crossed the tunnel, the IPs specified in --dns-hosts are
irrelevant (as long as they are the same as found in the DNS forwarder
configuration). This might be a little counter-intuitive.