Ubuntu
為什麼 OpenSuSE 和 Ubuntu 之間的 hosts 文件有不同的格式?
有什麼
127.0.0.1
關係127.0.0.2
?使用 ssh 登錄tleilax (OpenSuSE):
tleilax:~ # tleilax:~ # hostname tleilax tleilax:~ # tleilax:~ # hostname -f tleilax.bounceme.net tleilax:~ # tleilax:~ # cat /etc/hosts # # hosts This file describes a number of hostname-to-address # mappings for the TCP/IP subsystem. It is mostly # used at boot time, when no name servers are running. # On small systems, this file can be used instead of a # "named" name server. # Syntax: # # IP-Address Full-Qualified-Hostname Short-Hostname # 127.0.0.1 localhost # special IPv6 addresses ::1 localhost ipv6-localhost ipv6-loopback fe00::0 ipv6-localnet ff00::0 ipv6-mcastprefix ff02::1 ipv6-allnodes ff02::2 ipv6-allrouters ff02::3 ipv6-allhosts 127.0.0.2 tleilax.bounceme.net tleilax tleilax:~ # tleilax:~ # exit logout Connection to 192.168.1.4 closed.
登錄到總督(Ubuntu):
thufir@doge:~$ thufir@doge:~$ hostname doge thufir@doge:~$ thufir@doge:~$ hostname -f doge.bounceme.net thufir@doge:~$ thufir@doge:~$ cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 doge.bounceme.net doge # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters thufir@doge:~$
我的理解是,
127.0.0.1
至少127.0.1.1.
在 Ubuntu 中,用於主機名:Somme years ago Thomas Hood started a discussion[0] about how the system hostname should be resolved. The eventual result[1] was that Debian nowadays ships /etc/hosts like these per default: 127.0.0.1 localhost 127.0.1.1 <host_name>.<domain_name> <host_name> As also described in the Debian reference[2]. I had a short mail conversation with Thomas and he proposed bringing up the following at d-d.
https://lists.debian.org/debian-devel/2013/07/msg00809.html
在tleilax 上,我使用了 yast——為什麼它給出的 IP 地址是
127.0.0.2
?那和 有什麼不同127.0.0.1
嗎?它只是使用yast的神器嗎?
127.0.0.2
最後,如果我改成 ,它會以任何方式搞砸127.0.0.1
嗎?我猜這並不重要——我對此更好奇。與 IPv4 地址如何工作的更廣泛要求相比,每個發行版中的這種只是約定的程度如何?
您的環回設備
lo
綁定到網路127/8
(又名127.0.0.1/255.0.0.0
),因此範圍內的任何地址127.0.0.1
to127.255.255.254
都是您的本地環回。因此,無論您使用
127.0.0.1
還是127.0.0.2
.他們(Debian)選擇他們選擇的方案的原因在Debian-reference中有解釋(這確實是一個錯誤的解決方法)