如何修复 Linux Mint 18.x 上的 IPv6 DNS 服务器设置?

如何修复 Linux Mint 18.x 上的 IPv6 DNS 服务器设置?

操作系统:Linux Mint 18.2 Cinnamon + Windows 10 Pro;双启动。

我刚刚使用过这个网站http://test-ipv6.com/检查我的 IPv6 准备情况。


Windows 10 专业版上的结果:

Windows 10 专业版上的结果

Linux Mint 18.2 Cinnamon 上的结果:

Linux Mint 18.2 Cinnamon 上的结果


如你所见,我有一些我的 Linux Mint 上的 DNS 设置有问题。但一切似乎都已打开,例如在网络设置 - IPv6 部分:

网络设置 - IPv6 部分


我不确定在哪里查找失败的 DNS 设置。或者 Linux Mint 18 还没有为 IPv6 做好准备吗?


编辑1:

$ cat /etc/resolv.conf

nameserver 209.222.18.222
nameserver 209.222.18.218

但在网络管理器中,我将 Google DNS 视为主要 DNS,而我的 IPS 则视为次要 DNS,我已在路由器的 DHCP 中的 IPv4 部分中对其进行了配置:

在网络管理器中我看到 Google DNS

我想我的笔记本电脑正在使用这些。

$ nmcli dev show | grep DNS

IP4.DNS[1]:                             8.8.8.8
IP4.DNS[2]:                             10.255.255.10
IP6.DNS[1]:                             2a02:768:0:1010::3
IP6.DNS[2]:                             2a02:768:0:1010::2

我承认我根本不懂IPv6,但我不明白为什么在Windows 上测试,因此IPv6 是完全可操作的,而在Linux 上却不行。

$ cat /etc/gai.conf

# Configuration for getaddrinfo(3).
#
# So far only configuration for the destination address sorting is needed.
# RFC 3484 governs the sorting.  But the RFC also says that system
# administrators should be able to overwrite the defaults.  This can be
# achieved here.
#
# All lines have an initial identifier specifying the option followed by
# up to two values.  Information specified in this file replaces the
# default information.  Complete absence of data of one kind causes the
# appropriate default information to be used.  The supported commands include:
#
# reload  <yes|no>
#    If set to yes, each getaddrinfo(3) call will check whether this file
#    changed and if necessary reload.  This option should not really be
#    used.  There are possible runtime problems.  The default is no.
#
# label   <mask>   <value>
#    Add another rule to the RFC 3484 label table.  See section 2.1 in
#    RFC 3484.  The default is:
#
#label ::1/128       0
#label ::/0          1
#label 2002::/16     2
#label ::/96         3
#label ::ffff:0:0/96 4
#label fec0::/10     5
#label fc00::/7      6
#label 2001:0::/32   7
#
#    This default differs from the tables given in RFC 3484 by handling
#    (now obsolete) site-local IPv6 addresses and Unique Local Addresses.
#    The reason for this difference is that these addresses are never
#    NATed while IPv4 site-local addresses most probably are.  Given
#    the precedence of IPv6 over IPv4 (see below) on machines having only
#    site-local IPv4 and IPv6 addresses a lookup for a global address would
#    see the IPv6 be preferred.  The result is a long delay because the
#    site-local IPv6 addresses cannot be used while the IPv4 address is
#    (at least for the foreseeable future) NATed.  We also treat Teredo
#    tunnels special.
#
# precedence  <mask>   <value>
#    Add another rule to the RFC 3484 precedence table.  See section 2.1
#    and 10.3 in RFC 3484.  The default is:
#
#precedence  ::1/128       50
#precedence  ::/0          40
#precedence  2002::/16     30
#precedence ::/96          20
#precedence ::ffff:0:0/96  10
#
#    For sites which prefer IPv4 connections change the last line to
#
precedence ::ffff:0:0/96  100

#
# scopev4  <mask>  <value>
#    Add another rule to the RFC 6724 scope table for IPv4 addresses.
#    By default the scope IDs described in section 3.2 in RFC 6724 are
#    used.  Changing these defaults should hardly ever be necessary.
#    The defaults are equivalent to:
#
#scopev4 ::ffff:169.254.0.0/112  2
#scopev4 ::ffff:127.0.0.0/104    2
#scopev4 ::ffff:0.0.0.0/96       14

