getent hosts app.example.test returns 192.0.2.20, but dig app.example.test A returns a different address.
Check for an NSS files-based local override.
Which file should be checked first?
getent can read /etc/hosts through the NSS files service, while dig normally queries DNS directly and ignores that local mapping.
Detailed explanation
/etc/hostsCorrect. It stores local address and hostname mappings.
Correct. It stores local address and hostname mappings.
/etc/servicesIncorrect. It maps services to ports, not host addresses.
Incorrect. It maps services to ports, not host addresses.
/etc/hostnameIncorrect. It stores the local host's static hostname.
Incorrect. It stores the local host's static hostname.
/etc/gai.confIncorrect. It adjusts address-selection policy rather than storing name mappings.
Incorrect. It adjusts address-selection policy rather than storing name mappings.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' 'getent hosts -> NSS/files may read /etc/hosts' 'dig -> DNS query, ignores hosts mapping'Expected result
getent hosts -> NSS/files may read /etc/hosts
dig -> DNS query, ignores hosts mappingKey points
- /etc/hosts is a local override
- getent follows NSS
- dig queries DNS directly
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.