This is the mail archive of the
libc-alpha@sourceware.cygnus.com
mailing list for the glibc project.
gethostbyname and multiple addresses for one host
- To: libc-alpha Mailinglist <libc-alpha@sourceware.cygnus.com>
- Subject: gethostbyname and multiple addresses for one host
- From: Andreas Jaeger <aj@arthur.rhein-neckar.de>
- Date: 03 Jul 1999 14:04:42 +0200
- Cc: Matthias Barnutz <barney@nef.wh.uni-dortmund.de>
Matthias described a problem with his setup and gethostbyname. His
/etc/hosts contains:
10.0.0.254 emil.nef.wh.uni-dortmund.de emil
127.0.0.1 localhost
129.217.240.1 emil.nef.wh.uni-dortmund.de emil
129.217.255.132 emil.nef.wh.uni-dortmund.de emil
129.217.255.249 emil.nef.wh.uni-dortmund.de emil
and gethostbyname ("emil") only returns the first IP address but
should return all IP addresses. I checked all documentation I could
find for the format of /etc/hosts and only Solaris 7 mentioned this
case:
The hosts file has one entry for each IP address of each
host. If a host has more than one IP address, it will have
one entry for each, on consecutive lines. The format of each
line is:
IP-addressofficial-host-namenicknames...
Items are separated by any number of SPACE and/or TAB char-
acters. The first item on a line is the host's IP address.
The second entry is the host's official name. Subsequent
entries on the same line are alternative names for the same
machine, or "nicknames." Nicknames are optional.
For a host with more than one IP address, consecutive
entries for these addresses may contain the same or differ-
ing nicknames. Different nicknames are useful for assigning
distinct names to different addresses.
A call to gethostbyname(3N) returns a hostent structure con-
taining the union of all addresses and nicknames from each
line containing a matching official name or nickname.
Matthias' /etc/hosts doesn't contain email on consecutive lines -
there the localhost between. Nevertheless (just checked) this doesn't
work.
Is this a bug in glibc?
Andreas
--
Andreas Jaeger aj@arthur.rhein-neckar.de jaeger@informatik.uni-kl.de
for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de