[comp.mail.sendmail] MX records, NAMED_BIND, and aliases in /etc/hosts

jim@jagmac2.gsfc.nasa.gov (Jim Jagielski) (07/20/90)

I've been working on a port of 5.64 to A/UX... the port is pretty straight-
forward, but there is one area where I'm stuck. Any help would be great.

It seems when sendmail is compiled with NAMED_BIND defined, then nameserver
support is incorporated. This is fine. However, sendmail will then refuse
to use or recognize any and all aliases in /etc/hosts. For example, if a
line in /etc/host is:

128.183.44.2    unixbox.gsfc.nasa.gov   tryme

and one tries to mail to foo@tryme, then the mail gets bounced back with
the "host unknown" error. This is done whether the RES_* options are
in the source or commented out, so I don't think it's resolver, but I may
be wrong.

However, when sendmail is compiled without NAMED_BIND defined, then the
aliases are recognized and used. It still lets me mail stuff to hosts
NOT specified in /etc/hosts, so some nameserver functionality is maintained.

The upshot is, I need to be able to use/query MX records (and therefore
NAMED_BIND must be defined) but I also would like to be able to use aliases
in /etc/hosts (after all, they are recognized in telnet, ftp, etc...).

Please e-mail me ANY and ALL comments and suggestions... and thanks in
advance!

--
=======================================================================
#include <std/disclaimer.h>
                                 =:^)
           Jim Jagielski                    NASA/GSFC, Code 711.1
     jim@jagmac2.gsfc.nasa.gov               Greenbelt, MD 20771

"Kilimanjaro is a pretty tricky climb. Most of it's up, until you reach
 the very, very top, and then it tends to slope away rather sharply."

paul@uxc.cso.uiuc.edu (Paul Pomes - UofIllinois CSO) (07/21/90)

jim@jagmac2.gsfc.nasa.gov (Jim Jagielski) writes:

>It seems when sendmail is compiled with NAMED_BIND defined, then nameserver
>support is incorporated. This is fine. However, sendmail will then refuse
>to use or recognize any and all aliases in /etc/hosts. For example, if a
>line in /etc/host is:
>
>128.183.44.2    unixbox.gsfc.nasa.gov   tryme

Put the aliases into the nameserver as CNAMEs.

/pbp
--
         Paul Pomes

UUCP: {att,iuvax,uunet}!uiucuxc!paul   Internet, BITNET: paul@uxc.cso.uiuc.edu
US Mail:  UofIllinois, CSO, 1304 W Springfield Ave, Urbana, IL  61801-2987

jgreco@archimedes.math.uwm.edu (Joe Greco) (07/22/90)

In comp.mail.sendmail article <2850@dftsrv.gsfc.nasa.gov>, jim@jagmac2.gsfc.nasa.gov (Jim Jagielski) wrote:
:I've been working on a port of 5.64 to A/UX... the port is pretty straight-
:forward, but there is one area where I'm stuck. Any help would be great.
:
:It seems when sendmail is compiled with NAMED_BIND defined, then nameserver
:support is incorporated. This is fine. However, sendmail will then refuse
:to use or recognize any and all aliases in /etc/hosts. For example, if a
:line in /etc/host is:

The nameserver is a complete replacement for /etc/hosts, which might be used
at best for initial lookups for the nameserver.  Locally, we specify
addresses to the nameserver, so I don't think /etc/hosts is even necessary.

Therefore you can put whatever you want in /etc/hosts and it won't do a darn
thing.

:and one tries to mail to foo@tryme, then the mail gets bounced back with
:the "host unknown" error. This is done whether the RES_* options are
:in the source or commented out, so I don't think it's resolver, but I may
:be wrong.
:
:However, when sendmail is compiled without NAMED_BIND defined, then the
:aliases are recognized and used. It still lets me mail stuff to hosts
:NOT specified in /etc/hosts, so some nameserver functionality is maintained.

As I recall, NAMED_BIND is mainly used to tell sendmail to do MX lookups.
Your C library should still have the nameserver installed and running, so it
should perform host name lookups via BIND but not MX lookups.  This means
you can mail to a host for which there is an A record but not to hosts for
which there are only MX records.

:The upshot is, I need to be able to use/query MX records (and therefore
:NAMED_BIND must be defined) but I also would like to be able to use aliases
:in /etc/hosts (after all, they are recognized in telnet, ftp, etc...).

