dig app.example.test A returns the expected address, but getent hosts app.example.test returns nothing.
Check the NSS host lookup path before investigating the DNS server.
Which file should be checked first?
dig queries DNS directly, whereas getent uses NSS. Check the hosts line and modules in nsswitch.conf when their results differ.
Detailed explanation
/etc/hostnameIncorrect. /etc/hostname stores the local static hostname.
Incorrect. /etc/hostname stores the local static hostname.
/etc/nsswitch.confCorrect. It defines the hosts database service order.
Correct. It defines the hosts database service order.
/etc/servicesIncorrect. /etc/services maps service names to ports.
Incorrect. /etc/services maps service names to ports.
/etc/protocolsIncorrect. /etc/protocols maps protocol names to numbers.
Incorrect. /etc/protocols maps protocol names to numbers.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' 'dig=DNS query' 'getent hosts=NSS lookup' 'difference -> inspect nsswitch hosts line'Expected result
dig=DNS query
getent hosts=NSS lookup
difference -> inspect nsswitch hosts lineKey points
- dig and getent use different paths
- Check the hosts line
- Confirm the dns service
Notes
- Environment: 診断対応表の表示のみ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.