只能使用 20.04 上的 Chromium 浏览互联网 - DNS 问题?

只能使用 20.04 上的 Chromium 浏览互联网 - DNS 问题?

我可以在 Ubuntu 20.04 上使用 Chromium 浏览互联网。

我无法使用 Firefox,也无法执行以下操作apt-get update

$ sudo apt-get update

Could not resolve 'actiontoad.canonical.com'

# etc...

我认为我的 DNS 可能因某种原因损坏,而 Chromium 忽略了系统设置。

$ curl google.com

Could not resolve host: google.com

有任何想法吗?

答案1

经过多次斗争,我发现了这个问题。

看看你的/etc/nssswitch.conf

就我的情况来说,它有以下几行:

# Use /etc/resolv.conf first, then fall back to systemd-resolved
hosts: files dns resolve myhostname mymachines
# Use systemd-resolved first, then fall back to /etc/resolv.conf
hosts: files resolve dns myhostname mymachines
# Don't use /etc/resolv.conf at all
hosts: files resolve myhostname mymachines

为了让事情正常运转,我将其改为这样:

# Use /etc/resolv.conf first, then fall back to systemd-resolved
# hosts: files dns resolve myhostname mymachines

# Use systemd-resolved first, then fall back to /etc/resolv.conf
hosts: files resolve dns myhostname mymachines

# Don't use /etc/resolv.conf at all
# hosts: files resolve myhostname mymachines

甚至不需要重新启动!

$ curl google.com                      
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

$ nslookup google.com
Server:     8.8.8.8
Address:    8.8.8.8#53

Non-authoritative answer:
Name:   google.com
Address: 172.217.16.238
Name:   google.com
Address: 2a00:1450:4009:821::200e

真是一段痛苦的时光。祝你好运!

相关内容