It is probably Not Really True that they are recognized in telnet, ftp, etc.
I'd guess if that you recompiled those clients to support name server, the
aliases would suddenly cease to function.  This is probably the desirable
action, anyways, as it would be a real drag having to trace down which
lookup method was producing the wrong answers.  Remember, with UNIX, library
routines are included in program binaries.  If you compile a program with a
host-table library routine as opposed to a nameserver library routine, it'll
use the host table until it is blue in the face (and you are quite red with
fury).  You have to recompile the puppy.

We've currently got a little of both on this machine, and Monday I intend to
replace every single piece of code with nameserver calls in it.  :-)  One of
my gripes with the host table routines is that sometimes they don't catch
aliases correctly.  :-|

Now, back to the subject.  It occurs to me that maybe you don't entirely
understand MX records (or perhaps CNAME records), since it would be possible
to implement aliasing in either of these fashions.  Personally, I prefer
CNAME because then you may use telnet, finger, ftp, etc with the same
nickname.  Users like consistency.  However, I believe the aliasing you
desire can be performed either way.

... Joe

Informational Content Disclaimer: I've just spent a few weeks wrestling with
DNS and named.  I believe my facts are correct.  My sendmail experience is a
little shakier.  I still believe my facts are correct.  Your mileage may vary.
-------------------------------------------------------------------------------
Joe Greco - University of Wisconsin, Milwaukee - Department of Mathematics
jgreco@archimedes.math.uwm.edu		USnail: Joe Greco
Voice: 414/321-6184				9905 W. Montana Ave.
Data:  414/321-9287 (Happy Hacker's BBS) 	West Allis, WI  53227-3329
#include <witty_and_humorous_saying.h>
Disclaimer: I don't speak for the Math Department, the University, or myself.

jim@jagmac2.gsfc.nasa.gov (Jim Jagielski) (07/23/90)

In article <5229@uwm.edu> jgreco@archimedes.math.uwm.edu (Joe Greco) writes:
>In comp.mail.sendmail article <2850@dftsrv.gsfc.nasa.gov>, jim@jagmac2.gsfc.nasa.gov (Jim Jagielski) wrote:
>
>:The upshot is, I need to be able to use/query MX records (and therefore
>:NAMED_BIND must be defined) but I also would like to be able to use aliases
>:in /etc/hosts (after all, they are recognized in telnet, ftp, etc...).
>
>It is probably Not Really True that they are recognized in telnet, ftp, etc.
>I'd guess if that you recompiled those clients to support name server, the
>aliases would suddenly cease to function.  This is probably the desirable
>action, anyways, as it would be a real drag having to trace down which
>lookup method was producing the wrong answers.  Remember, with UNIX, library
>routines are included in program binaries.  If you compile a program with a
>host-table library routine as opposed to a nameserver library routine, it'll
>use the host table until it is blue in the face (and you are quite red with
>fury).  You have to recompile the puppy.
>

I am NOT an expert, but it is my understanding that telnet, ftp, etc MUST
be using nameserver since a LOT of the places I telnet and ftp to are NOT
in my /etc/hosts file (which is actually quite short). To resolve these
names, I think nameserver must be "in the loop" somewhere... Of course,
I may be totally wrong... I'll have to look at my source for ftpd to see
how it uses BIND.

My initial concern (as I stated in the message) was that the version of send-
mail (5.59) that CAME with my Unixbox DID see and recognize the aliases in
/etc/hosts as WELL as using BIND and MX records. When I ported 5.64, this
no longer happened. I looked thru the RFCs (882 and 973) and saw the info
about CNAME, but it didn't seem to do what I wanted... true I could
use CNAME and the SRRF to create a CNAME record, but (as far as I understood
it) that was INDEPENDENT of /etc/hosts and that was NOT what I was looking
for.

To figure all this out, I snagged the source for all resolver routines and
really looked at them. res_search (and it's "brothers" all contact the
nameserver, but gethostbyname() also looks at /etc/hosts if either BIND
isn't running or if nameserver queries fail...

What I did then, was pretty straightforward... after the queries are made,
I added code that simply checked if the query failed due to "HOST_NOT_FOUND"
If so, I then call gethostbyname, which will also query but will also peek
in /etc/hosts. True, this does add time, but only when aliases are used.
For fully qualified names, this is not even done.

I am also surprised that not one person mentioned the use of the
HOSTALIASES variable, which is something totally different...

--
=======================================================================
#include <std/disclaimer.h>
                                 =:^)
           Jim Jagielski                    NASA/GSFC, Code 711.1
     jim@jagmac2.gsfc.nasa.gov               Greenbelt, MD 20771

"Kilimanjaro is a pretty tricky climb. Most of it's up, until you reach
 the very, very top, and then it tends to slope away rather sharply."