所以,几乎所有内容都被注释掉了。

另外,您问我正在使用哪个 DHCP 客户端:

$ dhclient --help

Internet Systems Consortium DHCP Client 4.3.3
...

编辑2:

$ cat /etc/dhcp/dhclient.conf

# Configuration file for /sbin/dhclient.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
#   man page for more information about the syntax of this file
#   and a more comprehensive list of the parameters understood by
#   dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
#   not leave anything out (like the domain name, for example), then
#   few changes must be made to this file, if any.
#

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

send host-name = gethostname();
request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search, host-name,
    dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;

#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
#prepend domain-name-servers 127.0.0.1;
#require subnet-mask, domain-name-servers;
timeout 300;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
#script "/sbin/dhclient-script";
#media "-link0 -link1 -link2", "link0 link1";
#reject 192.33.137.209;

#alias {
#  interface "eth0";
#  fixed-address 192.5.5.213;
#  option subnet-mask 255.255.255.255;
#}

#lease {
#  interface "eth0";
#  fixed-address 192.33.137.200;
#  medium "link0 link1";
#  option host-name "andare.swiftmedia.com";
#  option subnet-mask 255.255.255.0;
#  option broadcast-address 192.33.137.255;
#  option routers 192.33.137.250;
#  option domain-name-servers 127.0.0.1;
#  renew 2 2000/1/12 00:00:01;
#  rebind 2 2000/1/12 00:00:01;
#  expire 2 2000/1/12 00:00:01;
#}

编辑3:

将 IPv6 行复制粘贴到上面一行后:

cat /etc/dhcp/dhclient.conf 

# Configuration file for /sbin/dhclient.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
#   man page for more information about the syntax of this file
#   and a more comprehensive list of the parameters understood by
#   dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
#   not leave anything out (like the domain name, for example), then
#   few changes must be made to this file, if any.
#

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

send host-name = gethostname();
request subnet-mask, broadcast-address, time-offset, routers,
    dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
    domain-name, domain-name-servers, domain-search, host-name,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;

#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
#prepend domain-name-servers 127.0.0.1;
#require subnet-mask, domain-name-servers;
timeout 300;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
#script "/sbin/dhclient-script";
#media "-link0 -link1 -link2", "link0 link1";
#reject 192.33.137.209;

#alias {
#  interface "eth0";
#  fixed-address 192.5.5.213;
#  option subnet-mask 255.255.255.255;
#}

#lease {
#  interface "eth0";
#  fixed-address 192.33.137.200;
#  medium "link0 link1";
#  option host-name "andare.swiftmedia.com";
#  option subnet-mask 255.255.255.0;
#  option broadcast-address 192.33.137.255;
#  option routers 192.33.137.250;
#  option domain-name-servers 127.0.0.1;
#  renew 2 2000/1/12 00:00:01;
#  rebind 2 2000/1/12 00:00:01;
#  expire 2 2000/1/12 00:00:01;
#}

编辑4:

也许是我的 VPN 提供商应用程序造成的,我没有做任何更改。我目前没有使用 VPN,所以我想测试我的 Linux 是否支持 IPv6。 resolv.conf 中的名称服务器属于 VPN 提供商:Private Internet Access。

试图找出为什么resolv.conf不更新:

$ lsattr /etc/resolv.conf

-------------e-- /etc/resolv.conf

编辑5:

