Re: Host: fqdn

Michael Shapiro writes:
> Is it known how to convert a non-fqdn to a fqdn in exactly the
> same way that gethostbyname() does it when it looks up the IP address?
You should read man pages for gethostbyname and resolver and/or resolv.conf
on your system.
I did that under linux, and wrote a minimal perl package to get fqdn.
Usage: &resolver'getfqdn(hostname);
The subroutine tries to figure out the fqdn version of the name given and
returns the CNAME, not the official form. (To support multi-indentity servers.)
You can pick it at http://spike.fa.gau.hu/~bne/resolver.pl
A test program for it is at http://spike.fa.gau.hu/~bne/gethost.pl
I use perl5.
> My experiments with the hostent returned by gethostbyname() did not
> have the fqdn in certain cases.  I looked at Mac/Windows/Unix
> gethostbyname() and the Unix version did not return the fqdn.
> 
>     hostent = gethostbyname("sdg")
> 
> should have set hostent->h_name to "sdg.ncsa.uiuc.edu" but it only was
> set to "sdg".
I guess sdg is in the /etc/hosts file and the result is not coming from dns.
> (Note - the Mac and Windows version of gethostbyname() did set
> hostent->h_name to the fqdn "sdg.ncsa.uiuc.edu").

Andrew. (Endre Balint Nagy) <bne@bne.ind.eunet.hu>

Received on Wednesday, 4 October 1995 00:16:10 UTC