[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#247734: hostname on multiple lines in /etc/hosts



> 127.0.0.1	localhost	pingo
> 10.10.0.17	pingo.miss-knife.net	pingo

On rereading the original message I realize that I overlooked the most
important fact.  The hostname, 'pingo', appears on two lines in the
/etc/hosts file.  The presence of 'pingo' on the 127.0.0.1 line causes
'localhost' to be pingo's canonical hostname whereas (I take it) the
user wants 'pingo.miss-knife.net' to be pingo's canonical hostname.
Pierre Machard: Have I got that right?

I can think of a couple of different ways of solving this problem.
The first is to eliminate 'pingo' from the 127.0.0.1 line if and
only if 'pingo' appears on some other line.

A second approach to solving the problem is to have two separate
127.0.0.1 lines, one of them at the very end.  It acts as a default
canonical hostname specifier for the machine.  Experiment shows that
this gives the Right behavior; however I am not sure that it is legal
for one IP address to appear on more than one line in /etc/hosts.

# /etc/init.d/dnsmasq restart
# cat /etc/hosts
127.0.0.1       localhost
10.10.0.17      pingo.miss-knife.net    pingo
127.0.0.1       pingo
# hostname
pingo
# hostname --fqdn
pingo.miss-knife.net
# # Note that dnsmasq (which looks in /etc/hosts) is running
# host pingo
pingo has address 127.0.0.1
pingo has address 10.10.0.17
# host 127.0.0.1
1.0.0.127.in-addr.arpa domain name pointer localhost.
1.0.0.127.in-addr.arpa domain name pointer pingo.
# vi /etc/hosts
# /etc/init.d/dnsmasq restart
# cat /etc/hosts
127.0.0.1       localhost
127.0.0.1       pingo
# hostname --fqdn
pingo
# host pingo
pingo has address 127.0.0.1
# host 127.0.0.1
1.0.0.127.in-addr.arpa domain name pointer localhost.
1.0.0.127.in-addr.arpa domain name pointer pingo.

--
Thomas




Reply to: