HOWTO: Prevent Sendmail From Using DNS
This HOWTO details disabling DNS in Sendmail 8.12.x and later.
By default, Sendmail 8.12.x and later will always attempt to use MX records if it detects "
dns" in the hosts line in the
/etc/nsswitch.conf on Solaris. (I believe the same applies on Linux, but I've not verified this yet.)
At an ISP this isn't normally a problem as the ISP has access to reliable DNS servers and will forward DNS requests when necessary, however in the corporate world this can be a real problem with things like firewalls getting in the way, and internal only DNS servers.
In the event Sendmail can't canonify the recipient domain, it will queue the email and report something along the lines of:
$ domain.com: Name server timeout
email@example.com... Transient parse error -- message queued for future delivery
Now the easiest way is to remove "
dns" from the hosts line in
/etc/nsswitch.conf, however this also means you can't use DNS for your local domains.
The better way is to change Sendmail's configuration and this is what I'll detail here.
.mcfiles, the method of generating the
.cffiles and restarting Sendmail may vary slightly.
sendmail(1M)for more details). If you wish to continue running in "Local Only Mode", replace all references to
1. Change into the directory that contains the macro configuration (
2. Make a copy of the
# cp submit.mc nodns-submit.mc
3. Add the following lines to the new
nodns-subsidiary.mc file just above the "
FEATURE(`nocanonify')dnl define(`SMART_HOST', `[mailhost]')dnl
4. Ensure you have an entry in your /etc/hosts file for the hostname "
5. Comment out the "
confFALLBACK_SMARTHOST" line by placing "dnl" at the beginning of the line in the new
6. Add the following line to the new
nodns-submit.mc file after all the other "
7. Generate the new
.cf files (note the filename used is the same as the file we edited, except the extension is now
.cf instead of
test ! -f nodns-subsidiary.cf || /usr/bin/mv nodns-subsidiary.cf nodns-subsidiary.cf.prev
/usr/ccs/bin/m4 ../m4/cf.m4 nodns-subsidiary.mc > nodns-subsidiary.cf
# /usr/ccs/bin/make nodns-submit.cf
test ! -f nodns-submit.cf || /usr/bin/mv nodns-submit.cf nodns-submit.cf.prev
/usr/ccs/bin/m4 ../m4/cf.m4 nodns-submit.mc > nodns-submit.cf
8. Make a backup of the current files:
# cp /etc/mail/submit.cf /etc/mail/submit.cf.orig
9. Put the new files into place:
# cp /usr/lib/mail/cf/nodns-submit.cf /etc/mail/submit.cf
10. Restart Sendmail
Thats it. Sendmail will no longer query DNS and will instead blindly forward all emails destined for users remote to the local machine to the "
mailhost". It's then up to this machine to query a reliable interface facing DNS server. This is commonly a machine managed by an ISP.