Removed resolv.conf, connected to network, but no internet connection

I removed resolv.conf in order to clear my DNS settings, thinking that it would auto-regenerate on reboot, but it has not, and I can no longer connect to the internet. I can’t post the detailed information of the inxi command due to having no connection on the machine, so I can’t copy paste it.

I’ve tried a few things to fix this issue:
sudo resolvconf -u
sudo systemctl restart NetworkManager

I tried sudo touch resolv.conf and sudo nano resolv.conf but both give me No such file or directory (nano does it when I try to save and exit the editor).

not sure if this will work but is there any /etc/resolv.conf??

if not then paste the output of cat /run/NetworkManager/resolv.conf to that file and try again

1 Like

Hi @Mo0rBy,

If you are :100:% sure that it’s all, you can, theoretically just recreate it with the correct owner and permissions. Here is mine as example:

$ cat /etc/resolv.conf

# Generated by NetworkManager
search example.com
nameserver 8.8.8.8
nameserver 8.8.4.4

After which you should set the correct owner and permissions:

sudo chown root:root /etc/resolv.conf

and

sudo chmod 0644 /etc/resolv.conf

Followed by rebooting and seeing if it works.

If it does, then just for good measure, reinstall NetworkManager

pamaac reinstall networkmanager

I can’t recreate the file with nano or touch. When I try to save and exit nano, I get [ Error writing resolv.conf: No such file or directory ] and when i do sudo touch resolv.conf I get touch: cannot touch 'resolv.conf' : No such file or directory.

So I can’t even create before changing owner/permissions etc.

Also, I don’t have the pamaac package manager installed, I think i just have pacman and nothing else.

I do get an output for the cat command :slight_smile:

# Generated by NetworkManager
nameserver 127.0.0.53
options edns0 trust-ad

However, I can’t create a new resolv.conf file with touch or nano, I just get No such file or directory, which is strange, because I’m, CREATING the file, so of course it doesn’t exist.

I tried pacman -S networkmanager and it fails to download the .pkg.tar.zst file and fails to resolve hostnames got loads of stuff (which makes sense as I dont have internet connection because of this issue)

What is the output for :point_down:

sudo ls /etc/res*

/etc/resolv.conf /etc/resolvconf.conf

So this says that resolv.conf does exist?

I just did sudo rm resolv.conf no errors. Then did sudo nano resolv.conf and I was able to save it with the output of the previous cat command. Restarting now to see if it works.

That’s exactly what I was about to suggest.

YES, thank you, that did trick. Very strange behaviour, do you know any guesses why it was like that?

None whatsoever. Just make sure the ownership and permissions are correct as per my previous post.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.