Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
143.34.54.45 servername.domain.com 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

1 Answer 1

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 143.34.54.45 bit. i.e: hardcoding the local LAN ip into the machines own /etc/hosts file. –  Sirex Jun 12 '13 at 3:58
1  
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.