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.