Skip to content

systemd-resolved unable to resolve non-fqdn hosts #11391

Closed

Description

@lynix

systemd version the issue has been seen with

v240 (+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

Arch Linux (x86_64)

Expected behaviour you didn't see
systemd-resolved shall resolve local non-FQDN hosts (by adding the DNS search domain for the corresponding link when querying upstream servers).

Unexpected behaviour you saw
systemd-resolved fails to resolve non-fqdn hosts, without even sending out an upstream query:

$ resolvectl query myhost1
myhost1: resolve call failed: All attempts to contact name servers or networks failed

Lack of upstream query verified via tcpdump (with empty cache). It just blocks for one second and then prints the error above.

Manually adding the search domain works fine, so does resolving any other FQDN host:

$ resolvectl query myhost1.mydomain.lan
myhost1.mydomain.lan: 10.0.1.42                    -- link: net0

-- Information acquired via protocol DNS in 2.3ms.
-- Data is authenticated: no

$ resolvectl query example.com
example.com: 93.184.216.34                         -- link: net0

-- Information acquired via protocol DNS in 11.2ms.
-- Data is authenticated: no

Steps to reproduce the problem
Setup systemd-networkd for DHCP and enable DNS search domain usage as described in man(5) systemd.network:

# /etc/systemd/network/lan.network

[Match]
Name=net0

[Network]
DHCP=ipv4

[DHCP]
UseDomains=yes

Setup systemd-resolved with defaults, symlink /run/systemd/resolve/stub-resolve.conf to /etc/resolv.conf, enabling stub resolver mode.

Verify search domain has been received from DHCP:

$ resolvectl domain
Global:
Link 3 (net0): mydomain.lan
Link 2 (net1):

Query non-FQDN host:

$ resolvectl query myhost1
myhost1: resolve call failed: All attempts to contact name servers or networks failed

Query FQDN host:

$ resolvectl query myhost1.mydomain.lan
myhost1.mydomain.lan: 10.0.1.42                    -- link: net0

-- Information acquired via protocol DNS in 2.3ms.
-- Data is authenticated: no

Activity

  1. lynix commented on Jan 11, 2019

    @lynix
    Author

    Forgot to mention that I do have the issue when using "regular" applications as well (e.g. ping, ssh, etc.), so it cannot just be resolvectl acting like dig (suppressing search domain usage itself).

    And here's my NSS configuration:

    /etc/nsswitch.conf:

    # Name Service Switch configuration file.
    # See nsswitch.conf(5) for details.
    
    passwd: files mymachines systemd
    group: files mymachines systemd
    shadow: files
    
    publickey: files
    
    hosts: files mymachines myhostname resolve [!UNAVAIL=return] dns
    networks: files
    
    protocols: files
    services: files
    ethers: files
    rpc: files
    
    netgroup: files
    

    Removing the [!UNAVAIL=return] makes regular applications work again, as the names can be resolved via traditional nss-dns, but there is still a delay of ~1s from the resolve hook.

    And why should you rely on libnss_dns if you have libnss_resolve?

  2. lynix commented on Jan 11, 2019

    @lynix
    Author

    I'd consider #11325 not to be an exact duplicate as adding the record type does not work in my case:

    $ systemd-resolve -t A --search=true myhost1
    myhost1: resolve call failed: No appropriate name servers or networks for name found
    
  3. aaronp24 commented on Jan 11, 2019

    @aaronp24
    Contributor

    Adding the record type doesn't work for me either, so maybe my comment at #11325 (comment) should have been here instead.

    The problem is commit 1750854, which made link-local name resolution authoritative for both *.local and single-label lookups. It probably should have only done that for .local.

  4. smcv commented on Jan 14, 2019

    @smcv
    Contributor

    I can reproduce this on Debian unstable. Workaround:

    # /etc/systemd/resolved.conf
    [Resolve]
    LLMNR=no
    
  5. added a commit that references this issue on Jan 14, 2019
    09933b7
  6. poettering commented on Jan 18, 2019

    @poettering
    Member

    I prepped a fix in #11485. Would be excellent, if people could test this?

  7. added a commit that references this issue on Jan 18, 2019
    3aeeb49
  8. aaronp24 commented on Jan 18, 2019

    @aaronp24
    Contributor

    I prepped a fix in #11485. Would be excellent, if people could test this?

    I confirmed that this fixes it.

  9. lynix commented on Jan 21, 2019

    @lynix
    Author

    +1, works for me as well, thanks!

  10. added a commit that references this issue on Jan 22, 2019
    fea4678
  11. lynix commented on May 2, 2019

    @lynix
    Author

    Well, I'm having the same issues again with systemd-242.19:

    [lynix@thor ~]$ resolvectl domain
    Global: fritz.box
    Link 2 (lan0):
    
    [lynix@thor ~]$ ping -c 1 kodipi
    ping: kodipi: Name or service not known
    
    [lynix@thor ~]$ resolvectl query kodipi
    kodipi: resolve call failed: No appropriate name servers or networks for name found
    
    [lynix@thor ~]$ ping -c 1 kodipi.fritz.box
    PING kodipi.fritz.box(kodipi.fritz.box (10.0.0.12)) 56 data bytes
    64 bytes from kodipi.fritz.box (10.0.0.12): icmp_seq=1 ttl=64 time=0.860 ms
    
  12. andreyv commented on May 2, 2019

    @andreyv

    Confirmed on Arch Linux, and the LLMNR=no workaround doesn't seem to work this time.

  13. aaronp24 commented on May 2, 2019

    @aaronp24
    Contributor

    I confirmed this and tracked the regression down to commit 5e2a51d. This commit causes systemd-networkd to fail to populate the systemd-resolved search domains. You can tell by doing resolvectl domain and noticing that no search domains are listed.

  14. aaronp24 commented on May 2, 2019

    @aaronp24
    Contributor

    I dug into this and figured out the problem with this commit. In my configuration, there are no added search domains so link->network->search_domains is empty. This causes ordered_set_print to skip writing the DOMAINS= prefix. Then, code a few lines later writes the domainname which it expects to be on the same line as DOMAINS=, but it's not. So /run/systemd/netif/links/2 ends up containing this:

    DNS=(list of DNS server addresses)
    NTP=
    nvidia.com
    
    LLMNR=yes
    

    instead of this

    DNS=(list of DNS server addresses)
    NTP=
    DOMAINS=nvidia.com
    ROUTE_DOMAINS=
    LLMNR=yes
    

    As a result, systemd-resolved is not able to parse the search domains from this file and continues on without them.

  15. aaronp24 commented on May 2, 2019

    @aaronp24
    Contributor

    @keszybz should we file a new issue for this?

  16. ValdikSS commented on Dec 19, 2020

    @ValdikSS

    systemd 246 (v246.7-2.fc33) is unable to resolve global non-fqdn hosts. For example, ai.. ai has A and MX record, but it fails to resolve with both resolvectl query and dig:

    $ resolvectl query ai.
    ai.: resolve call failed: No appropriate name servers or networks for name found
    
  17. arvidjaar commented on Dec 20, 2020

    @arvidjaar
    Contributor

    @ValdikSS

    systemd 246 (v246.7-2.fc33) is unable to resolve global non-fqdn hosts. For example, ai.

    I see it too. Please open new issue for it, commenting in closed issue is not going to be of much help.

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