我的 NetworkManager 没有写入/var/run/networkmanager/resolv.conf
并且NetworkManager 没有填充 resolv.conf不是我的情况的答案,因为我不使用resolvconf
. 更多详情如下:
我将管理我的以太网从 NetworkManager 切换/etc/network/interfaces
到了 NetworkManager,它以某种方式永远不会写入/var/run/networkmanager/resolv.conf
:
$ nmcli d
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected Wired connection 1
lo loopback unmanaged --
$ ls /var/run/NetworkManager/resolv.conf
ls: cannot access '/var/run/NetworkManager/resolv.conf': No such file or directory
$ ls /var/run/nm-dns-dnsmasq.conf
ls: cannot access '/var/run/nm-dns-dnsmasq.conf': No such file or directory
当我/etc/network/interfaces
使用resolv.conf
.
这是我的NetworkManager.conf
:
cat /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile
dns=dnsmasq
[ifupdown]
managed=false
[device]
wifi.scan-rand-mac-address=no
有些答案说我应该dns=dnsmasq
在那里,但有些人说我不应该。总而言之,我仍然对如何更新 NetworkManager 感到困惑/var/run/networkmanager/resolv.conf
。
更新,更多信息:
$ resolvectl status | grep DNS
-su: resolvectl: command not found
$ dpkg -l '*dns*' | grep 'ii *dns'
ii dns-root-data 2018013001 all DNS root data including root zone
ii dnsmasq 2.79-1 all Small caching DNS proxy and DHCP/
ii dnsmasq-base 2.79-1 amd64 Small caching DNS proxy and DHCP/
ii dnsutils 1:9.11.3+dfs amd64 Clients provided with BIND
$ dpkg -l '*resolv*' | grep ii || echo no resolvconf
no resolvconf
$ ls -al /etc/resolv.conf
-rw-r--r-- 1 root root 79 2019-03-03 18:42 /etc/resolv.conf
$ host 8.8.8.8
8.8.8.8.in-addr.arpa domain name pointer google-public-dns-a.google.com.
$ host www.ebay.com
www.ebay.com is an alias for slot9428.ebay.com.edgekey.net.
slot9428.ebay.com.edgekey.net is an alias for e9428.b.akamaiedge.net.
e9428.b.akamaiedge.net has address 104.93.181.25
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
更新2。
- 这不是普通的 Ubuntu 安装,而是我自定义的全新安装(不是从以前版本的升级)。我删除了
resolvconf
自己,因为我正在使用/etc/network/interfaces
,并且不希望我/etc/resolv.conf
一直在改变。也许这就是罪魁祸首,NetworkManager 不能没有resolvconf
? - 我的全部意图是“用 dnsmasq 替换 systemd-resolved ”(我使用 18.04 LiveCD 练习过,它有
resolvconf
),并将其用于我的 LAN DNS 服务器。嗯,也许在那种情况下,我不需要 NetworkManager 一直在改变我/etc/resolv.conf
的。
无论如何,以下是进一步调查的信息:
$ dpkg -l '*resolv*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
un resolvconf <none> <none> (no description available)
$ cat /run/resolvconf/resolv.conf
cat: /run/resolvconf/resolv.conf: No such file or directory
$ cat /run/systemd/resolve/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
. . .
nameserver 64.71.255.204
nameserver 64.71.255.198
search hitronhub.home
$ cat /etc/netplan/*.yaml
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
eth0:
addresses: [192.168.0.11/24, 192.168.0.10/24]
gateway4: 192.168.0.1
$ ps auxc | grep resolv
systemd+ 23890 0.0 0.0 70608 1520 ? Ss Mar01 0:00 systemd-resolve
$ sudo lsof -i tcp:53
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
systemd-r 23890 systemd-resolve 13u IPv4 47127798 0t0 TCP 127.0.0.53:domain (LISTEN)
dnsmasq 29822 dnsmasq 5u IPv4 47935969 0t0 TCP 192.168.0.10:domain (LISTEN)
dnsmasq 29822 dnsmasq 7u IPv4 47935971 0t0 TCP 192.168.0.11:domain (LISTEN)
dnsmasq 29822 dnsmasq 9u IPv4 47935973 0t0 TCP localhost.myhost.org:domain (LISTEN)
dnsmasq 29822 dnsmasq 11u IPv6 47935975 0t0 TCP [fe80::xxxx]:domain (LISTEN)
dnsmasq 29822 dnsmasq 13u IPv6 47935977 0t0 TCP [2607:fea8:xxxx]:domain (LISTEN)
dnsmasq 29822 dnsmasq 15u IPv6 47935979 0t0 TCP [fd00:xxxx]:domain (LISTEN)
dnsmasq 29822 dnsmasq 17u IPv6 47935981 0t0 TCP ip6-localhost:domain (LISTEN)
难怪我说“这里有问题”。在你的“定制”中,你把事情弄得一团糟。停止试图击败系统。对不起。
在
/etc/netplan/*.yaml
你已经结合了 NetworkManager 和 netplan 脚本。您的 .yaml 文件应如下所示...此信息属于 NetworkManager GUI 连接配置文件,或属于
/etc/network/interfaces
NetworkManager 发言...而不是 netplan 发言...resolvconf
/etc/resolv.conf
符号链接/etc/systemd/resolved.conf
(有关说明,请参见下文)/etc/network/interfaces
dnsmasq*
,除非你能解释你为什么需要它关于
dnsmasq
和systemd-resolved
...执行
ps auxc | grep -i dns
andps auxc | grep -i resolv
并查找dnsmasq
andsystemd-resolved
,如果两者都在运行,则需要systemd-resolved
通过编辑/etc/systemd/resolved.conf
和禁用 DNS 部分...改变:
至:
然后重启 systemd-resolve 和 dnsmasq,或者重启。
您可能需要重置 /etc/resolv.conf 的符号链接(如果 dnsmasq 未运行)...
sudo mv /etc/resolv.conf /etc/resolv.conf.OLD
# 保存旧的符号链接sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
# 创建新的符号链接注意:原始符号链接是...
sudo ln -s /run/resolvconf/resolv.conf /etc/resolv.conf