reverse dns problem (again sorry!)

Kevin Darcy kcd at daimlerchrysler.com
Tue Aug 22 21:14:06 UTC 2000


Paul wrote:

> Kevin Darcy wrote:
>
> > Paul Hill wrote:
> >
> > > Hi
> > >
> > > This is driving me mad.
> > >
> > > I have a linux server with a dns server that works fine.  The nslookup
> > > works fine for all the reversed IP numbers.  However the client I am
> > > using (windows 98) uses a application that I have written that uses a
> > > function called gethostbyname.  If I pass this function the actual name
> > > of the server then it is fine (i.e. mcpc.priv.ate)  However If I pass it
> > > the IP address 192.168.1.1 it hangs for good while before eventually
> > > connecting and proceeding.
> > >
> > > I've run "named" in debug mode and I can see the connection request
> > > 192.168.1.1 coming in but not matching.  This is rediculout as I can
> > > match it on the server with the nsloopup function.  Is this a reverse
> > > problem.  Oh by the way the network is totally isolated (just client and
> > > server) so there is no deferment.
> >
> > gethostbyname() maps names to IP addresses. To map an IP address to a name,
> > use gethostbyaddr().
> >
> > - Kevin
>
> True, but the thing is that when I use the application using gethostbyname
> between two machines on the University (i.e. using the university DNS system)
> entering the IP address into gethostbyname works fine.  This may seem a little
> bit perverse but I have another application (without source) that I need to use
> that obviously uses gethostbyname without checking gethostbyaddr first.

It's possible that some versions of gethostbyname() may recognize IP addresses and
do you a favor by calling gethostbyaddr() (or some subsidiary routine) themselves.
I wouldn't rely on such behavior, though. To make your application portable, you
should always call gethostbyname() or gethostbyaddr() explicitly, depending on
whether you're trying to resolve a name or an address.


- Kevin





More information about the bind-users mailing list