Look Up a Remote Host’s Name
When sendmail begins to run as a
daemon, it creates a socket, binds to that socket,
and listens for incoming SMTP connections. When a
remote host connects to the local host,
sendmail uses the
accept(2) library routine to
accept the connection. The
accept(2) routine provides
the IP address of the remote machine to
sendmail. After that, it
calls gethostbyaddr(3) or
getipnodebyaddr(3) to convert
that IP address to a canonical hostname. The
sendmail program then calls
gethostbyname(3) or
getipnodebyname(3) to find
all the addresses for that found hostname. If the
original address is not in that list,
sendmail considers the
address and hostname to be forgeries and records
that fact in its syslog
messages, its added Received
: header, and its reply to the
initial greeting:
(may be forged)
The sendmail program needs a valid canonical hostname for five reasons:
The remote hostname is compared to the local hostname to prevent sendmail from connecting to itself.
The remote hostname claimed in the HELO or EHLO SMTP line is compared to the canonical name. If they differ, sendmail adds text noting that difference to its SMTP reply, and adds both to the
Received
: header it generated.The macro
$s
is assigned the canonical hostname as its value.The canonical name is included in many log messages produced by the setting of the
LogLevel
(L
) option (LogLevel on page 1040) and is available for inclusion inReceived
: header (Received: on page 1162) lines.The canonical name is ...
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.