Score:0

Local DNS not resolving local hostname but DIG does

in flag

I cannot figure out why this behavior. I have two pihole instances running in docker containers on 10.0.2.205 and 10.0.2.206 (sync'd). Running resolvectl status on the local pc/server results in the correct DNS Resolvers being used, including the tertiary IP 1.1.1.1; all handed out by my DHCP server. Both local DNS (pihole) resolve as expected.

My problem, I spin up a new server and run into this issue every time and I would like to once and for all be done with this. I don't think this should require overwriting the /etc/resolv.conf file every time I spin up a server.

The server can ping whatever, just nothing that is set as a local DNS entry in pihole. However, I can dig @10.0.2.205 <local_hostname> and get a result/IP. So the DNS resolver returns the IP address for the local DNS entry for the local hostname, as expected. But I can't ping the DNS hostname. If, however, I overwrite the /etc/resolv.conf (as mentioned before) with the IP address of one or both of the pihole resolvers, then all works as expected. So I don't believe this to be a DNS resolver issue but a local issue with systemd-resolved.service or other. I've seen numerous discussions on this topic and have come to the conclusion that there's still much confusion and no real clear and straight forward answers/fixes. That I've found anyway. Any experience and info to resolve this would be most appreciated. Please advise. Thank you very much

Server info:

noc@TestingServer:~$ hostnamectl 
   Static hostname: TestingServer
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 5ab2c4f3f6d2413a9684ada5dc6e87af
           Boot ID: 1f73d83492724511821bdf91a6a8cdf1
    Virtualization: kvm
  Operating System: Ubuntu 20.04.3 LTS
            Kernel: Linux 5.4.0-91-generic
      Architecture: x86-64

**/etc/hosts (default from initial installation) **

noc@TestingServer:~$ cat /etc/hosts
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.debian.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
#     /etc/cloud/cloud.cfg or cloud-config from user-data
#
127.0.1.1 TestingServer TestingServer
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Command line

noc@TestingServer:~$ ping docker1
ping: docker1: Temporary failure in name resolution
noc@TestingServer:~$
noc@TestingServer:~$ ping docker2
ping: docker2: Temporary failure in name resolution
noc@TestingServer:~$
noc@TestingServer:~$ ping docker3
ping: docker3: Temporary failure in name resolution
noc@TestingServer:~$
noc@TestingServer:~$ cat /etc/resolv.conf 
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad
noc@TestingServer:~$
noc@TestingServer:~$
noc@TestingServer:~$ resolvectl status | grep -A2 -E 'DNS Server'
  Current DNS Server: 10.0.2.205
         DNS Servers: 10.0.2.205
                      10.0.2.206
                      1.1.1.1
noc@TestingServer:~$
noc@TestingServer:~$
noc@TestingServer:~$ dig @10.0.2.205 docker1

; <<>> DiG 9.16.1-Ubuntu <<>> @10.0.2.205 docker1
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37841
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;docker1.           IN  A

;; ANSWER SECTION:
docker1.        0   IN  A   10.0.2.10

;; Query time: 0 msec
;; SERVER: 10.0.2.205#53(10.0.2.205)
;; WHEN: Sun Dec 05 09:29:04 MST 2021
;; MSG SIZE  rcvd: 52

noc@TestingServer:~$ ping google.com
PING google.com (172.217.11.174) 56(84) bytes of data.
64 bytes from lax28s15-in-f14.1e100.net (172.217.11.174): icmp_seq=1 ttl=116 time=46.1 ms
^C
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 46.132/46.132/46.132/0.000 ms
noc@TestingServer:~$
noc@TestingServer:~$
noc@TestingServer:~$ sudo su
root@TestingServer:/home/noc# echo -e "nameserver 10.0.2.205\n" > /etc/resolv.conf
root@TestingServer:/home/noc# exit
exit
noc@TestingServer:~$
noc@TestingServer:~$ ping docker1
PING docker1 (10.0.2.10) 56(84) bytes of data.
64 bytes from docker1.local (10.0.2.10): icmp_seq=1 ttl=64 time=0.617 ms
^C
--- docker1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.617/0.617/0.617/0.000 ms

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.