How does configuring both `search` and `domain` in a `/etc/resolv.conf` effect DNS short name query sequence?
Environment
- Red Hat Enterprise Linux (RHEL)
- 8
- 7
Issue
- What will the DNS search sequence be if both
search
anddomain
directives are configured in a/etc/resolv.conf
?
Resolution
- According to the implementation of
Glibc
, ifdomain
andsearch
directives are both used, only the last instance will be used for DNS queries.
Diagnostic Steps
-
The instance,
/etc/resolv.conf
shows that thedomain
directive is configured toexample.com
and followed by thesearch
directive which is configured toredhat.com
:[root@localhost etc]# cat resolv.conf nameserver 8.8.8.8 domain example.com search redhat.com [root@localhost resolv]# nslookup www Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: www.redhat.com canonical name = ds-www.redhat.com.edgekey.net. <----- Only the last instance, "search" is used for the DNS query. ds-www.redhat.com.edgekey.net canonical name = ds-www.redhat.com.edgekey.net.globalredir.akadns.net. ds-www.redhat.com.edgekey.net.globalredir.akadns.net canonical name = e3396.dscx.akamaiedge.net. Name: www.example.com Address: 184.xx.xx.xx Name: www.example.com Address: 00:00:00:00:00:aa Name: www.example.com Address: 00:00:00:00:00:aa
-
In another example, the
search
directive is configured and followed by thedomain
directive:[root@localhost etc]# cat resolv.conf nameserver 8.8.8.8 search redhat.com domain example.com [root@localhost resolv]# nslookup www Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: Name: www.example.com <------- Only the last instance, "domain" is used for the DNS query. Address: xxx.xxx.xxx.xxx Name: www.example.com Address: xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments