LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 06-26-2012, 05:13 PM   #1
Rohit_4739
Member
 
Registered: Oct 2010
Distribution: Red Hat
Posts: 224

Rep: Reputation: 7
sendmail ignoring hosts file ....


Hi,

I have setup a sendmail server on my local server. I have not made any changes in the default configuration, the emails are being sent and delivered fine to localhost (serv1.home.com - my localhost name).

Now i want to sent email to a my second machine which is on the same network with name (test.home.com). I have set up my /etc/hosts file properly to resolve test.home.com. However when i send email via sendmail or mutt the email gets deferred due to Name look failure. I have not set up DNS in my network but i assume sendmail should read the hosts file first before going to DNS. I did the necessary changes in /etc/nsswitch.conf also but still same issue. Here are the contents of various files. Please note i am just a beginner to sendmail so i am just running it with purely default config that i installed after building from source.
Code:
/etc/hosts
127.0.0.1     localhost
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.40.101 serv1 serv1.home.com
192.168.40.100 test test.home.com
Code:
# /etc/nsswitch.conf
#
# An example Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
#
# The entry '[NOTFOUND=return]' means that the search for an
# entry should stop if the search in the previous entry turned
# up nothing. Note that if the search failed due to some other reason
# (like no NIS server responding) then the search continues with the
# next entry.
#
# Valid entries include:
#
#       nisplus                 Use NIS+ (NIS version 3)
#       nis                     Use NIS (NIS version 2), also called YP
#       dns                     Use DNS (Domain Name Service)
#       files                   Use the local files
#       db                      Use the local database (.db) files
#       compat                  Use NIS on compat mode
#       hesiod                  Use Hesiod for user lookups
#       [NOTFOUND=return]       Stop searching if not found so far
#

# To use db, put the "db" in front of "files" for entries you want to be
# looked up first in the databases
# Example:
#passwd:    db files nisplus nis
#shadow:    db files nisplus nis
#group:     db files nisplus nis

passwd:     files
shadow:     files
group:      files

#hosts:     db files nisplus nis dns
#hosts:      files dns
hosts:      files

# Example - obey only what nisplus tells us...
#services:   nisplus [NOTFOUND=return] files
#networks:   nisplus [NOTFOUND=return] files
#protocols:  nisplus [NOTFOUND=return] files
#rpc:        nisplus [NOTFOUND=return] files
#ethers:     nisplus [NOTFOUND=return] files
#netmasks:   nisplus [NOTFOUND=return] files     

bootparams: nisplus [NOTFOUND=return] files

ethers:     files
netmasks:   files
networks:   files
protocols:  files
rpc:        files
services:   files

netgroup:   nisplus

publickey:  nisplus

automount:  files nisplus
aliases:    files nisplus
Code:
tail /var/log/maillog
Jun 26 14:07:40 serv1 -sm-mta[4590]: q5QG4FRt004064: to=<rohit@test.home.com>, ctladdr=<rohit@serv1.home.com> (502/505), delay=02:03:25, xdelay=00:00:00, mailer=esmtp, pri=1380448, relay=test.home.com., dsn=4.0.0, stat=Deferred: Name server: test.home.com.: host name lookup failure
Jun 26 14:07:40 serv1 -sm-mta[4590]: q5QG2RoZ004012: to=<rohit@test.home.com>, ctladdr=<rohit@serv1.home.com> (502/505), delay=02:05:13, xdelay=00:00:00, mailer=esmtp, pri=1380459, relay=test.home.com., dsn=4.0.0, stat=Deferred: Name server: test.home.com.: host name lookup failure
Jun 26 14:07:40 serv1 -sm-mta[4590]: q5MMY2M1008384: to=<rohit@test.home.com>, ctladdr=<stu@serv1.home.com> (501/502), delay=3+19:33:38, xdelay=00:00:00, mailer=esmtp, pri=5520436, relay=test.home.com., dsn=4.0.0, stat=Deferred: Name server: test.home.com.: host name lookup failure
Jun 26 14:07:40 serv1 -sm-mta[4590]: q5MMc3lu008406: to=<rohit@test.home.com>, ctladdr=<rohit@serv1.home.com> (502/505), delay=3+19:29:37, xdelay=00:00:00, mailer=esmtp, pri=5520448, relay=test.home.com., dsn=4.0.0, stat=Deferred: Name server: test.home.com.: host name lookup failure
Jun 26 14:07:40 serv1 -sm-mta[4590]: q5MKHu70007408: to=<rohit@test.home.com>, ctladdr=<rohit@serv1.home.com> (502/505), delay=3+21:49:44, xdelay=00:00:00, mailer=esmtp, pri=5970440, relay=test.home.com., dsn=4.0.0, stat=Deferred: Name server: test.home.com.: host name lookup failure

