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
[networkd] description of UseDNS= / UseDomains= #9473
From manual page: When true (the default), the DNS servers received from the DHCP server will be used and take precedence over any statically configured ones.
What I observed is that both sections simply get merged, without any particular preferences (formally DNS= listed DNSes are before dynamically obtained ones). Same applies to Domains= and UseDomains= - static and dynamic are simply merged.
Probably the same applies to NTP= / UseNTP= pair - but I haven't checked this yet.
The behavior is as usual - the relevant DNSes are tried in turn (in case some of servers fail, tested with simple iptables rule)
systemd-networkd internally uses an ordered hash set and inserts the statically configured DNS servers first, so they get preferred. systemd-resolved inserts the DNS servers from the ordered hash set in insertion order into a linked list. If the DNS server is already in the list, it inserts it at the end of the list. So there is a particular precedence and it should – if I'm not mistaken – match the precedence that is documented in the man page.
I stumbled across this issue myself.
I was looking into fixing a VPN-DNSleak of mine and stumbled across these tickets. #6076 (comment) #10830 #5755
Since I want my configuration to work for wireless networks outside my home, e.g. coffeshops, I need my setup to be able to adhere their configuration without a lot of fuss. So I thought about, writing a configuration explicitly for the few networks I am using most. The idea is that there is no need for DNS-Server use in those networks, because access is not locked by a conset-screen displayed via DNS-request "hijacking". So the DNS-Server of the VPN-Setup can just be used.
I found that my setup is still acquiring the DNS server configuration via DHCP.
To reproduce the Issue:
Create a *.link file in /etc/systemd/network with the appropriate [MATCH] and [NETWORK] section
set UseDNS=false under [NETWORK]
Disconnect your network
execute the following commands as root: systemctl daemon-reload && systemctl restart systemd-networkd && systemctl restart systemd-resolved
connect to network listed under [MATCH] section of file created under point 1
execute networkctl status and you will find that the network is managed, but also that there is a DNS-configuration present
I assume the reason for this not surfacing sooner is the available alternative of making /etc/resolve.conf a file and not a symlink.
However, this approach has the drawback of not being able to use alternative network-setups with ease, which regularly results in configuration-sessions, rather than getting work done, when entering a new shop trying to use a publicly available WiFi Mac and Windows can use without a problem.
Seeing how the other issues devolved, I want to stress that this is not about the way certain shops run their network or how the VPN-DNS-issue might or might not be an other project's/this project's issue, but rather about the UseDNS= configuration not performing actions as documented, thereby limiting flexibility and raising privacy-issues for the user-base.
Following are my system-details:
% uname -r
5.7.9-arch1-1
% networkctl status
● State: routable
Address: 192.168.x.z on wlan0
172.17.0.1 on docker0
xxxx:xxxx:xxxx:xxxx on wlan0
Gateway: 192.168.x.x on wlan0
DNS: 192.168.x.x # same as gateway
Route Domains: .
NTP: 192.168.x.x # same as gateway
% cat wlan0_home.network
[Match]
Name=wlan0
SSID="My Hidden SSID With Spaces"
% resolvectl status
Global
LLMNR setting: no
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: allow-downgrade
DNSSEC supported: no
Current DNS Server: 9.9.9.9
DNS Servers: 9.9.9.9
Fallback DNS Servers: 1.1.1.1
149.112.112.112
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 5 (docker0)
Current Scopes: none
DefaultRoute setting: no
LLMNR setting: yes
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: allow-downgrade
DNSSEC supported: yes
Link 4 (wlan0)
Current Scopes: DNS
DefaultRoute setting: yes
LLMNR setting: no
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
Link 2 (enp3s0)
Current Scopes: none
DefaultRoute setting: no
LLMNR setting: yes
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: allow-downgrade
DNSSEC supported: yes
$ cat /etc/systemd/networkd.conf
# This file is part of systemd.
[DHCP]
UseDNS=false
systemd-networkd[19392]: /etc/systemd/networkd.conf:2: Unknown lvalue 'UseDNS' in section 'DHCP'
[DHCP] is a section for .network files. Of course it doesn't work in networkd.conf.
--
I don't see why UseDNS=no wouldn't work. @yuwata added a test for this e2d5aab. @yuwata do you have any idea why this might not work for them as expected? Were there any fixes that could be relevent?
I don't see why UseDNS=no wouldn't work. @yuwata added a test for this e2d5aab. @yuwata do you have any idea why this might not work for them as expected? Were there any fixes that could be relevent?
Hmm, I cannot find anything relevant to this issue. @mikhailnov and @teatreeoilchocolate Could you show the result of networkctl status INTERFACE_NAME, and check that .network file name shown in the result is matches the file you set UseDNS=no?
This is the output of networkctl status tun0 with UseDNS=no. It is no different from UseDNS=false , according to man-pages it is a boolean anyways.
# networkctl status tun0
● 14: tun0
Link File: /usr/lib/systemd/network/99-default.link
Network File: /etc/systemd/network/tun0.network
Type: none
State: routable (failed)
Driver: tun
MTU: 1500 (min: 68, max: 65535)
QDisc: fq_codel
IPv6 Address Generation Mode: random
Queue Length (Tx/Rx): 1/1
Auto negotiation: no
Speed: 10Mbps
Duplex: full
Port: tp
Address: xxxxxxx
xxxxxxxx
DNS: 9.9.9.9
Route Domains: .
Mar 12 22:37:47 gg systemd-networkd[841]: tun0: Gained IPv6LL
Mar 12 22:37:47 gg systemd-networkd[841]: tun0: DHCP4 CLIENT: Failed to set MAC address: Invalid argument
Mar 12 22:37:47 gg systemd-networkd[841]: tun0: Failed
Mar 12 22:39:34 g systemd-networkd[841]: tun0: Link DOWN
Mar 12 22:39:34 gg systemd-networkd[841]: tun0: Lost carrier
Mar 12 22:39:41 gg systemd-networkd[841]: tun0: Link UP
Mar 12 22:39:41 gg systemd-networkd[841]: tun0: Gained carrier
Mar 12 22:39:41 gg systemd-networkd[841]: tun0: Gained IPv6LL
Mar 12 22:39:41 gg systemd-networkd[841]: tun0: DHCP4 CLIENT: Failed to set MAC address: Invalid argument
Mar 12 22:39:41 gg systemd-networkd[841]: tun0: Failed
The DHCP-Problems are peculiar, but do not lead to a defunct device and I doubt they are related to UseDNS.
I also have a tun0.link(under /etc/systemd/network/) which is not used here and ip link lists tun0 as tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN mode DEFAULT group default qlen 500 link/none
My configuration-files again because it has been some time.
I also revisited the problem to see exactly what issue I had.
I am not 100% sure because of the time passed and I had to put it on the backburner. But if memory serves me right the issue I had was that the documentation stated that the DNS-Servers received via DHCP will be used and take precedent over the statically configured ones.
Now looking at resolvectl status I can say that false definitely works.
My tun0 device only works with DNS-Servers defined by me and thanks to the wonderful possibility of minute configuration I have every url being resolved via tun0 if it is up(see config).
True, being the default appears to still not work, or at least it is displayed as such.
It is currently not possible for me to test this because I cannot walk into a Starbucks and setup my rig for obvious reasons.
The hotspot in my building is using a sign-in gateway and Firefox allows for a direct calling of this website via IP not unlike the phones ability to navigate you to the sign-in-page.
So DNS is never part of the equation.
However looking at resolvectl, I can see the search-domain and the DNS-Server for wlan0 being set, BUT the DNS-Server provided via DHCP is the last of the alternative DNS-Servers, so it stands to reason that trying to look up bing.com(and in that event being redirected to the signin-page) might still fail, because
A) the cache might not be cold(very likely)
and
B) the other DNS-Servers are not reachable or their response not usable as port 80 is blocked until signed in
With systemd-resolve looping through the DNS-Server list this issue might be resolved if the cache is cold, but I cannot test this at the moment.
# resolvectl status
......
Link 4 (wlan0)
Current Scopes: DNS
Protocols: +DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 1.1.1.1
DNS Servers: 1.1.1.1 8.8.8.8 192.168.x.z
DNS Domain: cccc-sssss
......
I also have a tun0.link(under /etc/systemd/network/) which is not used here
You need to prefix a digit to the .link file e.g. 50-tun0.link. We read .network or .link file in alphanumerically, so the file must be listed earlier than 99-default.link.
At least UseDNS=no/false issue is not reproducible anymore. Thank you for the confirmation.
However looking at resolvectl, I can see the search-domain and the DNS-Server for wlan0 being set, BUT the DNS-Server provided via DHCP is the last of the alternative DNS-Servers
I guess you have something like the following config for wlan0
You need to prefix a digit to the .link file e.g. 50-tun0.link. We read .network or .link file in alphanumerically, so the file must be listed earlier than 99-default.link.
I take the global configuration for the DNS-servers.
The verbosity stems from another configuration I have for when I do not need to log into a wireless lan via sign-up-page, and I tried to mitigate the use of the signup-button presented by Firefox which I now use regularly though. I do not know if proponents of Chrome(/ium) or other browsers are able to solve this in the same manner.
That was also the reason for me to stumble across the description of UseDNS.
I don't mind the description being changed instead of the application to fit the description.
Would also be quicker.
The problem I had back then was that I was chasing a ghost, thinking my config must have some minor difference from what is expected to make it work in the described manner. With the description being off, that undertaking is, of course, doomed.
Thanks for looking at this after such a long time and once again: I love systemd <3
Hm? Where does the 'global configuration' come from? How do you configure 1.1.1.1 and 8.8.8.8?
I set them in the resolved.conf
% cat /etc/systemd/resolved.conf
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details
[Resolve]
DNS=9.9.9.9
FallbackDNS=1.1.1.1 149.112.112.112
#Domains=
LLMNR=no
#MulticastDNS=yes
MulticastDNS=no
#DNSSEC=allow-downgrade
DNSSEC=allow-downgrade
#DNSOverTLS=no
DNSOverTLS=no
#Cache=yes
#DNSStubListener
But I fail to account for the 8.8.8.8 for some reason.
//Edit
I stand corrected.
cat /run/systemd/netif/leases/4
....
DNS=1.1.1.1 8.8.8.8 192.168.x.z
...
I was focused on 1.1.1.1. So checking /run/systemd/netif/leases/4 networkctl status wlan0 and resolvectl status wlan0 UseDNS works, so the documentation is correct after all.
Puzzles me a bit as I distinctly remember having trouble with it using some public WiFi, but then again, maybe I overlooked some small detail like Quad8 or prefixing .link-files with numbers. What could have been the case is that the WiFi used the same DNS-servers Quad9 or 1 as I had configured and the cache was not cold(after all what they are doing with the signup pages is not really nice), the order in which the DNS-servers were added was unfavourable(the one in the LAN being the last of the fallbacks), so briefly looking over the configuration one can easily get the impression of UseDNS not working properly. After all it is rather inconspicuous when at work.
Would really love to put it to the test next time we can sit down in coffee shops again.
% networkctl status wlan0
.....
Gateway: 192.168.ccc.xxx (...)
DNS: 1.1.1.1
8.8.8.8
192.168.ccc.xxx
% resolvectl status wlan0
Link 4 (wlan0)
Current Scopes: DNS
Protocols: +DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 192.168.ccc.xxx
DNS Servers: 1.1.1.1 8.8.8.8 192.168.ccc.xxx
DNS Domain: ....
With the change(which appears to be random) of the current DNS-server, I would also argue that the override(without concatination as 149.112.112.112 is missing) , as hinted at by me and reported by the @msoltyspl is working.
The documentation issue was resolved in b63dae3. IIUC, everything else works. If the problem reappears, please open a new issue, because this one is quite messy.
Activity
ott commentedon Sep 2, 2018
systemd-networkd internally uses an ordered hash set and inserts the statically configured DNS servers first, so they get preferred. systemd-resolved inserts the DNS servers from the ordered hash set in insertion order into a linked list. If the DNS server is already in the list, it inserts it at the end of the list. So there is a particular precedence and it should – if I'm not mistaken – match the precedence that is documented in the man page.
mikhailnov commentedon Feb 3, 2019
I'm having the same issue. How to disable receiving DNS from DHCP??
ott commentedon Mar 10, 2019
@mikhailnov UseDNS=false in the DHCP section should be correct.
tomtastic commentedon Apr 23, 2019
teatreeoilchocolate commentedon Jul 19, 2020
I stumbled across this issue myself.
I was looking into fixing a VPN-DNSleak of mine and stumbled across these tickets.
#6076 (comment)
#10830
#5755
Since I want my configuration to work for wireless networks outside my home, e.g. coffeshops, I need my setup to be able to adhere their configuration without a lot of fuss. So I thought about, writing a configuration explicitly for the few networks I am using most. The idea is that there is no need for DNS-Server use in those networks, because access is not locked by a conset-screen displayed via DNS-request "hijacking". So the DNS-Server of the VPN-Setup can just be used.
I found that my setup is still acquiring the DNS server configuration via DHCP.
To reproduce the Issue:
I assume the reason for this not surfacing sooner is the available alternative of making /etc/resolve.conf a file and not a symlink.
However, this approach has the drawback of not being able to use alternative network-setups with ease, which regularly results in configuration-sessions, rather than getting work done, when entering a new shop trying to use a publicly available WiFi Mac and Windows can use without a problem.
Seeing how the other issues devolved, I want to stress that this is not about the way certain shops run their network or how the VPN-DNS-issue might or might not be an other project's/this project's issue, but rather about the
UseDNS=configuration not performing actions as documented, thereby limiting flexibility and raising privacy-issues for the user-base.Following are my system-details:
[Network]
DHCP=ipv4
LLMNR=false
DNSOverTLS=no
DNSSEC=no
[DHCPV4]
UseDNS=false
UseDomains=false
Anonymize=true
keszybz commentedon Mar 1, 2021
@tomtastic
[DHCP] is a section for .network files. Of course it doesn't work in networkd.conf.
--
I don't see why UseDNS=no wouldn't work. @yuwata added a test for this e2d5aab. @yuwata do you have any idea why this might not work for them as expected? Were there any fixes that could be relevent?
@msoltyspl, @mikhailnov please tests with a recent version.
tomtastic commentedon Mar 1, 2021
thanks @keszybz, but 2019 was long ago and this is no longer an issue for me :)
yuwata commentedon Mar 1, 2021
Hmm, I cannot find anything relevant to this issue.
@mikhailnov and @teatreeoilchocolate Could you show the result of
networkctl status INTERFACE_NAME, and check that .network file name shown in the result is matches the file you setUseDNS=no?teatreeoilchocolate commentedon Mar 12, 2021
Hello!
Sorry for the delay.
This is the output of
networkctl status tun0withUseDNS=no. It is no different fromUseDNS=false, according to man-pages it is a boolean anyways.The DHCP-Problems are peculiar, but do not lead to a defunct device and I doubt they are related to
UseDNS.I also have a tun0.link(under /etc/systemd/network/) which is not used here and ip link lists tun0 as
tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN mode DEFAULT group default qlen 500 link/noneMy configuration-files again because it has been some time.
//Edit:
I also revisited the problem to see exactly what issue I had.
I am not 100% sure because of the time passed and I had to put it on the backburner. But if memory serves me right the issue I had was that the documentation stated that the DNS-Servers received via DHCP will be used and take precedent over the statically configured ones.
Now looking at
resolvectl statusI can say that false definitely works.My tun0 device only works with DNS-Servers defined by me and thanks to the wonderful possibility of minute configuration I have every url being resolved via tun0 if it is up(see config).
True, being the default appears to still not work, or at least it is displayed as such.
It is currently not possible for me to test this because I cannot walk into a Starbucks and setup my rig for obvious reasons.
The hotspot in my building is using a sign-in gateway and Firefox allows for a direct calling of this website via IP not unlike the phones ability to navigate you to the sign-in-page.
So DNS is never part of the equation.
However looking at resolvectl, I can see the search-domain and the DNS-Server for wlan0 being set, BUT the DNS-Server provided via DHCP is the last of the alternative DNS-Servers, so it stands to reason that trying to look up bing.com(and in that event being redirected to the signin-page) might still fail, because
A) the cache might not be cold(very likely)
and
B) the other DNS-Servers are not reachable or their response not usable as port 80 is blocked until signed in
With systemd-resolve looping through the DNS-Server list this issue might be resolved if the cache is cold, but I cannot test this at the moment.
yuwata commentedon Mar 13, 2021
@teatreeoilchocolate
You need to prefix a digit to the .link file e.g. 50-tun0.link. We read .network or .link file in alphanumerically, so the file must be listed earlier than 99-default.link.
At least
UseDNS=no/falseissue is not reproducible anymore. Thank you for the confirmation.I guess you have something like the following config for wlan0
Hmm, indeed, the man page said
If I remember correctly, the behavior was not changed for so long time, so I think we need to adjust the man page.
teatreeoilchocolate commentedon Mar 13, 2021
Thanks. The devil is always in the details.
The wlan0.network file looks indeed similar:
I take the global configuration for the DNS-servers.
The verbosity stems from another configuration I have for when I do not need to log into a wireless lan via sign-up-page, and I tried to mitigate the use of the signup-button presented by Firefox which I now use regularly though. I do not know if proponents of Chrome(/ium) or other browsers are able to solve this in the same manner.
That was also the reason for me to stumble across the description of
UseDNS.I don't mind the description being changed instead of the application to fit the description.
Would also be quicker.
The problem I had back then was that I was chasing a ghost, thinking my config must have some minor difference from what is expected to make it work in the described manner. With the description being off, that undertaking is, of course, doomed.
Thanks for looking at this after such a long time and once again: I love systemd <3
man: DNS/NTP servers received from DHCP server are concatenated with …
yuwata commentedon Mar 13, 2021
Hm? Where does the 'global configuration' come from? How do you configure
1.1.1.1and8.8.8.8?Yey!
teatreeoilchocolate commentedon Mar 13, 2021
I set them in the resolved.conf
But I fail to account for the 8.8.8.8 for some reason.
//Edit
I stand corrected.
I was focused on 1.1.1.1. So checking /run/systemd/netif/leases/4
networkctl status wlan0andresolvectl status wlan0UseDNSworks, so the documentation is correct after all.Puzzles me a bit as I distinctly remember having trouble with it using some public WiFi, but then again, maybe I overlooked some small detail like Quad8 or prefixing .link-files with numbers. What could have been the case is that the WiFi used the same DNS-servers Quad9 or 1 as I had configured and the cache was not cold(after all what they are doing with the signup pages is not really nice), the order in which the DNS-servers were added was unfavourable(the one in the LAN being the last of the fallbacks), so briefly looking over the configuration one can easily get the impression of
UseDNSnot working properly. After all it is rather inconspicuous when at work.Would really love to put it to the test next time we can sit down in coffee shops again.
With the change(which appears to be random) of the current DNS-server, I would also argue that the override(without concatination as 149.112.112.112 is missing) , as hinted at by me and reported by the @msoltyspl is working.
man: DNS/NTP servers received from DHCP server are concatenated with …
man: DNS/NTP servers received from DHCP server are concatenated with …
man: DNS/NTP servers received from DHCP server are concatenated with …
keszybz commentedon Jan 11, 2022
The documentation issue was resolved in b63dae3. IIUC, everything else works. If the problem reappears, please open a new issue, because this one is quite messy.