Accidentally deleted /etc/resolv.conf and now can't access any domain

11,218

To fix this you should recreate the link how it was. On 18.04 /etc/resolv.conf points to ../run/systemd/resolve/stub-resolv.conf.

So to fix your problem it should be enough to do the following:

sudo rm resolv.conf
sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
Share:
11,218

Related videos on Youtube

आनंद
Author by

आनंद

CS undergrad.

Updated on September 18, 2022

Comments

  • आनंद
    आनंद over 1 year

    I was getting dns probe finished message in chrome on Ubuntu 18.04 so I looked up on the internet and tried to run the following commands.

    sudo rm/etc/resolv.conf
    sudo ln -s /var/run/resolvconf/resolv.conf /etc/resolv.conf
    

    Above 2 commands executed successfully but the following didn't.

    sudo resolvconf -u
    

    It gives an error message that resolvconf is not installed.

    Now, nothing is working and /etc/resolv.conf file is empty. I'm not even able to edit it (I tried to a add nameserver 8.8.8.8).

    Please help.

    Edit: i'm still getting ERR_NAME_NOT_RESOLVE and here's the output of '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
    
    • Admin
      Admin almost 6 years
      On 18.04 /etc/resolv.conf points to ../run/systemd/resolve/stub-resolv.conf
  • muclux
    muclux almost 6 years
    In my native 18.04 I have /etc/resolv.conf -> ../run/resolvconf/resolv.conf, in my VirtualBox 18.04 I have the link like you wrote. My native 18.04 is an upgrade from 17.10 but the VB system was a fresh install - perhaps this explains the difference?
  • Videonauth
    Videonauth almost 6 years
    Probably. This 18.04 I have here was a total fresh install, so I guess too that your different linkage is due to being an upgraded system.
  • आनंद
    आनंद almost 6 years
    @Videonauth Thanks. But I'm still occasionally getting ERR_NAME_NOT_RESOLVED. What should I do? I googled and found this answer askubuntu.com/questions/1029603/… The output of sudo service --status-all is added in question.
  • Videonauth
    Videonauth almost 6 years
    Did you restart the machine after the repair?
  • आनंद
    आनंद almost 6 years
    Yes, I did. But I continue to get the same message of DNS BAD CONFIG