我已经安装了 Ubuntu 20.04,但 IPv6 无法正常工作。有人能帮我吗?
$ resolvectl -6 查询 google.com
google.com: 2a00:1450:4003:801::200e -- link: wlo1
-- Information acquired via protocol DNS in 16.2ms.
-- Data is authenticated: no
好的
$ resolvectl -6 查询 askubuntu.com
askubuntu.com: resolve call failed: 'askubuntu.com' does not have any RR of the requested type
失败
$ resolvectl -4 查询 askubuntu.com
askubuntu.com: 151.101.1.69 -- link: wlo1
151.101.65.69 -- link: wlo1
151.101.193.69 -- link: wlo1
151.101.129.69 -- link: wlo1
-- Information acquired via protocol DNS in 18.3ms.
-- Data is authenticated: no
如果使用 IPv4 则可以。
$ cat /var/run/NetworkManager/resolv.conf
# Generated by NetworkManager
nameserver 127.0.0.53
$ cat /var/run/NetworkManager/no-stub-resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8
[使用 IPv4 连接时的输出]
$ cat /var/run/NetworkManager/resolv.conf
# Generated by NetworkManager
nameserver 127.0.0.53
$ cat /var/run/NetworkManager/no-stub-resolv.conf
# Generated by NetworkManager
nameserver 2001:4860:4860::8888
[使用 IPv6 连接时的输出]
$ systemd-resolve --status
Global
LLMNR setting: no
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNSSEC NTA: 10.in-addr.arpa
16.172.in-addr.arpa
168.192.in-addr.arpa
17.172.in-addr.arpa
18.172.in-addr.arpa
19.172.in-addr.arpa
20.172.in-addr.arpa
21.172.in-addr.arpa
22.172.in-addr.arpa
23.172.in-addr.arpa
24.172.in-addr.arpa
25.172.in-addr.arpa
26.172.in-addr.arpa
27.172.in-addr.arpa
28.172.in-addr.arpa
29.172.in-addr.arpa
30.172.in-addr.arpa
31.172.in-addr.arpa
corp
d.f.ip6.arpa
home
internal
intranet
lan
local
private
test
Link 2 (wlo1)
Current Scopes: DNS
DefaultRoute setting: yes
LLMNR setting: yes
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 2001:4860:4860::8888
DNS Domain: ~.
$ cat /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: files systemd
group: files systemd
shadow: files
gshadow: files
hosts: files resolve [!UNAVAIL=return] dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
编辑: 出现了问题。我无法访问 askubuntu.com 网站。问题出在我的 NetworkManager 配置上。我将 IPv4 方法设置为“已禁用”,而我真正想要的是“需要 IPv6 寻址才能完成此连接”。不过,这很酷!
答案1
从这里看,askubuntu.com 似乎没有任何 AAAA (IPv6) DNS 记录。毕竟,并非所有网站都有。所以,并不是你以前没有访问过它,而是它对任何人来说都不存在。
答案2
使用 dig 并指定 AAAA 作为记录类型来确定问题是否与网络相关或与系统相关。
root@ubuntu:~# dig google.com AAAA
; <<>> DiG 9.10.3-P4-Ubuntu <<>> google.com AAAA
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64485
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1452
;; QUESTION SECTION:
;google.com. IN AAAA
;; ANSWER SECTION:
google.com. 240 IN AAAA 2607:f8b0:4006:804::200e
;; Query time: 2 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed May 06 21:21:59 UTC 2020
;; MSG SIZE rcvd: 77
如果此方法有效,至少可以缩小问题的范围。