Skip to content

[resolved] "search" domains not used for resolvectl low-level RR resolution #11325

Closed

Description

@bugfood

systemd version the issue has been seen with

$ systemd --version
systemd 240
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid

Used distribution

$ cat /etc/debian_version
buster/sid

Expected behaviour you didn't see

When search domains are specified, lookup for e.g. "web001" should attempt lookup for e.g. "web001.example.com".

Unexpected behaviour you saw

No attempt to append ".example.com".

Steps to reproduce the problem

  1. Domain and DNS settings as follows:
$ resolvectl domain
Global:
Link 17 (tun0): example.com
Link 16 (br1):
Link 15 (br0):
Link 13 (vnet1):
Link 12 (vnet0):
Link 5 (docker0):
Link 2 (eth0):
$ resolvectl dns
Global:
Link 17 (tun0): 10.15.11.64
Link 16 (br1):
Link 15 (br0):
Link 13 (vnet1):
Link 12 (vnet0):
Link 5 (docker0):
Link 2 (eth0):
  1. Look up FQDN; success.
$ systemd-resolve -t A --search=true web001.example.com
web001.example.com IN A 10.15.24.221                         -- link: tun0

-- Information acquired via protocol DNS in 143.1ms.
-- Data is authenticated: no
  1. Look up unqualified name; failure.
$ systemd-resolve -t A --search=true web001
web001: resolve call failed: No appropriate name servers or networks for name found

As far as I understand, using systemd-resolve bypasses any potential issues in resolve.conf or nsswitch.conf.
resolved.log

Sorry if there's already a bug open for this--I can't find one.

Thanks,
Corey

