List IPv4 and IPv6 socket-address candidates for app.example.test using the order in /etc/nsswitch.conf.
Do not query DNS directly only.
Which command is appropriate?
getent ahosts NAME queries through NSS and lists socket-address candidates, unlike tools that query DNS directly.
Detailed explanation
dig app.example.test ANYIncorrect. dig queries DNS directly and bypasses NSS sources such as files.
host app.example.testIncorrect. host is a DNS lookup tool, not an NSS-wide result query.
getent ahosts app.example.testCorrect. getent ahosts follows the configured NSS order.
hostname app.example.testIncorrect. hostname concerns the local host name.
Try it yourself
An example you can run in a temporary verification environment.
getent ahosts localhost | sed -n '1,6p'Expected result
localhostのSTREAM、DGRAM、RAWなどを伴うアドレス候補Key points
- getent uses NSS
- ahosts lists socket candidates
- Different from direct DNS tools
Notes
- Environment: glibc getent / ローカル名前解決のみ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
NSS
The subsystem that selects local and network sources for system lookups.
getent
A command that queries system databases through the configured NSS path.
ahosts
The getent database that returns address candidates for a host name.