How to Remove a Host from Sendmail's Class w

Weldon Whipple <weldon@whipple.org>


Introduction

Sendmail's class w ($=w) is the set of all hosts and IP addresses (etc.) for which sendmail will accept and (attempt to) deliver mail locally.

You can see the contents of your sendmail's class w by issuing this command on your server as root:

# echo '$=w' | sendmail -bt

You will probably become aware of the need to remove an entry from class w if your MX server (for example) is mail.whipple.org, but you are logged onto whipple.org and want to send e-mail to fred@whipple.org. Instead of going to mail.whipple.org, the local server will attempt to deliver it to fred's local mailbox (which may or not exist on whipple.org).

There are several ways that hosts/domains are added to class w. Here are some of the ways:

Ways to Remove an Entry from Class w

Change the sendmail.cf File

Try the following, if they apply:

  1. Remove entries from /etc/mail/local-host-names
  2. Remove the host/domain name from a LOCAL_DOMAIN entry in the mc file, then regenerate your sendmail.cf
  3. Tell sendmail not to probe interfaces with by inserting the following line in your mc file:
    
    define(`confDONT_PROBE_INTERFACES', `true')dnl
    

Rename Your Server

If the host name you want to remove happens to be the hostname of your server, it is probably easiest to rename your server. (This will remove the name from class w, as well as add the server's new name to class w).

If I want to remove whipple.org from class w, I could rename the server to frodo.whipple.org, www.whipple.org, elvis.whipple.org, for example.

Add a Custom LOCAL_RULE_0 to the Sendmail Macro Configuration File

Use this as a last resort. (It actually involves modifying the sendmail.mc/cf file, but I didn't include it above because it is the least desirable solution! Also, unless you are very careful, you can break your sendmail configuration)

The example below illustrates a situation where the mail server for the whipple.org domain is named mail.whipple.org--the DNS MX record points to mail.whipple.org. This solution fixes the condition where other hosts on the Net send mail to mail.whipple.org correctly, but mail originating from the host named whipple.org, destined for someone@whipple.org, is unable to leave the whipple.org server.

If your mc file doesn't already have a LOCAL_RULESETS section, add one. If it does, just add the LOCAL_RULE_0 line--and the line following it--to the existing LOCAL_RULESETS section:

LOCAL_RULESETS
LOCAL_RULE_0
R$* < @whipple.org. > $*  <tab>$#esmtp $@ mail.whipple.org $: $1<@whipple.org.>$2
The LOCAL_RULESETS section generally goes last in the sendmail mc file.

Be sure to replace <tab> with an actual tab character! (Press the tab key in your editor.)

After modifying the mc file, generate a new sendmail.cf file (making a backup of your original sendmail.cf in case your new one doesn't work). Then restart sendmail. Finally, send a few e-mails to make sure sendmail works as expected.

Feedback

This document is a work in progress. Please send corrections, suggestions and additions to me.