Skip to content

Intercept DNS requests sent by systemd-resolved.#552

Merged
brianmay merged 2 commits intosshuttle:masterfrom
skuhl:systemd-resolved
Nov 4, 2020
Merged

Intercept DNS requests sent by systemd-resolved.#552
brianmay merged 2 commits intosshuttle:masterfrom
skuhl:systemd-resolved

Conversation

@skuhl
Copy link
Contributor

@skuhl skuhl commented Oct 25, 2020

Previously, we would find DNS servers we wish to intercept traffic on
by reading /etc/resolv.conf. On systems using systemd-resolved,
/etc/resolv.conf points to localhost and then systemd-resolved
actually uses the DNS servers listed in
/run/systemd/resolve/resolv.conf. Many programs will route the DNS
traffic through localhost as /etc/resolv.conf indicates and sshuttle
would capture it. However, systemd-resolved also provides other
interfaces for programs to resolve hostnames besides the localhost
server in /etc/resolv.conf.

This patch adds systemd-resolved's servers into the list of DNS
servers when --dns is used.

Note that sshuttle will continue to fail to intercept any traffic sent
to port 853 for DNS over TLS (which systemd-resolved also supports).

For more info, see:
sshuttle issue #535
https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html
systemd/systemd#6076

Previously, we would find DNS servers we wish to intercept traffic on
by reading /etc/resolv.conf. On systems using systemd-resolved,
/etc/resolv.conf points to localhost and then systemd-resolved
actually uses the DNS servers listed in
/run/systemd/resolve/resolv.conf. Many programs will route the DNS
traffic through localhost as /etc/resolv.conf indicates and sshuttle
would capture it. However, systemd-resolved also provides other
interfaces for programs to resolve hostnames besides the localhost
server in /etc/resolv.conf.

This patch adds systemd-resolved's servers into the list of DNS
servers when --dns is used.

Note that sshuttle will continue to fail to intercept any traffic sent
to port 853 for DNS over TLS (which systemd-resolved also supports).

For more info, see:
sshuttle issue sshuttle#535
https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html
systemd/systemd#6076
@skuhl
Copy link
Contributor Author

skuhl commented Oct 25, 2020

On second thought, we should probably just use resolv.conf on the server (that has been working fine) and resolv.conf + the systemd-resolved's file on the client (which is where the issue is). I'll update this with another commit later.

The server should just read from resolv.conf to find DNS servers to
use. This restores this behavior after the previous commit changed it.

The client now reads both /etc/resolv.conf and
/run/systemd/resolve/resolv.conf. The latter is required to more
reliably intercept regular DNS requests that systemd-resolved makes.
@skuhl
Copy link
Contributor Author

skuhl commented Nov 4, 2020

I fixed the issue mentioned in my previous comment.

@brianmay brianmay merged commit 9b036fc into sshuttle:master Nov 4, 2020
@skuhl skuhl deleted the systemd-resolved branch November 4, 2020 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants