Canonify a Host with /canon
The /canon
rule-testing command causes
sendmail to look up the
canonical (official, fully qualified) name of a host
and print the result. The form for this command
looks like this:
/canon host
If host
is missing,
the following usage message is printed:
Usage: /canon address
When you correctly supply the hostname as the argument, sendmail looks up the canonical name and returns the result:
> /canon icsic
getcanonname(icsic) returns icsic.icsi.berkeley.edu
>
Here, the hostname icsic
was looked up. Because its
canonical name was found, that name is printed
following the returns
. If the hostname had not been
found, sendmail would have
printed that same name after the returns
:
> /canon foo
getcanonname(foo) returns foo
If you wish to watch the actual process of a host
being canonified, you can turn on the -d38.20
debugging switch
(-d38.20 on page 568) with the
rule-testing -d
command (Add Debugging for Detail
on page 318):
> -d38.20
>
With that setting, the previous lookup of icsic
produces a trace
of all the steps that sendmail
takes:
> /canon icsic
getcanonname(icsic), trying dns
getcanonname(icsic), trying files
text_getcanonname(icsic)
getcanonname(icsic.icsi.berkeley.edu), found
getcanonname(icsic) returns icsic.icsi.berkeley.edu
Here, sendmail first looked up
icsic
using
DNS. That lookup failed, so
sendmail fell back to looking
it up in the /etc/hosts file,
where it was found. The order in which these
techniques are tried is defined by your service
switch (ServiceSwitchFile ...
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.