Technical article 111085

I want sendmail to deliver mail to machines on my LAN directly, without using the smarthost relay.

OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4OpenServer 5.0.5UnixWare 7.0.0UnixWare 7.0.1UnixWare 7.1.0UnixWare 7.1.1

Written · Last revised

Problem

Mail destined for delivery to another node on my local network is not delivered directly, but is sent to the smarthost instead. I want to avoid this relaying of mail. For example, with two machines on a local network, one named "eeyore" and one named "piglet", with a smarthost of "mail.test.dom" defined, if a user on eeyore sends a message addressed as:

user2@piglet

I want that message to go directly to the machine piglet.

Cause

By default, when a smarthost is defined in the sendmail.cf, the
smarthost will be used for relaying all non-local SMTP mail.  This
is true if Sendmail was configured using "mkdev cf" or by using
the m4 SMART_HOST macro.

Solution

To work around this, you need to modify ruleset 0 slightly. In your sendmail.cf file, search for a line toward the end of ruleset 0 that looks like this:

# pass names that still have a host to a smarthost (if defined)
R$* < @ $* > $*       $: $>95 < $S > $1 < @ $2 > $3   glue on smarthost name

Add another rewrite line just *before* the call to smarthost:

# make sure local LAN traffic does not go to $S
R$* < @ $* .$m. > $*          $#smtp $@ $2.$m. $: $1 < @ $2.$m. > $3

So, the completed section would look like this:

# make sure local LAN traffic does not go to $S
R$* < @ $* .$m. > $*          $#smtp $@ $2.$m. $: $1 < @ $2.$m. > $3
# pass names that still have a host to a smarthost (if defined)
R$* < @ $* > $*       $: $>95 < $S > $1 < @ $2 > $3   glue on smarthost name
(Note that sendmail requires the use of a tab between the
left and right side of the rule.  Make sure you use a tab
where the wide spacing is indicated above.)

You will then need to reboot the server or stop and start sendmail manually:

/etc/rc2.d/P86sendmail stop
/etc/rc2.d/P86sendmail start

See also

"sendmail", Costales and Allman, O'Reilly & Associates, 2nd ed.

From the Xinuos technical article database, record 111085. Reproduced with permission. The original is at www.sco.com/ta/111085, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.