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

/etc/hosts: Two lines with the same IP address?



The question has arisen in #247734:

Is it legal for /etc/hosts to contain two lines with the same
IP address?  In particular, is the following legal?:

    127.0.0.1	localhost
    127.0.0.1	pingo

What is nice about it is this:

    $ hostname
    pingo
    $ hostname --fqdn
    pingo

One can of course have:

    127.0.0.1	localhost	pingo

but then:

    $ hostname --fqdn
    localhost

I haven't run into any problems doing it the first way.  What worries
me is that hosts(5) says: 

       This file is a simple text file that associates IP addresses
       with hostnames, one line per IP address.

Should this be understood as a prohibition on multiple lines per
IP address?
--
Thomas Hood



Reply to: