Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it normal to put a machine's own network IP's into /etc/hosts ? I've never seen it done before, and i'm pretty sure it's a bad idea...

There's a cultural habit here of /etc/hosts files that look like this:   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6 servername

Surely this isn't the right thing to do? The last time this tripped me up was today with SRV records for a pair of freeipa servers.

edit: edited for a little clarity

share|improve this question
up vote 1 down vote accepted

Yes, this is completely normal, and is generally a good idea.

In theory, you can use DNS to resolve this for you, but DNS is less reliable than /etc/hosts--especially at times when the network may not be reachable, such as during startup or shutdown, to say nothing of network outages or other transient problems.

share|improve this answer
The local loopback interface ones (as in localhost) i wasn't bothered by, as that's how it looks from a clean Centos / RHEL install. The bit that i'm not sure is a good idea is the bit. i.e: hardcoding the local LAN ip into the machines own /etc/hosts file. – Sirex Jun 12 '13 at 3:58
That's also normal and expected. You could, in theory, set up DNS to handle that instead, but if your DNS server ever goes down, or is unreachable (say, during startup, before the network comes up), your system could be very confused about its own identity. – Flimzy Jun 12 '13 at 4:00
ok, thanks. I've never seen this done in the wild, and it just smelt a bit off. – Sirex Jun 12 '13 at 4:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .