Sendmail does not accord to the hosts order in Solaris nsswitch.conf

Dear Friend,

It is strange that my sendmail does not accord to the hosts order in solaris nsswitch.conf. Please let me elaborate in details. Thank you.

Setting:
solaris 9 /etc/nsswitch.conf
hosts: file [notfound=continue] ldap dns

sendmail 8.13.4 /etc/mail/sendmail.cf
O ServiceSwitchFile=/etc/nsswitch.conf

hosts in /etc/hosts
host1, host2

hosts in ldap
host3

Testing result/problem
/usr/lib/sendmail can sendmail to user@host1 and user@host2, but it cannot email to user@host3. It complains that hosts unknown.

Setting 2: Then I remove 'dns' from /etc/nsswitch.conf:
hosts: files ldap

Testing result/problem
/usr/lib/sendmail can sendmail to user@host1 and user@host2, and also to user@host3. But sendmail cannot send email to external domain, such as user@sun.com, because dns is removed from nsswitch.conf file.

Setting 3: I change the order of files, ldap, dns in nsswitch.conf, but it is no luck.

Do you ever meet the problem? I have been in the trouble for several weeks. Any hints are deeply appreciated!

Best regards,
Jacky

After you make the changes in nsswitch.conf, did you the inetd process?

Dear bruhnf,

Thanks your reply.

I do not restart the inet process during my experiment, but after you message, I restart inet and sendmail, but sendmail still cannot send email to hosts only in ldap.

Thank you very much for your hints.

Best regards,
Jacky

Hi Jacky,

Yes, after I thought about it, I realized that your system was already "seeing" the change in nsswitch.conf because of the different result when you removed dns for test 2.

Here are a couple of questions for you...

  1. Can you send email to external domain in Test 1? You didn't mention that but I'm assuming you can.

  2. So then my next question is, what happens if you put host 3 in your /etc/hosts file and put DNS back into the nsswitch.conf file? Can you send to everything this way? If you are unable to leave host 3 in the /etc/hosts file then just try it for this test to see what happens.

You also might want to try the above test and take ldap completely out of nsswitch.conf to see if ldap is being used at all.

Hope this helps.

Bruhn

1, Yes, sendmail can.

2, Yes, if I put host 3 in /etc/hosts, sendmail can send to host 3. If I remove dns from nsswitch.conf, sendmail can send to all hosts whether it is in /etc/hosts or only in ldap. so, we can find that sendmail uses ldap, but dns interrupt the normal sendmail and nsswitch behavior. I would like to know how dns makes this, and how to solve this.

Thank you.

Best regards,
Jacky