Commit 0cc65cc
committed
dns: 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.1 parent 3899e2e commit 0cc65cc
2 files changed
+8
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
342 | | - | |
| 342 | + | |
| 343 | + | |
343 | 344 | | |
344 | 345 | | |
345 | 346 | | |
| |||
380 | 381 | | |
381 | 382 | | |
382 | 383 | | |
383 | | - | |
| 384 | + | |
384 | 385 | | |
385 | 386 | | |
386 | 387 | | |
387 | | - | |
| 388 | + | |
| 389 | + | |
388 | 390 | | |
389 | 391 | | |
390 | 392 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
70 | | - | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| |||
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| 131 | + | |
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
| |||
0 commit comments