Repository navigation
Open
Labels
Help WantedNetworkManagerNetworkManager strikes againQuery RoutingConcerns how systemd-resolved selects interfaces and upstream resolvers.Won't Fix
Description
I'm experiencing DNS leakage using this script in which the IP addresses of my ISP's DNS servers are visible. Strangely, the IP addresses of my VPN's DNS servers are also visible. I'm running an OpenVPN server connected to a Comcast router.
From DNS Leak Test:
| IP | Hostname | ISP |
|---|---|---|
| 208.67.219.70 | m41.pao.opendns.com | OpenDNS, LLC |
| 208.67.219.14 | m4.pao.opendns.com | OpenDNS, LLC |
| 76.96.15.73 | sjos-cns05.nlb.sjc1.comcast.net | Comcast Cable |
| 208.67.219.29 | m21.pao.opendns.com | OpenDNS, LLC |
| ... | ... | ... |
systemd-resolve --status reports that everything is fine with the tunnel, so I assume I'm leaking traffic to some other interface:
Global
LLMNR setting: no
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNSSEC NTA: 10.in-addr.arpa
16.172.in-addr.arpa
168.192.in-addr.arpa
17.172.in-addr.arpa
18.172.in-addr.arpa
19.172.in-addr.arpa
20.172.in-addr.arpa
21.172.in-addr.arpa
22.172.in-addr.arpa
23.172.in-addr.arpa
24.172.in-addr.arpa
25.172.in-addr.arpa
26.172.in-addr.arpa
27.172.in-addr.arpa
28.172.in-addr.arpa
29.172.in-addr.arpa
30.172.in-addr.arpa
31.172.in-addr.arpa
corp
d.f.ip6.arpa
home
internal
intranet
lan
local
private
test
Link 4 (tun0)
Current Scopes: DNS
LLMNR setting: yes
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: no
DNSSEC supported: no
Current DNS Server: 208.67.220.220
DNS Servers: 208.67.222.222
208.67.220.220
DNS Domain: ~.
Link 3 (wlp4s0)
Current Scopes: DNS
LLMNR setting: yes
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: no
DNSSEC supported: no
Current DNS Server: 75.75.76.76
DNS Servers: 75.75.75.75
75.75.76.76
2001:558:feed::1
2001:558:feed::2
DNS Domain: ~.
hsd1.ca.comcast.net
Link 2 (enp0s31f6)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: no
DNSSEC supported: no
OpenVPN client configuration:
...
script-security 2
setenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
up /etc/openvpn/update-systemd-resolved
down /etc/openvpn/update-systemd-resolved
down-pre
# Prevent DNS leakage.
dhcp-option DOMAIN-ROUTE .
I know very little about networking, so I apologize if this is a trivial issue. Any insight would be greatly appreciated.
Reacted by Gullumluvl, Thayne McCombs, Martin and Joshua Ji
Metadata
Metadata
Assignees
Labels
Help WantedNetworkManagerNetworkManager strikes againQuery RoutingConcerns how systemd-resolved selects interfaces and upstream resolvers.Won't Fix
Activity
piotr-dobrogost commentedon Dec 31, 2018
I guess it is due to
DNS Domain: ~.set on linkwlp4s0(wireless I guess).Is there any reason for this setting?
If not then removing it should not break anything and prevent leakage here.
jonathanio commentedon Jan 3, 2019
DNS Domain: ~.is the search configuration - especiallysystemd-resolvedhas been told that the servers configured on this link are responsible for searches on all domains (.is in effect the root domain, so all domains will match). Yourtun0interface has the same search query, so you will be sending out requests to via interfaces to both sets of DNS servers and the first successful response back will be the one provided to your application.My current configuration is:
As you can see, I do not have any
DNS Domainconfiguration by default, so when I enable a VPN withDOMAIN-ROUTE .it will take over. Something on your system is overriding this configuration for some reason. What do you use to set up your networking configuration on your system?piotr-dobrogost commentedon Jan 3, 2019
That's interesting as it's Network Manager which likes to set
~.according to systemd/systemd#10125jonathanio commentedon Feb 8, 2019
I have never been a fan of NetworkManager - much like systemd at times, it tries to do too much with a number of questionable decisions under the surface which often result in difficult to detect and resolve failure modes. There is, as in this example, absolutely no reason to demand for
systemd-resolved.servicethat all DNS queries should be always directed to the local DNS server on the LAN when other, better, configurations may be provided.Ultimately, and as you suspected, the reason why it works in your case with
dhcp-option DOMAIN-ROUTE .on your VPN connection is that systemd, when faced with multiple possible options to route a query (explicit, or implicit), will send the same query to all servers. The result that is returned is either the first successful response (which can lead to some unpredictability without proper routing) or the last failed response (i.e. no server could resolve). With both links configured for~.you'll probably always get one failure (LAN) and one success (VPN), so the success will be returned.I'm uncertain how to remove
~.from your LAN interface, but ultimately this will help you if you can manage this configuration.bohlstry commentedon Feb 19, 2019
If have written a Bash-Script to get rid of
~.from all non-VPN-devices, if VPN is active. If VPN goes down,~.is written to the default device (identified by the default route).Important: as mentioned above,
dhcp-option DOMAIN-ROUTE .is required in VPN config.Save the following code at:
/etc/NetworkManager/dispatcher.d/10-check-dns-domain, don't forget to give execute rights.To check the log, you can use
journalctl -f -t check-dns-domaindannyk81 commentedon May 10, 2019
Thanks @bohlstry for sharing the script, works great for me.
I tried every possible way to get rid of
~.from non-VPN (Wifi) device but it keeps coming back, I suppose by NetworkManager (?)Using this method seems like the only way to fix DNS leakage...
EDIT: The script handles the case of a single VPN well, however I'm normally connected to multiple VPNs, so when I disconnected from just one it pushes back
~.EDIT 2: slightly revised version of @bohlstry's script, works in case there are multiple VPN connections:
Edu4rdSHL commentedon May 19, 2019
Hello, you just need to use the following option in your .network file:
The "leakage" that you're getting is because if you don't specify that option, the DNS servers received from the DHCP server will be used and take precedence over any statically configured ones.
See https://www.freedesktop.org/software/systemd/man/systemd.network.html#%5BDHCP%5D%20Section%20Options
Add details about DNS leakage with NetworkManager for #59
jonathanio commentedon May 19, 2019
@bohlstry and @dannyk81,
Thank you both for your scripts. It's still a shame that NetworkManager has not looked into this and doesn't seem to be any closer to resolving this regression. I'm much more a fan of systemd-networkd, despite even its issues at times.
Nonetheless, I'll keep this open waiting for a resolution from NetworkManager. In the meantime, I've added into the documentation notes about the issue of leakage when using NetworkManager, and linked to this issue.
Edu4rdSHL commentedon May 19, 2019
I don't understand what have to be network-manager in a script for systemd-resolved... network-manager provides their own DNS resolver implementation, nothing to be with systemd-resolved.
vaskokj commentedon Jan 8, 2020
How do I go about removing the
DNS Domain: ~.from my primary connection? I have no idea how that is even getting there in the first place? Is this something that my DHCP server adding this? If not, how do I go about removing it?nijave commentedon Apr 21, 2020
systemd-resolve --statusorresolvectl statusdepending on what version of systemd you have. Look for the Link # in the output with DNS Domain seti.e. link 2 here
Run
The
0sets it back to nothing which effectively removes any entriesDemiMarie commentedon Jun 24, 2020
Have the NetworkManager bugs been fixed? Another approach is to use nftables rules to block all non-VPN traffic. @jonathanio what do you think of this option?
coderonline commentedon Oct 21, 2020
I have had the same issue with a Fritz!box, because these seem to push DNS settings via DHCP and that is where the
~.DNS Domain came from in my case. It makes systemd-resolved send DNS queries out on both network-interfaces and takes the first to answer. That is the DNS leak I wanted to get rid of.I was able to track this further down and found in the Arch-Wiki a way to disable Domains from the Fritz!Box altogether (this may not be what you want, but for me its okay, because I can still use
host something.fritz.box 192.168.178.1to find devices in my local network). Then I had trouble to start VPN and found this issue with a working solution for the second issue "Call failed: Link tun0 is managed.".With the following two configuration files I got it working for me :)
How to get it working
On my client I have now two
.network-files for systemd:/etc/systemd/network/enp8s0.network/etc/systemd/network/tun.network:and then restarted
systemctl restart systemd-networkdandsystemctl restart systemd-resolved, reconnected to my network and finally restarted my VPN withopenvpn-client@someserverand now have no~.on enp8s0 any more and that is the best solution, I think.FYI: "how to remove ~. from a specific interface"
With the configuration above
resolvectl domain enp8s0 fritz.box ~.would re-add the unwanted configuration temporarily andresolvectl domain enp8s0 fritz.boxwould remove only the~.tmccombs commentedon Nov 23, 2020
Wouldn't removing "~." from my hardware interface, cause DNS resolution to fail (or at least not use those resolvers) if the VPN isn't active? Is there a way to remove the ~. from other interfaces only while the vpn is active? or at least tell systemd-resolved to try the dns resolvers for tun0 before any other interfaces?
tmccombs commentedon Nov 23, 2020
It also looks like update-systemd-resolved doesn't call
SetDefaultRoute. Should there be some way to configure this to set that?piotr-dobrogost commentedon Nov 23, 2020
Users of NetworkManager might be interested in the recent fix regarding this issue – dns: fix handling default routing domains with systemd-resolved (https://github.com/freedesktop/NetworkManager/commit/ee9fab03613e30f818d56217a968d1fabd5ea8d7)
jan-swiecki commentedon May 24, 2022
Any idea how to install newest NM (network manager) on Ubuntu. I'm using 20.04 LTS, but maybe there is a universal way to do it? It would seem that I need to build it from source and somehow seamlessly replace apt-installed system NM with newly built version, but I'm unsure how to do replacing step.
tomeon commentedon Jul 13, 2023
@tmccombs
Please see #110 for support for (among other things) controlling
SetLinkDefaultRoute.tomeon commentedon Jul 13, 2023
Given #59 (comment), is it time to close this issue?
tomeon commentedon Sep 8, 2023
The NetworkManager fix mentioned above landed in NetworkManager release 1.26.6.
tomeon commentedon Sep 8, 2023
Also, AFAICT, the latest Ubuntu LTS ships a version of NetworkManager that contains the fix: