Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Multiple IP Addresses For Same Host in /etc/hosts

22,183 views
Skip to first unread message

Tennis Smith

unread,
Dec 9, 2003, 5:05:54 PM12/9/03
to
Hi,

Can you have more than one address associated with a single host name
in the /etc/hosts file? Will it cause any problems?

For example, if lets say that hostA has multiple interfaces, and
therefore
multiple addresses:

1.1.1.1 hostA
2.2.2.2 hostB
3.3.3.3 hostA
4.4.4.4 hostC

Will that cause a problem?

TIA,
-Tennis

Bit Twister

unread,
Dec 9, 2003, 5:15:39 PM12/9/03
to


I would assume if I do anything using hostA, ssh, rlogin, ping,
ftp,...., host lookup will fetch 1.1.1.1.

murph

unread,
Dec 10, 2003, 3:32:19 AM12/10/03
to
Bit Twister <BitTw...@localhost.localdomain> wrote in message news:<slrnbtcicb.s...@wb.home>...

I'm not sure but i think yes
It is possible to have more than one IP on one interface (you create
virtual interface) and there should be no problem also with more
interfaces

Ian Fitchet

unread,
Dec 10, 2003, 5:01:39 AM12/10/03
to
tennis...@yahoo.com (Tennis Smith) writes:

> Can you have more than one address associated with a single host name
> in the /etc/hosts file? Will it cause any problems?

On Solaris you must put the IPs for any individual host on adjacent
lines in hosts. Your original hosts would only let a resolver
discover 1.1.1.1 for hostA, whereas:

1.1.1.1 hostA
3.3.3.3 hostA
2.2.2.2 hostB
4.4.4.4 hostC

would mean a resolver will find 1.1.1.1, 3.3.3.3 for hostA. It's a
subtle difference and can make/break your applications.

The man page says:

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.


Cheers,

Ian

Doug Freyburger

unread,
Dec 10, 2003, 2:03:49 PM12/10/03
to
Tennis Smith wrote:
>
> Can you have more than one address associated with a single host name
> in the /etc/hosts file? Will it cause any problems?

Sure, no problem.

> For example, if lets say that hostA has multiple interfaces, and
> therefore multiple addresses:
>
> 1.1.1.1 hostA
> 2.2.2.2 hostB
> 3.3.3.3 hostA
> 4.4.4.4 hostC


No, that's four different hosts. You're aware that a string comparison
of "hostA" and "hostB" will come out different, right? Also forget case:

1.1.1.1 hosta host
2.2.2.2 hostb host
...

Moshe Ivgy

unread,
Apr 16, 2014, 5:07:17 AM4/16/14
to
which manual page says that?
The Unix man page for hosts does NOT say that..
http://unixhelp.ed.ac.uk/CGI/man-cgi?hosts

Barry Margolin

unread,
Apr 16, 2014, 11:20:38 AM4/16/14
to
In article <7de1b3e1-5d09-4d1b...@googlegroups.com>,
He said "Solaris" on the first line of the reply.

> The Unix man page for hosts does NOT say that..
> http://unixhelp.ed.ac.uk/CGI/man-cgi?hosts

That man page is for Linux. It's also about a dozen years old. Although
not as old as the one on my Snow Leopard system, which claims to be from
1993! But I don't believe it, because it mentions both IPv6 and Mac OS
X, neither of which existed 20 years ago.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

Casper H.S. Dik

unread,
Apr 16, 2014, 12:25:21 PM4/16/14
to
Barry Margolin <bar...@alum.mit.edu> writes:

>> On Wednesday, December 10, 2003 12:01:44 PM UTC+2, Ian Fitchet wrote:

>> > The man page says:
>> >
>> > 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.
>> >
>> >
>> > Cheers,
>> >
>> > Ian

...

>>
>He said "Solaris" on the first line of the reply.

I don't think this is enforced.

What actually happens is that we read the /etc/hosts file in
nscd and hash it; when we lookup the hostname we will return
all the entries that are found in that hashbucket and match
the hostname.

Casper
0 new messages