“/etc/hosts”和“/etc/hostname”的默认设置是什么?

11 hostname hosts etc 16.04

我正在使用 Ubuntu 16.04。我最近开始学习 DevOps 并且对我的/etc/hosts/etc/hostname文件有点疯狂。在我疯狂地尝试从我的本地机器启动几台服务器时,我忘记了默认设置,只是想知道它们是什么/曾经是什么。

我记得/etc/hosts/etc/hostname只有一个条目,这是我的本地机器的用户名。不过我不完全确定。

有没有人知道全新安装的默认设置是什么?

tho*_*ter 18

它们基于您在安装时指定的主机名:在我下面的示例中,“myhostname”是您选择的名称。默认值看起来有点像这样:

/etc/主机名

myhostname
Run Code Online (Sandbox Code Playgroud)

/etc/hosts

127.0.1.1 myhostname
127.0.0.1 localhost

# 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
ff02::3 ip6-allhosts
Run Code Online (Sandbox Code Playgroud)

  • 在 20.04 中,“127.0.0.1 localhost”位于第一行,而不是“127.0.1.1 myhostname” (2认同)