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@pigletI 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 nameAdd 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. > $3So, 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.