Since my router does not resolve hostnames of LAN devices, I setup my server to act as a DNS using DNSMASQ.
DNS Server Specs ---------------- OS: Ubuntu Server LAN IP: 192.168.1.4
I have a second server for streaming media on the network, which runs kodi, and apache2 so I can control the machine via a web interface I wrote.
Media Server Specs ------------------ LAN IP: 192.168.1.10 HOSTNAME: media.lan
My router is configured so that it uses my local DNS server for DNS lookups. I also added an entry for my media server to /etc/hosts on my DNS server.
If I run
dig media.lan on any machine on my network , I get this:
; <<>> DiG 9.10.6 <<>> media.lan ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41974 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;media.lan. IN A ;; ANSWER SECTION: media.lan. 0 IN A 192.168.1.10 ;; Query time: 2 msec ;; SERVER: 192.168.1.4#53(192.168.1.4) ;; WHEN: Tue Dec 17 16:06:24 CET 2019 ;; MSG SIZE rcvd: 54
Which gives the impression that everything is working just fine. The proper DNS server is being contacted and the right IP address for media.lan returned. However, if I try to
ping media.lan on any machine, I get the following error:
ping: cannot resolve media.lan: Unknown host
And Firefox does not find the server either. If I ping the IP of media.lan, I get a response. My setup was working perfectly fine 30 minutes ago and I did not update anything. Pinging google.com works without any issues. What the hell is going on? Why is dig getting the correct response but all other DNS lookups for local hostnames seem to fail?
Contents of /etc/nsswitch.conf (of the DNS server):
# /etc/nsswitch.conf # # Example configuration of GNU Name Service Switch functionality. # If you have the `glibc-doc-reference' and `info' packages installed, try: # `info libc "Name Service Switch"' for information about this file. passwd: compat systemd group: compat systemd shadow: compat gshadow: files hosts: files dns networks: files protocols: db files services: db files ethers: db files rpc: db files netgroup: nis
nameserver 127.0.0.53 options edns0 search home