When a user enters db01, try db01.example.test and then db01.lab.example.test.
Configure search domains in /etc/resolv.conf.
Which line is appropriate?
search DOMAIN... supplies a list of suffixes appended to short names. Too many candidates can create unnecessary queries.
Detailed explanation
nameserver example.test lab.example.testIncorrect. nameserver expects resolver addresses.
search example.test lab.example.testCorrect. It lists the two search domains in order.
hosts: example.test lab.example.testIncorrect. hosts sources belong in nsswitch.conf, not resolv.conf.
domain example.test lab.example.testIncorrect. domain normally names one domain; search handles a list.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' 'search example.test lab.example.test' | awk '{$1=""; sub(/^ /, ""); print}'Expected result
example.test lab.example.testKey points
- search accepts multiple domains
- Append suffixes to short names
- Try in listed order
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
Search domain
A domain appended to an unqualified name during resolver lookup.
Search list
An ordered set of domains tried for a short host name.
nameserver
A resolver directive that identifies which DNS server receives the query.