You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
After connected to VPN, systemd-resolve still use ISP's DNS server( which was polluted because of regulation ) #6076
Ubuntu 17.04 Linux version 4.10.0-21-generic (buildd@lgw01-12) (gcc version 6.3.0 20170406 (Ubuntu 6.3.0-12ubuntu2) ) #23-Ubuntu SMP Fri Apr 28 16:14:22 UTC 2017
Because of the Internet regulation, ISP's DNS server can not resolve some domian correctly( for example www.google.comwww.youtube.com ). Under normal conditions, we use vpn and set the vpn as default internet gateway when needed to access above website.
When I start to use Ubuntu 17.04, It is found that when connected to vpn, all internet package transfer through vpn except domain name resolve. Infact, VPN server had tell correct DNS server IP address through DHCP. But systemd-resolve still use ISP's polluted resolve.
At /etc/resolv.conf, I found that DNS resolve had be taken over by systemd-resolve. There can't find any easy way to tell systemd-resolve to use a specified DNS server, or disable any DNS server according " systemd-resolve --help ".
Willing to accept guidance to correct my use of systemd-resolve,
If you can, Please add some necessary feature to systemd-resolve to solve such problem,
In case of bug report: Expected behaviour you didn't see
…
In case of bug report: Unexpected behaviour you saw
…
In case of bug report: Steps to reproduce the problem
…
Reacted by Laurens Bosscher, Maciej, Calamari, Ilya Baryshnikov, David, RNZ, Avindra Goolcharan, Victor Krapivensky, Leon Bogaert, Flyffies and 45 more
Hmm, not sure I follow. How exactly did you configure your DNS? What does "systemd-resolve --status" report about the DNS servers? Is /etc/resolv.conf a file or a symlink?
zhoub@ubuntu:\~$ ll /etc/resolv.conf
rwxrwxrwx 1 root root 29 Jun 6 09:35 /etc/resolv.conf -> ../run/resolvconf/resolv.conf
zhoub@ubuntu:~$ cat /etc/resolv.conf
\# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
\# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
\# 127.0.0.53 is the systemd-resolved stub resolver.
\# run "systemd-resolve --status" to see details about the actual nameservers.
nameserver 127.0.0.53
zhoub@ubuntu:~$ systemd-resolve --status
Global
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 6 (ppp0)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: allow-downgrade
DNSSEC supported: yes
Link 2 (ens33)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: allow-downgrade
DNSSEC supported: no
DNS Servers: 192.168.83.2
DNS Domain: localdomain
zhoub@ubuntu:~$ ping www.google.com
PING www.google.com (93.46.8.89) 56(84) bytes of data.
^C
--- www.google.com ping statistics ---
106 packets transmitted, 0 received, 100% packet loss, time 107507ms
ping failed, 93.46.8.89 is incorrect , ISP's DNS server resolve it to 93.46.8.89 because of Internet regulation. VPN's DNS Server resolve it to 172.217.26.36, which can ping successfully.
Can confirm the same effect with a OpenVPN connection.
Link 8 (tun0)
Current Scopes: DNS
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 172.20.0.50
172.20.0.14
Link 3 (wlan0)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 192.168.192.1
DNS Domain: net
Running "systemd-resolve internal.name.local" fails to find it (it only tries the 192.* DNS server), running "systemd-resolve -i tun0 internal.name.local" resolves the name correctly (via 172.* DNS server), but no applications actually supply that interface, naturally.
Systemd version 232
Ubuntu 17.04
Currently I have to workaround this by overwriting the /etc/resolv.conf file each time I connect to the VPN, but even that now stops working as some apps use the systemd-resolv directly if it is available.
@mikken, that script you're telling us to use is 400 lines long. What does it do? Any bugs? Is it safe or does it expose our systems to vulnerabilities? Will it break something else? Why do we need a 400 lines long script (and then to do even more stuff) to achieve something as essential as getting DNS lookups to go through the VPN connection?
Nearly every time someone connects to a VPN service the user's expected system behaviour is that the VPN service's DNS servers should be used and all traffic should go through the VPN connection; this is especially true for novice users. This should therefore be the default behaviour.
But not only is this not the default behavior, there also isn't some easy way to make systemd-resolved to work as desired (e.g. you have to use 400 lines long scripts, block packets to your ISP's DNS server at the IP-level, etc).
systemd-resolved is a "system service that provides network name resolution". It is beyond essential that a system that "provides network name resolution" should be able to with little effort to be made to route DNS requests through a VPN connection. Also, it's default behavior out-of-the-box should comply with the most common use cases (e.g. user connects to a VPN service ==> all data goes through VPN connection).
Reacted by Richard Hurt, swann croiset, jablan, Maciej, Matthew Gamble, nofunatall, Gullumluvl, Jakub Buriánek, Lari Niura, Pablo Domingo Rojo and 128 more
Reacted by Ilya Baryshnikov, Ivan Shapovalov, Alexander Dorn and Alex Berber
Reacted by Bednar87, ikt, Daniel Mota Leite, Jonathan S. Fisher, Dardan Bekteshi, zaid gharaybeh, Stefan Kuksenko, dbogatyr and Pavan Manjunath
Reacted by Ilya Baryshnikov, Ivan Shapovalov, ikt, Jonathan S. Fisher and belugame
Reacted by Bednar87, ikt, Jackson Hughes, Daniel Mota Leite, Kevin Tindall, Jonathan S. Fisher, Brandon Davis, Bobbie Deniker, Benjamin Hubert, Dimitri Papadopoulos Orfanos and 6 more
My current workaround is to do the following tricks every time I start my workplace VPN:
Find out the link number (a.k.a. interface index) of the ISP interface: systemd-resolve --status or ip l.
Connect the VPN.
Remove DNS settings from the ISP interface (using the link number from step 1) by sending a D-Bus command to systemd-resolved. This is an example using link number 2: sudo busctl call org.freedesktop.resolve1 /org/freedesktop/resolve1 org.freedesktop.resolve1.Manager SetLinkDNS 'ia(iay)' 2 0
Inspect with systemd-resolve --status to ensure that only the correct DNS servers are there.
Apparently there isn't any simple cli tool for managing systemd-resolved's settings. That busctl command isn't very user-friendly. :)
Reacted by Richard Hurt, swann croiset, jablan, Dylan Price, Jahn F., Nicolas Olivier, RNZ, Zsolt Donca, Trevor Bortins, Pavel P and 8 more
So, resolved is actually doing the right thing here, given the configuration it was given. @joshuafc, resolved only knows the DNS server 192.168.83.2 in your setup, but you want it to know 208.67.222.222 and 8.8.8.8, right? If so, this information needs to be made available to resolved, and the ppp scripts (given that you are using ppp/pptp) need to push it into resolved, which i think ubuntu updated the "resolvconf" package to do. But that's really outside of the scope of upstream resolved. @nox, can you help? is there some ppp/pptp hookup missing for resolved in ubuntu?
@poettering I'm confused by your most recent comment. If you review the contents of the most recent comment by @aigarius it shows that resolved does in fact have the DNS server addresses. He's just using google.com as an example to show the geo-located difference between his native connection and the vpn connection.
I came to this bug because I have a similar situation and basically the exact same symptoms as described in @aigarius' most recent comment with an openconnect vpn configuration. It's clear from the output that systemd-resolved has the DNS server info for the DNS servers inside the VPN, but it's not updating the DNS cache to bring in the new DNS servers and thus having trouble resolving things inside the private VPN network that should resolve easily. And in fact do resolve easily if you point relevant commands at the correct interface/DNS server.
A simple restart of systemd-resolved upon vpn connect/disconnect seems to fix the problem, but alas it really shouldn't be needed. Systemd-resolved should just be flushing the cache when a new DNS server is added.
Reacted by Peter Dzugas, Aaron Denney and Joe Julian
This issue is closed, but when I tried to use OpenVPN 2.4.7 on Ubuntu 20.04, this issue still causes DNS leaks. After some troubleshooting, I realized that I had to do all of the following:
Install openvpn-systemd-resolved
sudo apt-get install openvpn-systemd-resolved
Add these lines to the .ovpn config. This sets the "DNS Domain" of the VPN interface tun0 to ~.
script-security 2
up /etc/openvpn/update-systemd-resolved
up-restart
down /etc/openvpn/update-systemd-resolved
down-pre
dhcp-option DOMAIN-ROUTE .
After starting openvpn, I still had to do one more step, which is to remove the existing ~. from my default network interface (eno1 in my case). Otherwise DNS requests go to both tun0 and eno1 and still causes DNS leaks. This is the command:
sudo systemd-resolve -i eno1 --set-domain lan
Only after all three steps, openvpn finally stops leaking DNS. In systemd-resolve --status, this is what I now see. Without Step 3 above, the DNS Domain of eno1 is set to ~. and lan and thus still leaks DNS.
$ systemd-resolve --status
Global
LLMNR setting: no
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Domain: lan
...
Link 8 (tun0)
Current Scopes: DNS
DefaultRoute setting: yes
LLMNR setting: yes
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: no
DNSSEC supported: no
Current DNS Server: 1.1.1.1
DNS Servers: 1.1.1.1
8.8.8.8
DNS Domain: ~.
...
Link 2 (eno1)
Current Scopes: DNS
DefaultRoute setting: yes
LLMNR setting: yes
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: no
DNSSEC supported: no
Current DNS Server: 192.168.X.X
DNS Servers: 192.168.X.X
DNS Domain: lan
This is such a pain to do something simple. I want to point out that none of these were needed before systemd-resolved was introduced. Is there any plans to fix this?
Reacted by Pavan Manjunath, Evgeniy Paltsev, Denis Krivak and fredericgermain
This is such a pain to do something simple. I want to point out that none of these were needed before systemd-resolved was introduced. Is there any plans to fix this?
No, it would need to be fixed by the openvpn developers, not by systemd-resolved. systemd-resolved only sends your DNS exactly where you tell it to, so there is nothing to fix. If you don't tell it what you want, it cannot do what you want.
Your post is good documentation of how to manually tell systemd-resolved where your DNS is intended to go if you want to manually configure openvpn. Alternatively, if you are a desktop user, you could use NetworkManager-openvpn, which would take care of all of this for you automatically.
This is such a pain to do something simple. I want to point out that none of these were needed before systemd-resolved was introduced. Is there any plans to fix this?
No, it would need to be fixed by the openvpn developers, not by systemd-resolved. systemd-resolved only sends your DNS exactly where you tell it to, so there is nothing to fix. If you don't tell it what you want, it cannot do what you want.
Your post is good documentation of how to manually tell systemd-resolved where your DNS is intended to go if you want to manually configure openvpn. Alternatively, if you are a desktop user, you could use NetworkManager-openvpn, which would take care of all of this for you automatically.
Thanks. Let me try to find out if OpenVPN is fixing this.
This is such a pain to do something simple. I want to point out that none of these were needed before systemd-resolved was introduced. Is there any plans to fix this?
No, it would need to be fixed by the openvpn developers, not by systemd-resolved. systemd-resolved only sends your DNS exactly where you tell it to, so there is nothing to fix. If you don't tell it what you want, it cannot do what you want.
Your post is good documentation of how to manually tell systemd-resolved where your DNS is intended to go if you want to manually configure openvpn. Alternatively, if you are a desktop user, you could use NetworkManager-openvpn, which would take care of all of this for you automatically.
Hi @mcatanzaro one thing I want to point out is that, OpenVPN is not the only VPN client experiencing this issue. Others such as FortiClient have the same problem. Is it right to say that multiple VPN clients are broken and the issue is caused by those VPN clients themselves and not by systemd-resolved?
Hi @mcatanzaro one thing I want to point out is that, OpenVPN is not the only VPN client experiencing this issue. Others such as FortiClient have the same problem. Is it right to say that multiple VPN clients are broken and the issue is caused by those VPN clients themselves and not by systemd-resolved?
I'm surprised this is still a problem in 2020, since systemd-resolved has been default in Ubuntu for four years now, but yes, every VPN client that does not know how to configure systemd-resolved is going to be broken. Thanks for documenting how to do this, Lennart!
I put together some docs in #17678 that explain in detail what VPN should do to get the right config into systemd-resolved. PTAL.
Something is not working properly AFAIK,
I follow the guide and issued the privacy suggested command, correct DNS ip is used but on the interface "end0" instead of the "tun0"; this happen only if the DNS server has the same ip as the VPN server, otherwise it seems to work correctly
Global
Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: uplink
Fallback DNS Servers: 1.1.1.1#cloudflare-dns.com 9.9.9.9#dns.quad9.net 8.8.8.8#dns.google 2606:4700:4700::1111#cloudflare-dns.com 2620:fe::9#dns.quad9.net 2001:4860:4860::8888#dns.google
Link 2 (end0)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 127.0.0.1
DNS Servers: 127.0.0.1
Link 19 (tun0)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 195.216.219.147
DNS Servers: 195.216.219.147
DNS Domain: ~.
but making a dns request (in this case a simple ping www.google.com) causes:
the request is on end0, while it should be on tun0.
ping hangs as there is no answer from the DNS, so i dont think any parallel request is sent to tun0
setting the dns server to 8.8.8.8 or anything that is not the VPN's ip, seems to fix the issue
As we talk about privacy setup, and as DNS request are not encrypted, letting them go to the VPN server without passing trough the tun0 is pretty much as bad as requesting to the ISP, as they are easy to intercept from the ISP.
Also may be problematic in buisness setup, where the dns server may be listening only to request from the LAN rather than be accessible from the internet
also i find very strange this different behavior based on the destination ip, am i triggering some edge case?
this happen only if the DNS server has the same ip as the VPN server
To avoid routing the VPN traffic itself via TUN device, some route-based VPNs install a bypass route via physical interface for the VPN server's IP address. You might want to assign a second (maybe private) IP address to the VPN server that you use as DNS server address.
To avoid routing the VPN traffic itself via TUN device, some route-based VPNs install a bypass route via physical interface for the VPN server's IP address. You might want to assign a second (maybe private) IP address to the VPN server that you use as DNS server address.
ok, this make a lot of sense and i guess a simple routing table cannot handle my case as it does not know the protocol, or at least the destination port.
As i dont have access to server configuration, i guess my only solution is to make sure to use a different DNS server or do some iptables magic
Activity
poettering commentedon Jun 13, 2017
Hmm, not sure I follow. How exactly did you configure your DNS? What does "systemd-resolve --status" report about the DNS servers? Is /etc/resolv.conf a file or a symlink?
joshuafc commentedon Jun 20, 2017
@poettering thanks for your reply.
here is the information
ping failed, 93.46.8.89 is incorrect , ISP's DNS server resolve it to 93.46.8.89 because of Internet regulation. VPN's DNS Server resolve it to 172.217.26.36, which can ping successfully.
aigarius commentedon Sep 21, 2017
Can confirm the same effect with a OpenVPN connection.
Running "systemd-resolve internal.name.local" fails to find it (it only tries the 192.* DNS server), running "systemd-resolve -i tun0 internal.name.local" resolves the name correctly (via 172.* DNS server), but no applications actually supply that interface, naturally.
Systemd version 232
Ubuntu 17.04
Currently I have to workaround this by overwriting the /etc/resolv.conf file each time I connect to the VPN, but even that now stops working as some apps use the systemd-resolv directly if it is available.
Alternative solution that worked for me is using a patched version of NetworkManager from https://bugs.launchpad.net/network-manager/+bug/1624317 that forces using the VPN DNS server by adding a "DNS Domain: ~." declaration to the tun0 section of systemd-resolve
mikken commentedon Oct 9, 2017
You (joshuafc and aigarius) need to do 2 things:
mikken commentedon Oct 9, 2017
aigarius, for you the domain .local should be configured as "routing" domain on this link (tun0).
PureRumble commentedon Oct 29, 2017
@mikken, that script you're telling us to use is 400 lines long. What does it do? Any bugs? Is it safe or does it expose our systems to vulnerabilities? Will it break something else? Why do we need a 400 lines long script (and then to do even more stuff) to achieve something as essential as getting DNS lookups to go through the VPN connection?
Nearly every time someone connects to a VPN service the user's expected system behaviour is that the VPN service's DNS servers should be used and all traffic should go through the VPN connection; this is especially true for novice users. This should therefore be the default behaviour.
But not only is this not the default behavior, there also isn't some easy way to make systemd-resolved to work as desired (e.g. you have to use 400 lines long scripts, block packets to your ISP's DNS server at the IP-level, etc).
systemd-resolved is a "system service that provides network name resolution". It is beyond essential that a system that "provides network name resolution" should be able to with little effort to be made to route DNS requests through a VPN connection. Also, it's default behavior out-of-the-box should comply with the most common use cases (e.g. user connects to a VPN service ==> all data goes through VPN connection).
flo-wer commentedon Oct 29, 2017
See #7182
snabb commentedon Oct 29, 2017
My current workaround is to do the following tricks every time I start my workplace VPN:
systemd-resolve --statusorip l.sudo busctl call org.freedesktop.resolve1 /org/freedesktop/resolve1 org.freedesktop.resolve1.Manager SetLinkDNS 'ia(iay)' 2 0systemd-resolve --statusto ensure that only the correct DNS servers are there.Apparently there isn't any simple cli tool for managing systemd-resolved's settings. That
busctlcommand isn't very user-friendly. :)poettering commentedon Dec 8, 2017
So, resolved is actually doing the right thing here, given the configuration it was given. @joshuafc, resolved only knows the DNS server 192.168.83.2 in your setup, but you want it to know 208.67.222.222 and 8.8.8.8, right? If so, this information needs to be made available to resolved, and the ppp scripts (given that you are using ppp/pptp) need to push it into resolved, which i think ubuntu updated the "resolvconf" package to do. But that's really outside of the scope of upstream resolved. @nox, can you help? is there some ppp/pptp hookup missing for resolved in ubuntu?
poettering commentedon Dec 8, 2017
@snabb #7576 adds the requested "simple cli" functionality to systemd-resolve.
jetsaredim commentedon Jan 5, 2018
@poettering I'm confused by your most recent comment. If you review the contents of the most recent comment by @aigarius it shows that resolved does in fact have the DNS server addresses. He's just using google.com as an example to show the geo-located difference between his native connection and the vpn connection.
I came to this bug because I have a similar situation and basically the exact same symptoms as described in @aigarius' most recent comment with an openconnect vpn configuration. It's clear from the output that systemd-resolved has the DNS server info for the DNS servers inside the VPN, but it's not updating the DNS cache to bring in the new DNS servers and thus having trouble resolving things inside the private VPN network that should resolve easily. And in fact do resolve easily if you point relevant commands at the correct interface/DNS server.
A simple restart of systemd-resolved upon vpn connect/disconnect seems to fix the problem, but alas it really shouldn't be needed. Systemd-resolved should just be flushing the cache when a new DNS server is added.
95 remaining items
zerkms commentedon Nov 14, 2020
@sliddjur I use ipsec, there is no dedicated interface in my implementation: all traffic flows through one and the only physical interface.
yuqian90 commentedon Nov 18, 2020
This issue is closed, but when I tried to use OpenVPN 2.4.7 on Ubuntu 20.04, this issue still causes DNS leaks. After some troubleshooting, I realized that I had to do all of the following:
openvpn-systemd-resolved~.~.from my default network interface (eno1 in my case). Otherwise DNS requests go to both tun0 and eno1 and still causes DNS leaks. This is the command:Only after all three steps, openvpn finally stops leaking DNS. In
systemd-resolve --status, this is what I now see. Without Step 3 above, theDNS Domainofeno1is set to~.andlanand thus still leaks DNS.This is such a pain to do something simple. I want to point out that none of these were needed before systemd-resolved was introduced. Is there any plans to fix this?
mcatanzaro commentedon Nov 18, 2020
No, it would need to be fixed by the openvpn developers, not by systemd-resolved. systemd-resolved only sends your DNS exactly where you tell it to, so there is nothing to fix. If you don't tell it what you want, it cannot do what you want.
Your post is good documentation of how to manually tell systemd-resolved where your DNS is intended to go if you want to manually configure openvpn. Alternatively, if you are a desktop user, you could use NetworkManager-openvpn, which would take care of all of this for you automatically.
yuqian90 commentedon Nov 19, 2020
Thanks. Let me try to find out if OpenVPN is fixing this.
yuqian90 commentedon Nov 20, 2020
Hi @mcatanzaro one thing I want to point out is that, OpenVPN is not the only VPN client experiencing this issue. Others such as FortiClient have the same problem. Is it right to say that multiple VPN clients are broken and the issue is caused by those VPN clients themselves and not by systemd-resolved?
poettering commentedon Nov 20, 2020
I put together some docs in #17678 that explain in detail what VPN should do to get the right config into systemd-resolved. PTAL.
mcatanzaro commentedon Nov 20, 2020
I'm surprised this is still a problem in 2020, since systemd-resolved has been default in Ubuntu for four years now, but yes, every VPN client that does not know how to configure systemd-resolved is going to be broken. Thanks for documenting how to do this, Lennart!
docs: document what VPNs should do to systemd-resolved.service
docs: document what VPNs should do to systemd-resolved.service
AndrewVos commentedon Apr 9, 2021
Wow, so I've just found this and have been wondering why I've had so many problems with ivpn. Time to go back to nordvpn.
lestofante commentedon Jan 15, 2023
Something is not working properly AFAIK,
I follow the guide and issued the privacy suggested command, correct DNS ip is used but on the interface "end0" instead of the "tun0"; this happen only if the DNS server has the same ip as the VPN server, otherwise it seems to work correctly
systemd-resolve --status
but making a dns request (in this case a simple ping www.google.com) causes:
As we talk about privacy setup, and as DNS request are not encrypted, letting them go to the VPN server without passing trough the tun0 is pretty much as bad as requesting to the ISP, as they are easy to intercept from the ISP.
Also may be problematic in buisness setup, where the dns server may be listening only to request from the LAN rather than be accessible from the internet
also i find very strange this different behavior based on the destination ip, am i triggering some edge case?
tobiasbrunner commentedon Jan 16, 2023
To avoid routing the VPN traffic itself via TUN device, some route-based VPNs install a bypass route via physical interface for the VPN server's IP address. You might want to assign a second (maybe private) IP address to the VPN server that you use as DNS server address.
lestofante commentedon Jan 16, 2023
ok, this make a lot of sense and i guess a simple routing table cannot handle my case as it does not know the protocol, or at least the destination port.
As i dont have access to server configuration, i guess my only solution is to make sure to use a different DNS server or do some iptables magic