$ sudo tcpdump -i eth0 udp port 53

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
13:28:35.416720 IP 192.168.0.11.46858 > resolver1.privateinternetaccess.com.domain: 22927+ A? imap.gmail.com. (32)
13:28:35.416730 IP 192.168.0.11.46858 > resolver1.privateinternetaccess.com.domain: 8909+ AAAA? imap.gmail.com. (32)
13:28:35.416974 IP 192.168.0.11.39732 > resolver1.privateinternetaccess.com.domain: 35471+ PTR? 222.18.222.209.in-addr.arpa. (45)
13:28:35.436305 IP 192.168.0.11.52326 > resolver1.privateinternetaccess.com.domain: 65414+ A? live.mozillamessaging.com. (43)
13:28:35.436310 IP 192.168.0.11.52326 > resolver1.privateinternetaccess.com.domain: 30886+ AAAA? live.mozillamessaging.com. (43)
13:28:35.478049 IP 192.168.0.11.46175 > resolver1.privateinternetaccess.com.domain: 5292+ A? mx.endora.cz. (30)
13:28:35.478053 IP 192.168.0.11.46175 > resolver1.privateinternetaccess.com.domain: 16624+ AAAA? mx.endora.cz. (30)
13:28:35.815497 IP 192.168.0.11.50734 > resolver1.privateinternetaccess.com.domain: 17117+ A? clients1.google.com. (37)
13:28:35.815508 IP 192.168.0.11.50734 > resolver1.privateinternetaccess.com.domain: 34551+ AAAA? clients1.google.com. (37)
13:28:35.816481 IP resolver1.privateinternetaccess.com.domain > 192.168.0.11.46175: 5292 1/0/0 A 88.86.120.212 (46)
13:28:35.818739 IP resolver1.privateinternetaccess.com.domain > 192.168.0.11.46175: 16624 0/1/0 (86)
13:28:35.959874 IP resolver1.privateinternetaccess.com.domain > 192.168.0.11.50734: 17117 2/0/0 CNAME clients.l.google.com., A 172.217.12.142 (77)
13:28:35.959899 IP resolver1.privateinternetaccess.com.domain > 192.168.0.11.50734: 34551 2/0/0 CNAME clients.l.google.com., AAAA 2607:f8b0:4006:819::200e (89)
13:28:35.972396 IP 192.168.0.11.50409 > resolver1.privateinternetaccess.com.domain: 53313+ A? ocsp2.globalsign.com. (38)
13:28:35.972406 IP 192.168.0.11.50409 > resolver1.privateinternetaccess.com.domain: 62184+ AAAA? ocsp2.globalsign.com. (38)
13:28:36.145921 IP resolver1.privateinternetaccess.com.domain > 192.168.0.11.50409: 62184 3/0/0 CNAME cdn.globalsigncdn.com., AAAA 2400:cb00:2048:1::681f:4a7c, AAAA 2400:cb00:2048:1::681f:4b7c (126)
13:28:36.153394 IP resolver1.privateinternetaccess.com.domain > 192.168.0.11.50409: 53313 3/0/0 CNAME cdn.globalsigncdn.com., A 104.31.75.124, A 104.31.74.124 (102)
13:28:36.345446 IP 192.168.0.11.39036 > resolver1.privateinternetaccess.com.domain: 49155+ A? www.googleapis.com. (36)
13:28:36.345462 IP 192.168.0.11.39036 > resolver1.privateinternetaccess.com.domain: 10791+ AAAA? www.googleapis.com. (36)
13:28:36.483314 IP resolver1.privateinternetaccess.com.domain > 192.168.0.11.39036: 49155 13/0/0 CNAME googleapis.l.google.com., A 172.217.6.234, A 172.217.10.234, A 172.217.12.170, A 172.217.12.202, A 172.217.9.234, A 172.217.10.10, A 172.217.10.42, A 172.217.10.74, A 172.217.10.138, A 172.217.3.106, A 172.217.12.138, A 172.217.6.202 (262)
13:28:36.483344 IP resolver1.privateinternetaccess.com.domain > 192.168.0.11.39036: 10791 2/0/0 CNAME googleapis.l.google.com., AAAA 2607:f8b0:4006:812::200a (98)
^C

编辑6:

sudo dhclient -r
sudo dhclient -v eth0


Internet Systems Consortium DHCP Client 4.3.3
Copyright 2004-2015 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/eth0/d8:50:e6:05:e1:db
Sending on   LPF/eth0/d8:50:e6:05:e1:db
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3 (xid=0x3ede007c)
DHCPREQUEST of 192.168.0.11 on eth0 to 255.255.255.255 port 67 (xid=0x7c00de3e)
DHCPOFFER of 192.168.0.11 from 192.168.0.1
DHCPACK of 192.168.0.11 from 192.168.0.1
/etc/resolvconf/update.d/libc: Warning: /etc/resolv.conf is not a symbolic link to /run/resolvconf/resolv.conf
bound to 192.168.0.11 -- renewal in 2147483648 seconds.

