host $(/bin/hostname) differs from gethostbyname(HOSTNAME)
- From: jrw32982@xxxxxxxxx
- Date: Thu, 07 Jun 2007 08:33:51 -0700
Can someone explain (roughly) the algorithm that the host command uses
to determine the IP address?
On my server, /etc/hosts maps 127.0.0.1 to HOSTNAME, and
gethostbyname(HOSTNAME) returns 127.0.0.1 as expected. However, the
host command, when given HOSTNAME, returns the actual IP address. Is
the host command bypassing /etc/hosts and/or not using gethostbyname?
Is the host command going directly to the DNS server to get the IP
address?
BTW, I'm trying to convince my sysadmin that /etc/hosts should not map
127.0.0.1 to HOSTNAME (unless the server is not on a network) because
of this exact problem, but he's not convinced because he's not seeing
any ill effects. Only my code, which uses gethostbyname(HOSTNAME), is
exhibiting the problem of finding the wrong IP address.
Thanks!
.
- Follow-Ups:
- Re: host $(/bin/hostname) differs from gethostbyname(HOSTNAME)
- From: Barry Margolin
- Re: host $(/bin/hostname) differs from gethostbyname(HOSTNAME)
- Prev by Date: Re: unix performance monitoring
- Next by Date: new user cannot access UNIX share
- Previous by thread: Newbie Question - How to use SFTP & to replace FTP in shell script
- Next by thread: Re: host $(/bin/hostname) differs from gethostbyname(HOSTNAME)
- Index(es):
Relevant Pages
|
|