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

Eug*_*ash 7 debian sid

我以某种方式删除/etc/hosts了我的测试系统,即 Debian Sid。现在我想安装默认的/etc/hosts. 我试图dpkg -S /etc/hosts找出哪个包包含/etc/hosts,但没有找到。我可以从哪里下载?

jsc*_*ott 13

/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
Run Code Online (Sandbox Code Playgroud)

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

更新:

由于我觉得这个答案获得了比我预期更多的赞成票,作为回报,我为您做了一些手指工作。:)

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

netcfg.h#define文件本身和 IPv6 条目都有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"
Run Code Online (Sandbox Code Playgroud)

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);
}
Run Code Online (Sandbox Code Playgroud)