Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am new to unmanaged VPS servers and in addition IPv6. Is it necessary to include 127.0.0.1 AND ::1 for localhost in /etc/hosts files for IPv6 enabled servers, or is ::1 alone enough?

share|improve this question

3 Answers 3

up vote 4 down vote accepted

Yes, 127.0.0.1 should be left. IPv6 is enabled, but IPv4 is still used.

share|improve this answer
    
So I should include the following in my hosts file? 127.0.0.1 localhost ::1 localhost –  filmoreha May 2 '12 at 13:13
    
Yes, you should keep both the ipv4 and ipv6 localhost addresses –  Sirch May 2 '12 at 13:18

Leave the hosts file alone. Fiddle with it and you may break something. For example, if you remove the 127.0.0.1 don't be too surprised if anything that uses localhost fails.

share|improve this answer
    
I was curious about 120.0.0.1 and ::1 because I had never seen ::1 before and it (along with an IPv6 address) were the only things in my hosts file. Ended up cleaning things up a bit to include 127.0.0.1 as well. –  filmoreha May 7 '12 at 0:55
    
@filmoreha, I suspect that's a typo but there was no mention of 120.0.0.1. You also need to consider that a hosted environment, even an unmanaged one, will have certain requirements for monitoring purposes, which is another reason to be cautious of modifying things like the hosts file. –  John Gardeniers May 7 '12 at 2:23
    
Thanks, that was definitely a typo. I will keep what you said about monitoring in mind, hadn't thought about that! –  filmoreha May 7 '12 at 2:49

Adding anything to /etc/hosts is not necessary, but really helps, so it will be pretty useful to add both (IPv4 and IPv6) records. After all, it is not expensive in any sense (10 seconds on each won't kill you day), but you'll know this part is done completely.

share|improve this answer

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.