Sendmail configuration to support rDNS change

My ISP kindly agreed to make the rDNS lookup of my one static IP address point to my own domain. We settled on mail.hydrus.org.uk as a generic name. I added mail.hydrus.org.uk to my DNS records on DynDNS. What I then needed to do was persuade sendmail to use that domain name for outgoing mail, so that a rDNS lookup would be consistent. My mail server's name is crimson, and I didn't want to change that.

The /etc/nsswitch.conf file on crimson specifies that files come before DNS for lookups. I could take advantage of this and placed mail.hydrus.org.uk as the first fully qualified name in /etc/hosts against 127.0.0.1.

Then, running a sendmail -d0.4 command resulted in:

  Canonical name: mail.hydrus.org.uk
   UUCP nodename: crimson
          a.k.a.: mail.hydrus.org.uk
          a.k.a.: crimson
          a.k.a.: [127.0.0.1]

  ============ SYSTEM IDENTITY (after readcf) ============
      (short domain name) $w = mail
  (canonical domain name) $j = mail.hydrus.org.uk
         (subdomain name) $m = hydrus.org.uk
              (node name) $k = crimson
  ========================================================

Now sendmail was using mail.hydrus.org.uk as it's domain name, while I could still refer to the machine as crimson internally.

Sending mail to external recipients worked just fine. However, sending mail to other machines on the local network failed, as mail.hydrus.org.uk was not defined in the local DNS. Hmm, I could define the domain name I suppose, but I could also use sendmail re-writing rules to make the sending address the real host name, rather than mail.hydrus.org.uk. Since I already had special configuration setup for local mail this was relatively easy. I added a new re-writing rule:

  R$+ @ mail $*   $1 @ $k $2      replace generic mail hostname with real node name

for both the rulesets SEnvFromSMTPNET and SHdrFromSMTPNET. Mail on the internal LAN was now working again.