编辑7:

$ sudo tcpdump -i eth0 -vvv -n port 68

tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
14:30:18.135530 IP (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 328)
    0.0.0.0.68 > 255.255.255.255.67: [udp sum ok] BOOTP/DHCP, Request from d8:50:e6:05:e1:db, length 300, xid 0x7a30842b, Flags [none] (0x0000)
      Client-Ethernet-Address d8:50:e6:05:e1:db
      Vendor-rfc1048 Extensions
        Magic Cookie 0x63825363
        DHCP-Message Option 53, length 1: Request
        Requested-IP Option 50, length 4: 192.168.0.11
        Hostname Option 12, length 10: "vb-nb-mint"
        Parameter-Request Option 55, length 18: 
          Subnet-Mask, BR, Time-Zone, Default-Gateway
          Domain-Name, Domain-Name-Server, Option 119, Hostname
          Netbios-Name-Server, Netbios-Scope, MTU, Classless-Static-Route
          NTP, Classless-Static-Route, Classless-Static-Route-Microsoft, Static-Route
          Option 252, NTP
        END Option 255, length 0
        PAD Option 0, length 0, occurs 18
14:30:18.136280 IP (tos 0x0, ttl 64, id 15220, offset 0, flags [none], proto UDP (17), length 576)
    192.168.0.1.67 > 192.168.0.11.68: [udp sum ok] BOOTP/DHCP, Reply, length 548, xid 0x7a30842b, Flags [none] (0x0000)
      Your-IP 192.168.0.11
      Client-Ethernet-Address d8:50:e6:05:e1:db
      Vendor-rfc1048 Extensions
        Magic Cookie 0x63825363
        DHCP-Message Option 53, length 1: ACK
        Server-ID Option 54, length 4: 192.168.0.1
        Lease-Time Option 51, length 4: 4294967295
        Subnet-Mask Option 1, length 4: 255.255.255.0
        Default-Gateway Option 3, length 4: 192.168.0.1
        Domain-Name-Server Option 6, length 8: 8.8.8.8,10.255.255.10
        END Option 255, length 0
        PAD Option 0, length 0, occurs 270
^C

+

$ cat /run/resolvconf/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
nameserver 10.255.255.10
nameserver 127.0.1.1

答案1

在 /etc/gai.conf 中,您需要注释掉 IPv6 优先于 IPv4 的行,如下所示:

# precedence ::ffff:0:0/96  100

您还需要编辑 /etc/dhclient/dhclient6.conf,如果这还不够,则可以将 -6 参数传递给 dhclient。

我还建议更正 resolv.conf 链接。

我还可以发誓 dhclient 只使用通过 DHCP 传递的前两个 DNS 服务器,但我可能是错的。


编辑:

  1. 上面的步骤是正确的,即我们第一步注释掉该行:

    precedence ::ffff:0:0/96  100
    

    在以下文件中:

    /etc/gai.conf
    
  2. 执行提到的步骤在微软文档中适用于基于Ubuntu 16.04的Linux Mint 18.x:

    创建以下文件:

    /etc/dhcp/dhclient6.conf
    

    内容:

    timeout 10;
    

    创建以下文件:

    /etc/network/interfaces.d/50-cloud-init.cfg
    

    内容:

    iface eth0 inet6 auto
        up sleep 5
        up dhclient -1 -6 -cf /etc/dhcp/dhclient6.conf -lf /var/lib/dhcp/dhclient6.eth0.leases -v eth0 || true
    
  3. 最后创建符号链接,同时覆盖原始链接resolv.conf

    ln -sf /run/resolvconf/resolv.conf /etc/resolv.conf
    
  4. 重新启动,瞧,来自 DHCP 的 IPv6 正在工作。

答案2

您可以在 /etc/gai.conf 文件中添加该行precedence 2001:470::/32 100并注释,使 IPv6 优先于 IPv4precedence ::ffff:0:0/96 100

相关内容