每当我重新启动计算机时,NetworkManager 都会设置/etc/resolv.conf
为此项,我的 DNS 就会停止工作,并且我会在 Chrome 中收到此错误。
/etc/resolv.conf
# Generated by NetworkManager
search tampabay.rr.com
nameserver 127.0.0.53
Chrome 错误:
DNS_PROBE_FINISHED_NO_INTERNET
/etc/resolv.conf
我通过设置此项暂时解决了该问题。
/etc/resolv.conf
nameserver 8.8.8.8
我猜 NetworkManager 需要我本地机器上的 DNS 服务器 127.0.0.53,但我没有在那里运行 DNS。我如何永久将其设置8.8.8.8
为我的名称服务器?如果真的有必要,我该如何设置 DNS 127.0.0.53
?
我读过man resolv.conf
但对我没什么帮助。
我读过这个答案并创建了文件/etc/resolvconf/resolv.conf.d/tail
,nameserver 8.8.8.8
但它似乎没有任何效果:DNS 设置为 systemd 的 127.0.0.53 - 如何永久更改?
编辑: Ubuntu 20.04 LTS
DNS 缓存程序unbound
在端口 :53 上运行,无法dnsmasq
启动。我卸载了它unbound
,dnsmasq
现在启动了。但是出于某种原因,它说它只在 0.0.0.0 上运行。我想它必须在 127.0.0.1:53 上运行。我重新安装了 dnsmasq,但它的行为还是一样。/etc/dnsmasq.conf
全部被注释掉了。/etc/resolv.conf
现在在重新启动时设置为
# Generated by resolvconf
nameserver 127.0.0.1
不确定如何dnsmasq
正确运行。
/lib/systemd/system/dnsmasq.service
[Unit]
Description=dnsmasq - A lightweight DHCP and caching DNS server
Requires=network.target
Wants=nss-lookup.target
Before=nss-lookup.target
After=network.target
[Service]
Type=forking
PIDFile=/run/dnsmasq/dnsmasq.pid
# Test the config file and refuse starting if it is not valid.
ExecStartPre=/usr/sbin/dnsmasq --test
# We run dnsmasq via the /etc/init.d/dnsmasq script which acts as a
# wrapper picking up extra configuration files and then execs dnsmasq
# itself, when called with the "systemd-exec" function.
ExecStart=/etc/init.d/dnsmasq systemd-exec
# The systemd-*-resolvconf functions configure (and deconfigure)
# resolvconf to work with the dnsmasq DNS server. They're called like
# this to get correct error handling (ie don't start-resolvconf if the
# dnsmasq daemon fails to start.
ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf
ExecStop=/etc/init.d/dnsmasq systemd-stop-resolvconf
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
journalctl -e --unit dnsmasq.service
-- Reboot --
Jul 08 23:41:54 phil-desktopubuntu-18-04-1-lts systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
Jul 08 23:41:54 phil-desktopubuntu-18-04-1-lts dnsmasq[7349]: dnsmasq: syntax check OK.
Jul 08 23:41:54 phil-desktopubuntu-18-04-1-lts dnsmasq[7369]: started, version 2.80 cachesize 150
Jul 08 23:41:54 phil-desktopubuntu-18-04-1-lts dnsmasq[7369]: DNS service limited to local subnets
Jul 08 23:41:54 phil-desktopubuntu-18-04-1-lts dnsmasq[7369]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify dumpfile
Jul 08 23:41:54 phil-desktopubuntu-18-04-1-lts dnsmasq[7369]: read /etc/hosts - 7 addresses
Jul 08 23:41:54 phil-desktopubuntu-18-04-1-lts dnsmasq[7369]: no servers found in /run/dnsmasq/resolv.conf, will retry
Jul 08 23:41:54 phil-desktopubuntu-18-04-1-lts systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.
答案1
我搞明白了。我的一切都被注释掉了/etc/dnsmasq.conf
。我必须设置 DNS 服务器。
/etc/dnsmasq.conf
server=8.8.8.8
/etc/resolv.conf
# Generated by resolvconf
nameserver 127.0.0.1
这些命令有助于调试
sudo systemctl status dnsmasq #dnsmasq should be running
sudo netstat -tulpn #dnsmasq should be listening on 0.0.0.0:53
nslookup debian.org localhost #should return IP address of debian.org