Ideas on how to configure DNS properly for Ubuntu 20.04

Since a wifi outage a day or so ago I have had no access to the internet on my ubuntu running computer. I can ping 8.8.8.8, so I believe the problem is DNS related. However, manually setting the DNS in the network manager does nothing. I have also tried systemctl enable resolved, but am told that I don't have a resolved.service file at all.

Any ideas that people have on how to fix this issue would be greatly appreciated, as I am increasingly out of ideas. I can provide more information on request.

Edit: The input cat /etc/resolv.conf returns No such file or directory Edit 2: After following the advice of a previous answer, cat /etc/resolv.conf now gives:

This file is managed by man:systemd-resolved(8) Do not edit.

And other such information about the file. However, I still cannot access the internet. Edit 3: Putting in cat /etc/resolv.conf gives the nameserver 127.0.0.53 and options ends0 trust-ad lines, but not the search example.com one.

Additonally, entering in /etc/reslov.conf gives bash: /etc/resolv.conf: Permission denied if that is of any use to anybody.

Edit 4: Somehow, someway, for reasons known but to God, cat /etc/resolv.conf is again telling me there is no such file. I did restart the computer a moment ago to see if that would set things right. Clearly, it did not. Putting in sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf returns Unable to resolve host (my name)'s computer: Temporary failure in name resolution followed by (after a password entry) ln: failed to create smbolic link etc/resolv.conf: No such file or directory

Edit 5: Upon creating that text file nameserver 8.8.8.8 and trying to save it as * etc/resolv.conf* I am told that there is an error for every place I would try to save it in, as there is "No such file or directory."

This is entirely new and doesn't happen when I save a quickly drawn-up word document.

Edit 6: An error upon trying to save the new file they are as follows:

(gedit: 3844): Tepl-WARNING ** (timestamp): GVfs metadata is not supported fallback to TeplMetadataManager. Either GVfs is not correctly installed or GVfs metadta are not supported on this platform. In the later case, you should configure Tepl with --disable-gvfs-metadata

The second:

(gedit: 3998) WARNING ** (timestamp): Hit unhandled case 11 (error opening file "/etc/resolv.conf": too many levels of symbolic links) in parse_error

Finally:

(geditt:3998) CRITICAL ** (timestamp) _gedit_tab_save_as_async: assertion'tab-> state == GEDIT_TAB_STATE_NORMAL || tab->state == GEDIT_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION || tab-> state == GEDT_TAB_STATE_SHOWING_PRINT_PREVIEW' failed

Additonally, when trying to open the old /etc/resolv.conf I am told it cannot be opened because "its target "/run/system/resolve/stub-resolv.conf" doesn't exist"

Edit 7: rm /etc/resolv.conf produces rm: cannot remove '/etc/resolv.conf': permission denied

I also cannot just drag it to the trash or delete it in other known ways.

I am beginning to wonder if reinstalling ubuntu entirely would be easier at this point.

Final Edit:

It works! The problem seems to have been some odd final remnant of my old VPN. Upon removing it and restarting the machine the problem vanished. While I am still concerned about things like how the computer cannot find /etc/resolv.conf when I order it to destroy the file, I can cross that bridge later.

I would like to thank everyone who helped me with this, as I know you all have other things to do. I hope that someday I understand this stuff well enough to pay it forward.


Hey there I also faced the same after uninstalling protonvpn . basically what it does is that it leaves the network settings of ProtonVPN killswitch just the same even after uninstalling the vpn, according to this post.

See this page for the solution.

Disable the kill switch if you have uninstalled the app

The kill switch can be easily disabled from within the official Linux CLI app, but this will not be possible if you have uninstalled the CLI app first without disabling the kill switch. This may result in your system being unable to access the internet. To remove the kill switch after the CLI app has been uninstalled:

  • Identify ProtonVPN connection names by running the command:

    nmcli connection show --active
    

This will display a list of all your system’s active connections.

  • Look for any connections with the pvpn- prefix. This usually includes pvpn-killswitch and pvpn-ipv6leak-protection, and may include pvpn-routed-killswitch. Delete all these connections using the following command:

    nmcli connection delete [connection name]
    

    For example:

    nmcli connection delete pvpn-killswitch
    
  • Re-run the following command to verify that ProtonVPN connections have been deleted:

    nmcli connection show --active
    

If any ProtonVPN connections remain, delete them as described above.


Without /etc/resolv.conf file, the DNS resolution will not work. It's quite strange why the file got deleted. Did you use any VPN software?

Type the command systemctl status systemd-resolved (the service name is systemd-resolved, not resolved alone) to see if the service is running. If the service does not run, try to start/enable it (systemctl start systemd-resolved/systemctl enable systemd-resolved). If it is running, and /etc/resolv.conf still doesn't exist, do the following:

sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

This should re-create your /etc/resolv.conf and the DNS resolution should start working.

Update: Your /etc/resolv.conf should contain - apart from some comments with information about the file - the following important lines at the bottom:

nameserver 127.0.0.53
options edns0 trust-ad
search example.com

where example.com should be replaced by your local domain (for example the one of your ISP).

If after linking /etc/resolv.conf to /run/systemd/resolve/stub-resolv.conf the above lines are not present in the file, try first disconnecting and re-connecting your network connection. If this doesn't fix the situation (the lines still don't appear), try restarting systemd-resolved. If still no effect, try linking /etc/resolv.conf to fallback static configuration file /usr/lib/systemd/resolv.conf:

sudo rm /etc/resolv.conf
sudo ln -s /usr/lib/systemd/resolv.conf /etc/resolv.conf

The file will not contain the "search" line, but should contain the two other ones.

If these lines are still not present, try to add them manually using a text editor (sudo gedit /etc/resolv.conf). Restart systemd-resolved after making the change.