Feedback

type to search

what is the correct /etc/hosts for debian

Asked by [ Editor ] , Edited by Fernando C. Estrada [ Admin ]

strange, but in debian i have the following /etc/hosts :

127.0.0.1       localhost       debian
192.168.1.2     debian

In ubuntu and arch I’ve had another. It was something like: 

127.0.0.1       localhost       myhostname
127.0.1.1       myhostname
As you may see the second line is different. Why? Which is the correct one?


or Cancel

6 answers

5

kaeso [ Editor ]

This is a tricky question :)

Short answer: both are correct, the difference is that debian installation was done with an already configured 192.168.1.0/24 address, while the ubuntu one not, thus it is using a loopback address (the entire 127.0.0.0/8 is assigned to loopback, so 127.0.0.1 and 127.0.1.1 are almost equivalent).

Long answer: local machine naming is a tricky matter, which may impact on applications in a wide variety of ways, in particular for roaming machines. The scheme for /etc/hosts naming and the pattern you are seeing are a result of some discussions, which can be read through the log of bug #247734.

NN comments
amlj
-

Nice answer… Thanks.

or Cancel
0

amlj [ Editor ]

For me it’s…

127.0.0.1    localhost
127.0.1.1    debian.home.gateway    debian

But I’m not sure if this means something is wrong with your /etc/hosts file…

or Cancel
0

lucabrivio

For me (Debian squeeze/sid) it’s:

127.0.0.1       localhost

127.0.1.1       myhostname.residential.fw       myhostname


# The following lines are desirable for IPv6 capable hosts

::1     localhost ip6-localhost ip6-loopback

fe00::0 ip6-localnet

ff00::0 ip6-mcastprefix

ff02::1 ip6-allnodes

ff02::2 ip6-allrouters

ff02::3 ip6-allhosts

or Cancel

Your answer

You need to join Debian to complete this action, click here to do so.