Repository navigation
Description
Is your feature request related to a problem? Please describe.
You may have a case where you'd want to use a specific upstream resolver for a domain, within dnsmasq this is possible though a convention in their documentation called "special servers".
Using special servers.
Dnsmasq has the ability to direct DNS queries for certain domains to specific upstream nameservers. This feature was added for use with VPNs but it is fully general. The scenario is this: you have a standard internet connection via an ISP, and dnsmasq is configured to forward queries to the ISP's nameservers, then you make a VPN connection into your companies network, giving access to hosts inside the company firewall. You have access, but since many of the internal hosts aren't visible on the public internet, your company doesn't publish them to the public DNS and you can't get their IP address from the ISP nameservers. The solution is to use the companies nameserver for private domains within the company, and dnsmasq allows this. Assuming that internal company machines are all in the domain internal.myco.com and the companies nameserver is at 192.168.10.1 then the option server=/internal.myco.com/192.168.10.1 will direct all queries in the internal domain to the correct nameserver. You can specify more than one domain in each server option. If there is more than one nameserver just include as many server options as is needed to specify them all.
In configuration it looks like this:
server=/acme.corp/10.1.1.2
Describe the solution you'd like
A configuration option similar to dnsmasq "special servers" as outlined above, possible to use Domains=?
Describe alternatives you've considered
Can utilize a resolver like dnsmasq in front of systemd-resolved to accomplish the same thing.
The systemd version you checked that didn't have the feature you are asking for
[agd@chonk ~]$ systemctl --version
systemd 248 (v248.7-1.fc34)
+PAM +AUDIT +SELINUX -APPARMOR +IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified
Activity
trallnag commentedon Sep 18, 2021
Yep, this comes up very often at companies. The only solution I know is (as already said by OP) dnsmasq.
yrro commentedon Oct 13, 2021
Can you create a
dummyinterface, and configure a server & routing domain on it viaresolvectlcommands?... which NetworkManager pushes through to
systemd-resolved:I can then see queries for
foo.example.qqgoing to8.8.8.8.yrro commentedon Oct 13, 2021
I think this is a dupe of #5573 actually!
gedia commentedon Nov 13, 2021
For some reason this doesn't work for me on Gentoo with sys-apps/systemd-249.5-r1. The resolvectl status output is the same as in your example (with the exception of DNSSEC being allow-downgrade/supported in my case), but when I try to resolve a hostname through the dummy interface I get a timeout. Capturing with tshark reveals no DNS traffic happening. It's not a connectivity issue cause using dig directly works, e.g.:
Is there anything specific to the systemd version I'm using affecting this workaround? Also I'm on NM 'net-misc/networkmanager-1.32.12'.
yrro commentedon Nov 13, 2021
I'd run resolved with
SYSTEMD_LOG_LEVEL=debug& check its log messages; also confirm that NM did set the dummy interfaceUP& gave it an IP address (I didn't note it in my comment above but I vaguely remember having to do that in order to get resolved to actually consider using the interface's DNS server).gedia commentedon Nov 13, 2021
Thanks for the reply @yrro. Unfortunately debug doesn't yield anything useful:
This repeats several times (from the 'Cache miss..' line onward, also trying alternative DNS entries I supplied to the dummy iface) and then I get:
I also tried assigning an RFC1918 address to dummy-dns from the same subnet as the one which has a default gateway configured on my setup (instead of a loopback address), but this doesn't seem to make any difference either. dummy-dnq is listed as UP throughout testing.
yrro commentedon Nov 14, 2021
I think the version is an issue. The workaround works for me with systemd 247, I just upgraded to 249 and now I get "resolve call failed: All attempts to contact name servers or networks failed" errors instead of observing queries going out to
8.8.8.8.DemiMarie commentedon Jan 24, 2022
Is systemd-resolved trying to send the data out the dummy interface? That would of course fail and would explain the problem.
yrro commentedon Jan 26, 2022
Indeed, between
v247andv249#11935 was fixed, which could have had the side effect of breaking the dummy interface workaround.Really this needs solving properly. At present you're better off forwarding DNS queries to dnsmasq/coredns or something else that can route queries to the appropriate recursive DNS service as described at the top of this RFE.
The dnsmasq configuration is well-known. Here's what it looks like with coredns:
DemiMarie commentedon Jan 26, 2022
It might be possible to use nftables to redirect the traffic, but I am not certain.
resolved: add concept of delegating lookups below certain domains to …
resolved: add concept of delegating lookups below certain domains to …
systemd-resolved: Add support for this via configuration
resolved: add concept of delegating lookups below certain domains to …
resolved: add concept of delegating lookups below certain domains to …
resolved: add concept of delegating lookups below certain domains to …
resolved: add concept of delegating lookups below certain domains to …
resolved: add concept of delegating lookups below certain domains to …
resolved: add concept of delegating lookups below certain domains to …
resolved: add concept of delegating lookups below certain domains to …
resolved: add new "DNS Delegate" concepts (#34368)