Thursday, October 28, 2010

sendmail, Solving ‘host name lookup failure’ at name server

To solve the problem of 'host name lookup failure’ on sendmail, first you need to determine if it's really this problem.

check the /var/log/maillog , there should be entry such as below

xxxxxx sendmail[30685]: o9T3l3Pe030683: to=, ctladdr= (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=120354, relay=xxx.xxxxxx.com, dsn=4.0.0, stat=Deferred: Name server: xx.xxxx.com: host name lookup failure

Then we try to nslookup the mail server, by dig xxx.xxxxx.com. It should show that the connection is time out.

; <<>> DiG 9.3.4-P1 <<>> xxx.xxxx.com
;; global options: printcmd
;; connection timed out; no servers could be reached

Next, we can resolved this by setting up name server or put the mail server into the /etc/mail/mailertable .

First by checking the /etc/nsswitch.conf to see if we are using hosts file.
#hosts: files dns

Then do the following to create the entry in the mailertable.
xxxx.xxxx.com smtp:[xxxx.xxxx.com]

then we hash the file to the mailertable.db
makemap hash /etc/mail/mailertable < /etc/mail/mailertable

after that, restart the sendmail by running service sendmail restart

Reference link
http://davespicks.com/writing/programming/sendmailhostlookupfailure.html