Skip to content

systemd-resolved "special servers" or "split horizon" #20485

Closed

Description

@andrewdunndev

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

  1. trallnag commented on Sep 18, 2021

    @trallnag

    Yep, this comes up very often at companies. The only solution I know is (as already said by OP) dnsmasq.

  2. yrro commented on Oct 13, 2021

    @yrro
    Contributor

    Can you create a dummy interface, and configure a server & routing domain on it via resolvectl commands?

    # nmcli connection add con-name dns-test type dummy ifname dummy-dns ipv4.method manual ipv4.addresses 127.0.0.88/32 ipv6.method disable ipv4.dns-search ~example.qq ipv4.dns 8.8.8.8 
    Connection 'dns-test' (a953eeaf-c506-4f7d-8f19-39aa02ae2e10) successfully added.
    

    ... which NetworkManager pushes through to systemd-resolved:

    # resolvectl status dummy-dns
    Link 9 (dummy-dns)
        Current Scopes: DNS
             Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
    Current DNS Server: 8.8.8.8
           DNS Servers: 8.8.8.8
            DNS Domain: ~example.qq
    

    I can then see queries for foo.example.qq going to 8.8.8.8.

  3. yrro commented on Oct 13, 2021

    @yrro
    Contributor

    I think this is a dupe of #5573 actually!

  4. gedia commented on Nov 13, 2021

    @gedia

    Can you create a dummy interface, and configure a server & routing domain on it via resolvectl commands?

    # nmcli connection add con-name dns-test type dummy ifname dummy-dns ipv4.method manual ipv4.addresses 127.0.0.88/32 ipv6.method disable ipv4.dns-search ~example.qq ipv4.dns 8.8.8.8 
    Connection 'dns-test' (a953eeaf-c506-4f7d-8f19-39aa02ae2e10) successfully added.
    

    ... which NetworkManager pushes through to systemd-resolved:

    # resolvectl status dummy-dns
    Link 9 (dummy-dns)
        Current Scopes: DNS
             Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
    Current DNS Server: 8.8.8.8
           DNS Servers: 8.8.8.8
            DNS Domain: ~example.qq
    

    I can then see queries for foo.example.qq going to 8.8.8.8.

    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.:

    dig example.qq @127.0.0.53 -> timeout
    dig example.qq @'Current DNS Server for ~example.qq' -> OK
    

    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'.

  5. yrro commented on Nov 13, 2021

    @yrro
    Contributor

    For some reason this doesn't work for me on Gentoo with sys-apps/systemd-249.5-r1

    I'd run resolved with SYSTEMD_LOG_LEVEL=debug & check its log messages; also confirm that NM did set the dummy interface UP & 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).

  6. gedia commented on Nov 13, 2021

    @gedia

    Thanks for the reply @yrro. Unfortunately debug doesn't yield anything useful:

    Processing query...
    Received dns UDP packet of size 51, ifindex=0, ttl=64, fragsize=0
    Got DNS stub UDP query packet for id 25407
    Looking up RR for example.qq IN A.
    Cache miss for example.qq IN A
    Firing regular transaction 398 for <example.qq IN A> scope dns on dummy-dns/* (validate=yes).
    Using feature level UDP+EDNS0+DO+LARGE for transaction 398.
    Using DNS server `Current DNS Server` for transaction 398.
    Switching to DNS server `Current DNS Server` for interface dummy-dns.
    

    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:

    Regular transaction 398 for <example.qq IN A> on scope dns on dummy-dns/* now complete with <attempts-max-reached> from none (unsigned; non-confidential).
    Freeing transaction 398.
    

    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.

  7. yrro commented on Nov 14, 2021

    @yrro
    Contributor

    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.

  8. DemiMarie commented on Jan 24, 2022

    @DemiMarie

    Is systemd-resolved trying to send the data out the dummy interface? That would of course fail and would explain the problem.

  9. yrro commented on Jan 26, 2022

    @yrro
    Contributor

    Indeed, between v247 and v249 #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:

    . {
      forward . 192.0.2.53
      forward special-domain.example.com 203.0.113.53
    }
    
  10. DemiMarie commented on Jan 26, 2022

    @DemiMarie

    Indeed, between v247 and v249 #11935 was fixed, which could have had the side effect of breaking the dummy interface workaround.

    It might be possible to use nftables to redirect the traffic, but I am not certain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions