Sendmail ignores /etc/hosts

Find an article
Jul 4
Published by in · Leave your thoughts
( words)
Warning! There was an error loading some of the images for this post.

By default, Sendmail uses DNS for name resolution, not the /etc/hosts file. The behaviour can be changed using one of the below methods:

  1. If you wish to query the hosts file before DNS servers, create a /etc/mail/service.switch file which contains the following line:
    hosts files dns

    If you wish to query ONLY the hosts file, use the following:

    hosts files

    Send Sendmail a HUP signal:

    kill -HUP `head -1 /var/run/`

    and the changes will take effect.

  2. Open (or create if it doesn’t exist the file /etc/mail/mailertable) and esmtp:[ip.addr.addr.addr]Then rebuild mailertable running:makemap hash /etc/mail/mailertable < /etc/mail/mailertableThis should take immediate effect – no need to alter the running process.

Jobs a gooden!

If you then wish to force any deferred mail currently in the queue you can use:sendmail -OTimeout.hoststatus=0m -q -vThis ensures that the cached DNS is ignored, and the new IP address is looked up.

Leave a Reply

Your email address will not be published.