So could you please am i missing something or do i need to make some changes in some other files also.
 
Old 06-27-2012, 06:55 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,900

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Hi,

sendmail as any mta depends heavily on dns. You cannot just fool it using /etc/hosts, as it has to query dns for the mx record of the recipient's domain, resolve the MX IP and so on.
What you can do in your case, is to use mailertable. Open (or create if it doesn't exist the file /etc/mail/mailertable) and add
Code:
test.home.com esmtp:[192.168.40.100]
Then rebuild mailertable running
Code:
makemap hash /etc/mail/mailertable < /etc/mail/mailertable
Regards
 
1 members found this post helpful.
Old 06-27-2012, 07:02 AM   #3
Rohit_4739
Member
 
Registered: Oct 2010
Distribution: Red Hat
Posts: 224

Original Poster
Rep: Reputation: 7
Quote:
Originally Posted by bathory View Post
Hi,

sendmail as any mta depends heavily on dns. You cannot just fool it using /etc/hosts, as it has to query dns for the mx record of the recipient's domain, resolve the MX IP and so on.
What you can do in your case, is to use mailertable. Open (or create if it doesn't exist the file /etc/mail/mailertable) and add
Code:
test.home.com esmtp:[192.168.40.100]
Then rebuild mailertable running
Code:
makemap hash /etc/mail/mailertable < /etc/mail/mailertable
Regards
Thanks Bathory for taking your precious time to reply. I would surely try and let you know if it works..
 
Old 07-02-2012, 07:29 PM   #4
Rohit_4739
Member
 
Registered: Oct 2010
Distribution: Red Hat
Posts: 224

Original Poster
Rep: Reputation: 7
Hi Bathory,

I have set up the DNS in my network even then i am facing issue,sendmail for some reason says Hostname lookup failure but if i run dig query for same hostname it gets resolved.

Any suggestions ???

Here are the logs

Code:
Jul  2 20:21:02 box sendmail[2382]: q630L1gB002382: from=root, size=299, class=0, nrcpts=1, msgid=<20120703002101.GA2378@box.example.com>, relay=root@localhost
Jul  2 20:21:02 box sm-mta[2384]: q630L2KI002384: from=<root@box.example.com>, size=448, class=0, nrcpts=1, msgid=<20120703002101.GA2378@box.example.com>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Jul  2 20:21:02 box sendmail[2382]: q630L1gB002382: to=root@test.home.com, ctladdr=root (0/0), delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=30299, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q630L2KI002384 Message accepted for delivery)
Jul  2 20:21:02 box sm-mta[2386]: q630L2KI002384: to=<root@test.home.com>, ctladdr=<root@box.example.com> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120448, relay=test.home.com. [192.168.40.101], dsn=4.0.0, stat=Deferred: Name server: test.home.com.: host name lookup failure

Code:
dig test.home.com

; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> test.home.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62548
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;test.home.com.			IN	A

;; ANSWER SECTION:
test.home.com.		86440	IN	A	192.168.40.101

;; AUTHORITY SECTION:
home.com.		86440	IN	NS	test.home.com.

;; Query time: 2 msec
;; SERVER: 192.168.40.101#53(192.168.40.101)
;; WHEN: Mon Jul  2 20:27:09 2012
;; MSG SIZE  rcvd: 61
Code:
dig home.com mx

; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> home.com mx
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 760
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 2

;; QUESTION SECTION:
;home.com.			IN	MX

;; ANSWER SECTION:
home.com.		86440	IN	MX	10 serv1.home.com.
home.com.		86440	IN	MX	20 test.home.com.

;; AUTHORITY SECTION:
home.com.		86440	IN	NS	test.home.com.

;; ADDITIONAL SECTION:
serv1.home.com.		86440	IN	A	192.168.40.100
test.home.com.		86440	IN	A	192.168.40.101

;; Query time: 4 msec
;; SERVER: 192.168.40.101#53(192.168.40.101)
;; WHEN: Mon Jul  2 20:28:06 2012
;; MSG SIZE  rcvd: 115
 
Old 07-03-2012, 03:16 AM   #5
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,900

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Hi,

Quote:
Jul 2 20:21:02 box sm-mta[2386]: q630L2KI002384: to=<root@test.home.com>, ctladdr=<root@box.example.com> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120448, relay=test.home.com. [192.168.40.101], dsn=4.0.0, stat=Deferred: Name server: test.home.com.: host name lookup failure
Did you try the mailertable solution? It's valid even if you use dns.
Can box.example.com resolve test.home.com? I guess you've edited back the hosts line in /etc/nsswitch.conf to read "hosts files dns"

Run the following from both boxes and see what you get:
Code:
sendmail -bv root@test.home.com
You might need also a reverse zone in your dns for your hosts, so you can resolve IPs to hostnames

Regards
 
Old 07-03-2012, 07:52 AM   #6
Rohit_4739
Member
 
Registered: Oct 2010
Distribution: Red Hat
Posts: 224

Original Poster
Rep: Reputation: 7
Quote:
Originally Posted by bathory View Post
Hi,


Did you try the mailertable solution? It's valid even if you use dns.
Can box.example.com resolve test.home.com? I guess you've edited back the hosts line in /etc/nsswitch.conf to read "hosts files dns"

Run the following from both boxes and see what you get:
Code:
sendmail -bv root@test.home.com
You might need also a reverse zone in your dns for your hosts, so you can resolve IPs to hostnames

Regards
Yes box.example.com does resolve test.home.com as the dig result shows.
 
Old 07-03-2012, 08:54 AM   #7
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,900

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
OK, once again:
Did you try to use mailertable?
What gives
Code:
sendmail -bv root@test.home.com
from both boxes?
 
Old 07-03-2012, 09:54 AM   #8
Rohit_4739
Member
 
Registered: Oct 2010
Distribution: Red Hat
Posts: 224

Original Poster
Rep: Reputation: 7
Quote:
Originally Posted by bathory View Post
OK, once again:
Did you try to use mailertable?
What gives
Code:
sendmail -bv root@test.home.com
from both boxes?
Hi Bathory,

No i did not try mailertable, but i got it working. I do not where the issue was, what i did was put an entry for box.example.com bin the DNS and that made it working. Because i was getting name lookup error for test.home.com then i tried to send email from box.example.com locally and even that dint got delivered and logs showed error as Domain of the sender could not be resolved. Then i put the entry in hosts file and finally in DNS and now it is working. So i assume it was some Name Lookup issues only similar to what sendmail was complaining.

Thank you so much for your help and time. !!!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sendmail seems to be ignoring config file; Centos 6 Nilore Linux - Server 1 08-05-2011 07:04 PM
[SOLVED] sendmail ignoring MX records; only uses smart relay lrtward Linux - Newbie 3 03-03-2011 10:28 AM
Sendmail ignoring NIS aliases flgal3 Linux - Enterprise 3 01-08-2010 08:04 AM
slapd ignoring hosts.deny garba Linux - Security 1 09-07-2006 09:25 AM
Sendmail recently ignoring Access.db jd6strings Linux - Server 1 08-16-2006 07:45 PM


All times are GMT -5. The time now is 07:27 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration