[Info-vax] Which name is returned by the gethostbyaddr(<IP address>) in the hostent h_name field
jbriggs444
jbriggs444 at gmail.com
Fri Jul 22 08:11:21 EDT 2011
On Jul 22, 2:59 am, Andy <andrew... at gmail.com> wrote:
> Hi,
>
> I have not had much experience with IP programming. I have some
> software that uses the gethostbyaddr(<IP address>) hostent h_name
> field to do some checking.
>
> Is this the name of the host,i.e. the name returned by the hostname
> command, or the network interface?
It is a routine that attempts to return the host name that corresponds
to the IP address provided by the caller.
In the Unix world, this routine is often a stub. The actual mechanics
of looking up the IP address and finding the corresponding host name
is then determined based on configuration file settings with an
underlying resolver routine being dynamically selected at run time.
In the Unix world, this would be controlled in places like /etc/
nsswitch.conf.
So the lookup from IP address to host name could come from, for
instance:
1. The hosts file (or VMS host name table)
2. DNS (with specifiable servers)
3. WINS
4. Yellow Pages/NIS
In my experience, the host name that is returned has nothing
whatsoever to do with the host name that is configured into the
machine at the target IP address -- the routine does not reach
out into the network and ask the target machine for its canonical
host name.
Of course, folks usually try to maintain some consistency in these
matters -- so that reverse DNS is the mirror image of forward DNS,
hosts files match DNS databases match internally configured host
names, etc.
More information about the Info-vax
mailing list