不小心删除了/etc/resolv.conf,现在无法访问任何域

आनं*_*नंद 7 dns resolv.conf resolvconf 18.04

我在 Ubuntu 18.04 上的 chrome 中收到 dns 探测完成消息,所以我在互联网上查找并尝试运行以下命令。

sudo rm/etc/resolv.conf
sudo ln -s /var/run/resolvconf/resolv.conf /etc/resolv.conf
Run Code Online (Sandbox Code Playgroud)

以上 2 个命令成功执行,但以下命令没有执行。

sudo resolvconf -u
Run Code Online (Sandbox Code Playgroud)

它给出了resolvconf未安装的错误消息。

现在,没有任何工作,/etc/resolv.conf文件为空。我什至无法编辑它(我尝试添加nameserver 8.8.8.8)。

请帮忙。

编辑:我仍然收到 ERR_NAME_NOT_RESOLVE,这是“service --status-all”的输出。

 [ + ]  acpid
 [ - ]  alsa-utils
 [ - ]  anacron
 [ + ]  apparmor
 [ + ]  apport
 [ + ]  avahi-daemon
 [ + ]  bluetooth
 [ - ]  console-setup.sh
 [ + ]  cron
 [ + ]  cups
 [ + ]  cups-browsed
 [ + ]  dbus
 [ - ]  dns-clean
 [ + ]  gdm3
 [ + ]  grub-common
 [ - ]  hwclock.sh
 [ + ]  irqbalance
 [ + ]  kerneloops
 [ - ]  keyboard-setup.sh
 [ + ]  kmod
 [ + ]  network-manager
 [ + ]  networking
 [ - ]  plymouth
 [ - ]  plymouth-log
 [ - ]  pppd-dns
 [ + ]  procps
 [ - ]  rsync
 [ + ]  rsyslog
 [ - ]  saned
 [ + ]  speech-dispatcher
 [ - ]  spice-vdagent
 [ + ]  udev
 [ + ]  ufw
 [ + ]  unattended-upgrades
 [ - ]  uuidd
 [ + ]  whoopsie
 [ - ]  x11-common
Run Code Online (Sandbox Code Playgroud)

Vid*_*uth 7

要解决此问题,您应该重新创建链接。在 18.04/etc/resolv.conf点到../run/systemd/resolve/stub-resolv.conf.

因此,要解决您的问题,执行以下操作就足够了:

sudo rm resolv.conf
sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
Run Code Online (Sandbox Code Playgroud)