HOWTO: Prevent Sendmail From Using DNS

/howto-prevent-sendmail-from-using-dns 2006-06-28T10:54:31+01:00

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:

$ echo `date` | mailx -v -s "Test - `date`"
$ Name server timeout Transient parse error -- message queued for future delivery queued

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.

NOTE: This process is demonstrated using Solaris 10, however the configuration changes will apply to all operating systems, just the location of the .mc files, the method of generating the .cf files and restarting Sendmail may vary slightly.
NOTE: Sendmail on Solaris 10 (and OpenSolaris) now runs in "Local Only Mode" by default, ie remote clients will not be allowed to connect to port 25 on this host but outbound delivery will still take place (see sendmail(1M) for more details). If you wish to continue running in "Local Only Mode", replace all references to and below with and respectively.

1. Change into the directory that contains the macro configuration (.mc) files:

# cd /usr/lib/mail/cf

2. Make a copy of the and files

# cp
# cp

3. Add the following lines to the new file just above the "confFALLBACK_SMARTHOST" line:

    define(`SMART_HOST', `[mailhost]')dnl

4. Ensure you have an entry in your /etc/hosts file for the hostname "mailhost".

5. Comment out the "confFALLBACK_SMARTHOST" line by placing "dnl" at the beginning of the line in the new file.

6. Add the following line to the new file after all the other "define" lines:

    define(`confDIRECT_SUBMISSION_MODIFIERS', `C')dnl

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 .mc):

# /usr/ccs/bin/make
test ! -f || /usr/bin/mv
/usr/ccs/bin/m4 ../m4/cf.m4 >
# /usr/ccs/bin/make
test ! -f || /usr/bin/mv
/usr/ccs/bin/m4 ../m4/cf.m4 >

8. Make a backup of the current files:

# cp /etc/mail/ /etc/mail/
# cp /etc/mail/ /etc/mail/

9. Put the new files into place:

# cp /usr/lib/mail/cf/ /etc/mail/
# cp /usr/lib/mail/cf/ /etc/mail/

10. Restart Sendmail

# svcadm refresh 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.

Copyright © 2005 - 2021 Colin Seymour All rights reserved. Privacy Policy.
Check out the feed if you do the RSS/Atom thing.