我在哪里可以得到Debian Sid的默认的/ etc / hosts文件?

我在某种程度上删除了我的testing系统上的/etc/hosts ,这是Debian Sid。 现在我想安装默认的/etc/hosts 。 我试过dpkg -S /etc/hosts来找出哪个软件包包含/etc/hosts ,但是没有find。 我在哪里可以下载?

/etc/hosts文件是通过debian-installer写的,它不是作为打包文件存在的。

以下是我的/etc/hosts的一个默认安装:

 127.0.0.1 localhost 127.0.1.1 hostname.fqdn.example.com hostname # 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 

有关语法的更多详细信息,请参阅Debian Reference部分主机名parsing

更新:

因为我觉得这个答案比我预料的要多得多,所以我为你做了一点小手指。 🙂

debian-installer使用的包含/etc/hosts逻辑的实际包名为net-cfg 。 更具体地说,两个文件netcfg.hnetcfg-common.c处理构build/etc/hosts文件的逻辑。

netcfg.h对于文件本身和IPv6条目都有#define s:

 #define HOSTS_FILE "/etc/hosts" ...<snip>... #define IPV6_HOSTS \ "# The following lines are desirable for IPv6 capable hosts\n" \ "::1 ip6-localhost ip6-loopback\n" \ "fe00::0 ip6-localnet\n" \ "ff00::0 ip6-mcastprefix\n" \ "ff02::1 ip6-allnodes\n" \ "ff02::2 ip6-allrouters\n" 

netcfg-common.c包含脏的工作,在/etc/hosts填充信息:

 if ((fp = file_open(HOSTS_FILE, "w"))) { char ptr1[INET_ADDRSTRLEN]; fprintf(fp, "127.0.0.1\tlocalhost"); if (ipaddress.s_addr) { inet_ntop (AF_INET, &ipaddress, ptr1, sizeof(ptr1)); if (domain_nodot && !empty_str(domain_nodot)) fprintf(fp, "\n%s\t%s.%s\t%s\n", ptr1, hostname, domain_nodot, hostname); else fprintf(fp, "\n%s\t%s\n", ptr1, hostname); } else { #if defined(__linux__) || defined(__GNU__) if (domain_nodot && !empty_str(domain_nodot)) fprintf(fp, "\n127.0.1.1\t%s.%s\t%s\n", hostname, domain_nodot, hostname); else fprintf(fp, "\n127.0.1.1\t%s\n", hostname); #else fprintf(fp, "\t%s\n", hostname); #endif } fprintf(fp, "\n" IPV6_HOSTS); fclose(fp); } 

在Debian上没有选中,但应该是

 :: 1 localhost localhost.my.domain
 127.0.0.1 localhost localhost.my.domain

(如果你不使用IPv6,那么你可以忽略以:: 1开始的行)

编辑:该文件可能是基础安装,而不是从一个额外的软件包。