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.
Incorrect. 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.
Incorrect. host is a DNS lookup tool, not an NSS-wide result query.
getent ahosts app.example.testCorrect. getent ahosts follows the configured NSS order.
Correct. getent ahosts follows the configured NSS order.
hostname app.example.testIncorrect. hostname concerns the local host name.
Incorrect. 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
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.