DNS 解析在 Linux Ubuntu 22.04 上不起作用

DNS 解析在 Linux Ubuntu 22.04 上不起作用

当我尝试将我的 DNS 更改为任何其他 DNS 时,没有任何效果按预期进行,就像我没有设置任何 DNS 一样,但是我做到了!

当我打开浏览器并尝试打开网站时出现此错误:

ERR_NAME_NOT_RESOLVED


我尝试更改我的 DNS:

sudo nano /etc/resolv.conf

像这样:

nameserver 178.22.122.100
nameserver 185.51.200.2

但此后,当我打开浏览器并尝试打开网站时出现此错误:

ERR_NAME_NOT_RESOLVED


我也尝试在这里更改我的 DNS:

sudo nano /etc/systemd/resolved.conf

像这样:

DNS=178.22.122.100 185.51.200.2

在此之前/之后,我使用以下命令进行了 systemd-resolved 重启:

sudo systemctl restart systemd-resolved

但此后,当我打开浏览器并尝试打开网站时出现此错误:

ERR_NAME_NOT_RESOLVED


我也尝试了这个命令:

sudo resolvectl dns wlp3s0 178.22.122.100 185.51.200.2

将 shecan DNS 直接设置为 wlp3s0(我的网络适配器),当我检查时resolvectl status显示以下内容:

Link 3 (wlp3s0)
Current Scopes: DNS
     Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
   DNS Servers: 178.22.122.100 185.51.200.2

但 DNS 未按预期工作。当我打开浏览器并尝试打开网站时出现此错误:

ERR_NAME_NOT_RESOLVED


当我尝试 ping 这些 IP 时,它们起作用了:

$ping 185.51.200.2 -c 4
PING 185.51.200.2 (185.51.200.2) 56(84) bytes of data.
64 bytes from 185.51.200.2: icmp_seq=1 ttl=53 time=101 ms
64 bytes from 185.51.200.2: icmp_seq=1 ttl=53 time=101 ms (DUP!)
64 bytes from 185.51.200.2: icmp_seq=2 ttl=53 time=55.1 ms
64 bytes from 185.51.200.2: icmp_seq=3 ttl=53 time=99.0 ms
64 bytes from 185.51.200.2: icmp_seq=4 ttl=53 time=54.9 ms

--- 185.51.200.2 ping statistics ---
4 packets transmitted, 4 received, +1 duplicates, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 54.940/82.227/101.074/22.213 ms

$ping 178.22.122.100 -c 4
PING 178.22.122.100 (178.22.122.100) 56(84) bytes of data.
64 bytes from 178.22.122.100: icmp_seq=1 ttl=51 time=68.9 ms
64 bytes from 178.22.122.100: icmp_seq=2 ttl=51 time=123 ms
64 bytes from 178.22.122.100: icmp_seq=3 ttl=51 time=66.3 ms
64 bytes from 178.22.122.100: icmp_seq=4 ttl=51 time=105 ms

--- 178.22.122.100 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 66.326/90.860/122.741/24.041 ms

编辑:输出ls -al /etc/resolv.conf

lrwxrwxrwx 1 root root 37 May 25 15:24 /etc/resolv.conf -> /run/systemd/resolve/stub-resolv.conf

相关内容