与有何127.0.0.1
关系127.0.0.2
?
使用ssh登录特莱拉克斯(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.
登录总督(乌班图):
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:~$
我的理解是,至少在 Ubuntu 中,127.0.0.1
和are 用于主机名:127.0.1.1.
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
在特莱拉克斯我使用 yast - 为什么它给出的 IP 地址为127.0.0.2
?这和有什么不同吗127.0.0.1
?难道只是用yast的神器吗?
127.0.0.2
最后,如果我改为yast ,它会以任何方式弄乱吗127.0.0.1
?我猜这并不重要——我对此更好奇。
与 IPv4 地址如何工作的更广泛要求相比,每个发行版中的这种约定在多大程度上是公正的?
答案1
您的环回设备lo
已绑定到网络127/8
(又名127.0.0.1/255.0.0.0
),因此任何127.0.0.1
to范围内的地址127.255.255.254
是您的本地环回。
127.0.0.1
因此,使用或并不重要127.0.0.2
。
他们(Debian)选择他们选择的方案的原因在Debian 参考(这确实是一个错误的解决方法)