Sunday, November 13, 2016

linux - Why does my hostname appear with the address 127.0.1.1 rather than 127.0.0.1 in /etc/hosts?



This may be a bit of a noobish question, but I was taking a look at /etc/hosts on my new Xubuntu install and saw this:



127.0.0.1 localhost

127.0.1.1 myhostname


On most 'nixes I've used, the second line is omitted, and if I want to add my hostname to the hosts file, I'd just do this:



127.0.0.1 localhost myhostname


Is there a difference between these two files in any practical sense?


Answer




There isn't a great deal of difference between the two; 127/8 (eg: 127.0.0.0 => 127.255.255.255) are all bound to the loopback interface.



The reason why is documented in the Debian manual in Ch. 5 Network Setup - 5.1.1. The hostname resolution.



Ultimately, it is a bug workaround; the original report is 316099.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...