>If I set up an MX record for "mydomain.com." that points to
>"gateway.mydomain.com." then sendmail on the gateway machine won't
>work because it refuses to talk to itself. If I set up an MX
>record for "mydomain.com." that points to "mailhost.mydomain.com."
>then I can't receive mail from the Internet, because sendmail
>(or whatever) on the Internet machines attempts to contact
>"mailhost.mydomain.com." which isn't reachable from the Internet.
The most straightforward way is to set up two MX RRs:
mydomain.com. IN MX 0 mailhost.mydomain.com.
IN MX 50 gateway.mydomain.com.
Outside host will first try to send mail addressed to xxx @
to mailhost.mydomain.com, which will fail, and it will then send
to gateway.mydomain.com instead. Machine gateway.mydomain.com will
then send it to mailhost.mydomain.com, which will be delivered
successfully. In the MX RRs, the lower the number, the higher
This does slow down the delivery to your domain, and there are
probably a few mailers out there that don't know enough to try
gateway.mydomain.com after failing mailhost.mydomain.com,
fortunately they are in the small minority nowadays.
If you are using dual (inside/outside) DNS, you can simply use
gateway.mydomain.com for MX in the DNS databse for outside and
mailhost.mydomain.com for inside, and point the resolv.conf on
gateway.mydomain.com to the inside DNS server.
Finally, if you are not afraid of fooling with sendmail.cf,
then adding a line that should look something like
R$*<@mydomain.com>$* $#ether$ @
near the top of rulset 0 in gateway.mydomain.com's sendmail.cf
should take care of your problems without using two MX RRs.
Please note that the actual contents of that sendmail rule will
have to depend on your overall sendmail.cf.
Ying-Da Lee (214)518-3490 (214)518-3552 (FAX)
Principal Member, Technical Staff
NEC Systems Laboratory, C&C Software Technology Center /
NEC USA, Corporate Network Administration Division