I have a couple of local domains resolved to 127.0.0.1 in my /etc/hosts file. And it was all alright for a period of time but now when I run:
nslookup test.local
It results in:
Server: 192.168.1.3
Address: 192.168.1.3#53
** server can't find test.local: NXDOMAIN
The 192.168.1.3 is our network DNS and it's not supposed to know my local domain test.local. After a couple of searches I found that /etc/nsswitch.conf file holds information on the priority of the DNS sources to query by. But there was no problem there! Here's mine:
# /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
group: compat
shadow: compat
hosts: files mdns4_minimal [NOTFOUND=return] dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
So does anyone know why my hosts file is not included in DNS look-up?
pingone should be usinggetent ahostsbecause that does not require all the extra stuff thatpinghas. – Mikko Rantalainen Oct 02 '17 at 10:09getentfor years for user & group info - had no idea it could handle DNS. – colm.anseo Oct 06 '22 at 21:20nslookupis definitely using/etc/hostson Ubuntu 22.04. I see inresolv.confthat mynameserveris set to 127.0.0.53, though. So that's not an actual DNS server, it's asystemd-resolved"stub resolver" which I assumes also uses/etc/hostsas a data source. – Frans Sep 17 '25 at 06:47