Look in local files first and query DNS only when no local mapping is found.
Which nsswitch.conf line is appropriate?
hosts: files dns searches local hosts data before DNS.
Detailed explanation
hosts: dns filesIncorrect. It queries DNS before local files.
Incorrect. It queries DNS before local files.
networks: files dnsIncorrect. networks is a different database.
Incorrect. networks is a different database.
hosts = files,dnsIncorrect. nsswitch uses a colon and whitespace-separated services.
Incorrect. nsswitch uses a colon and whitespace-separated services.
hosts: files dnsCorrect. It selects files, then DNS.
Correct. It selects files, then DNS.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' 'hosts: files dns' | cut -d' ' -f1-3Expected result
hosts: files dnsKey points
- hosts database
- Services evaluated left to right
- files is local mapping
Notes
- Environment: POSIX awkによる構文確認
- 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.