Saturday, 22 November 2008

Sendmail stat=Deferred: Name server: host name lookup failure

It's a saturday. I have just spent 4 1/2 hours making sendmail actually work on a development server. All other websites I found gave me useless information on how to fix this, So I thought I'd post my fix here to Save countless hours of your weekend....

I kept receiving the followingerror

stat=Deferred: Name server: host name lookup failure

in my maillog file.

The main crox of the problem is that I set up a FC9 development server on my local network without installing Bind. At the time I didn't want to use Bind, which is a common thing not to have on a development server. However, sendmail doesn't look at my hosts file to resolve network addresses... oh no, why be so simple! instead isendmail decides to ignore my hosts file and visits the router to find out where localhost is. Therefore, to fix this problem, you need to install bind and just setup a localhost.

You Need to install Bind on your server to get Sendmail to work.



Don't rely on your hosts file. If you are unfamiliar with using Bind, on fedora you can just type; yum install bind bind-chroot. You can setup a simple configuration using this guide.

After you have Bind setup, you will then need to edit your network settings to make sure all DNS requests look to your server first, before going to the internet to resolve. So edit this file;

vi /etc/sysconfig/networking/devices/ifcfg-eth0

and change

DNS1=192.168.1.1

to

DNS1=127.0.0.1
DNS2=192.168.1.1

Restart your server and make sure that sendmail and bind are both up and running. Then try crossing your fingers, finding some wood to touch and then sending an email.

For me, this worked a treat and shows in my case that Sendmail completely ignores my hosts file and goes straight for the servers primary DNS setting.

6 comments:

Anonymous said...

Cheers!

You did indeed save me a whole lot of messing around! If you were in Auckland I would shout you a beer =)

Also my box was Slackware 12 and I needed to also flush the message queue (using webmin) and run /etc/rc.d/rc.sendmail restart

Website Development said...

Nice collection.I think it is a good blog.Thank you Sir.

a said...

thanks for your post. sendmail and dns interaction has been giving me a variety of new and unique problems on fc8 periodically for the past 6 months or so.

in at least one case the problem was due to an automatic update that broke my config.

you can get sendmail to work without local bind tho,

look in /etc/nsswitch.conf
find the line that begins with hosts:

make sure this looks something like:

hosts: files dns

sendmail8 will respect this setting and resolve names against your local hosts file first, then go to dns.

one update I got not too long ago clobbered this file with something like:

hosts:mdns4_minimal [NOTFOUND=return] dns

assumes you have a microsoft dns, which is kind of weird for a linux system, but more to the point, fails if notfound there, never querying dns.

Website Design Web Development Company said...

Thank you sir for this great discussion.

Ecommerce Website Design Company said...

The post on this site is the best I have ever seen! Your post is nice and also knowledgeable for the newbie . I like it, thanks, as you submitted here your good experienced knowledge.

bfluri said...

thank you very much! we were digging around a long time to find the resolution problem. now it works :)