The $[and $] Operators
The $[
and $]
operators (Canonicalize Hostname: $[ and $] on page 668) are used to canonicalize a hostname.
Here is a simplified description of the
process.
Each lookup is actually composed of many lookups that occur in the form of a loop within a loop. In the outermost loop, the following logic is used:
If the hostname has at least one dot somewhere in it, sendmail looks up its address unmodified first.
If the unmodified hostname is not found and the RES_DNSRCH bit is set (the
ResolverOptions
option, ResolverOptions on page 1080), sendmail looks up variations on the domain part of the address. The default domain is tried first (for a host in the sub-subdomain at dc.gov, that would be sub.dc.gov, thus looking up host.sub.dc.gov). If that fails, BIND 4.9 and above use thesearch
attribute, if given, and try that list of possible domains. BIND 4.8 then throws away the lowest part of the domain and tries again (looks up host.dc.gov).If the hostname has no dots and the RES_DEFNAMES bit is set (the
ResolverOptions
option, ResolverOptions on page 1080), sendmail tries the single default domain (looks up host.sub.dc.gov). This is for compatibility with older versions of DNS.
Each lookup just described is performed by using the following three steps:
Prior to V8.12 sendmail, try the hostname with a T_ANY query that requests all the cached DNS records for that host. If it succeeds, IPv6 AAAA records, IPv4 A records, and/or MX records might be among those returned. However, ...
Get sendmail, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.