Activity

  1. changed the title [-][resolved] search[/-] [+][resolved] "search" domains not used for name resolution[/+] on Jan 4, 2019
  2. bugfood commented on Jan 4, 2019

    @bugfood
    Author

    I have since discovered that this works if I omit the -t A. From the logs, it appears that systemd-resolved is doing an SOA lookup for example.com prior to appending .example.com to the hostname. I do not know why this happens, but apparently systemd-resolved considers it necessary, and using -t A restricts it from happening.

    Thus, expected behavior would be that looking up an unqualified name via search will still work when specifying a record type.

  3. poettering commented on Jan 6, 2019

    @poettering
    Member

    resolved distuingishes RR lookups from hostnames/address lookups. The former being a low-level operation, the latter being a high-level operation. If you do the low-level operation the assumption is that you provide an fqdn already and no search domain extension is done. if you to the high-level operation the search domain logic is applied however. Hence what you are seeing is actually intended behaviour and I think it does make a lot of sense.

    This is not unlike behaviour of "dig" btw, which doesn't do search list expansion either, and is a similar low-level RR lookup tool. In contrast to our tool "dig" does have an option however to turn on search domain logic.

    Either way, I am not sure we should change behaviour here. However we probably should document this better. I hope that makes sense?

  4. bugfood commented on Jan 7, 2019

    @bugfood
    Author

    Your explanation does make sense.

    The behavior sounds reasonable too, but as a counterexample, the host tool appears to apply the domain search even when the record type is specified. Since the behavior does not seem universal, I would agree that some clarification in the man page could help.

    ...or, if possible, specifying both --search=true and -t should print an error.

    Thanks,
    Corey

  5. dR3b commented on Jan 9, 2019

    @dR3b

    Since the update to "systemd 240" I also have these problems!

    blabla@blabla ~ $ systemctl --version 
    systemd 240
    +PAM +AUDIT -SELINUX -IMA -APPARMOR +SMACK -SYSVINIT +UTMP \
    +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID \
    +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=hybrid
    
    blabla@blabla ~ $ host hostxx                             
    hostxx.home.fantasy.bla has address 172.16.2.20
    
    blabla@blabla ~ $ ping hostxx
    ping: hostxx: Name or service not known
    
    blabla@blabla ~ $ ssh hostxx 
    ssh: Could not resolve hostname hostxx: Name or service not known
    
    blabla@blabla ~ $ systemd-resolve t A --search=true hostxx
    t: resolve call failed: All attempts to contact name servers or networks failed
    A: resolve call failed: All attempts to contact name servers or networks failed
    hostxx: resolve call failed: All attempts to contact name servers or networks failed
    
    blabla@blabla ~ $ systemd-resolve t A --search=true hostxx.home.fantasy.bla
    t: resolve call failed: All attempts to contact name servers or networks failed
    A: resolve call failed: All attempts to contact name servers or networks failed
    hostxx.home.fantasy.bla: 172.16.2.20              -- link: br0
    -- Information acquired via protocol DNS in 1.6ms.
    -- Data is authenticated: no
    
    blabla@blabla ~ $ cat /etc/resolv.conf
    nameserver 172.16.2.6
    nameserver 172.16.2.4
    search home.fantasy.bla
    
  6. dR3b commented on Jan 9, 2019

    @dR3b

    Change this in /etc/nsswitch.conf:

    hosts: files mymachines myhostname resolve [!UNAVAIL=return] dns
    
    hosts: files mymachines myhostname resolve dns [!UNAVAIL=return]
    
  7. falconindy commented on Jan 10, 2019

    @falconindy
    Contributor

    Seems silly to put [!UNAVAIL=return] at the end. The lookup returns with the final status regardless of what happens.

    I'm wondering if, after 5486a31, the [!UNAVAIL=return] is actually needed at all anymore. Host lookups through getent seem to work for me even with systemd-resolved not running and a (trimmed) nsswitch.conf of:

    hosts: files mymachines myhostname resolve dns
    
  8. aaronp24 commented on Jan 10, 2019

    @aaronp24
    Contributor

    I have the same problem with a system configured to use a static IP. I specified a search domain in both /etc/systemd/resolved.conf and in the per-network file in /etc/systemd/network/enp1s0.network. resolved appears to make no attempt to use the search domain, or even DNS at all.

    Here's the failed lookup for ping testhost:
    resolved.txt

    And here's the successful lookup for ping testhost.example.com:
    resolved-fqdn.txt

    The workaround of editing /etc/nsswitch.conf does work, but makes all DNS search domain lookups take longer than they should because it takes a while before the resolve step fails and the resolver falls back to the dns step.

  9. aaronp24 commented on Jan 11, 2019

    @aaronp24
    Contributor

    I stepped through dns_query_go and the problem appears to be that in the manager for the network link, the first scope is the DNS_PROTOCOL_LLMNR one. When it calls dns_scope_good_domain, it notices a single name and returns DNS_SCOPE_YES_BASE + 1 (which has value 3) marking itself as authoritative for that name.

    Next, dns_query_go tries the DNS_PROTOCOL_DNS scope. For that one dns_scope_good_domain notices that it's a single-label query and returns DNS_SCOPE_MAYBE (value 1). Since DNS_SCOPE_MAYBE < DNS_SCOPE_YES_BASE + 1, dns_query_go skips calling dns_query_add_candidate for the DNS scope.

    The problem seems to have been caused by commit 1750854.

  10. bugfood commented on Jan 12, 2019

    @bugfood
    Author

    I was originally having some intermittent problems with the DNS search while I was connected to a VPN. I filed this ticket because I had difficulty troubleshooting and got stuck, and I haven't yet gotten back to troubleshoot more.

    @aaronp24 , if the bug you described covers my original problem, then great! I don't know enough to be able to tell for sure without some deeper learning, but I'll keep an eye out.

    Thanks,
    Corey

  11. thebodzio commented on Jan 16, 2019

    @thebodzio

    A somewhat ugly and hasty workaround is to disable LLMNR lookups in /etc/systemd/resolved.conf. Of course as long as LLMNR is not required for a given network to work properly.

  12. aaronp24 commented on Jan 16, 2019

    @aaronp24
    Contributor

    I posted a pull request to revert the problematic part of the change, if you are willing to give it a try: #11425

  13. poettering commented on Jan 21, 2019

    @poettering
  14. 9 remaining items

  15. added 2 commits that reference this issue on Feb 15, 2021
    a87cf66
    d9123d1
  16. added a commit that references this issue on Feb 16, 2021
    018b642
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions