Ubuntu – DNS settings messed up and resolvconf uninstalled

dnslubuntunetworkingresolvconf

Yesterday I messed up my network settings on Lubuntu 16.04. Wifi had problems and I thought it was my problem, it turned out later, that the problem was a temporary problem with the central wifi, it basically showed as connected but I could not load any pages in Firefox.

Trying to fix it I am afraid i screwed up my DNS and networking settings 🙁

I followed the advice of doing:

sudo apt-get remove --purge resolvconf && sudo apt-get install resolvconf 

So I removed resolvconf but then of course I could not re-install it because internet was not working 🙁

I can "ping 8.8.8.8" but I can't reach google.com as I get:

ping: unknown host google.com

This, as far as I understood means a DNS problem.

I think resolvconf is necessary for fixing my problem, I tried editing the config file adding

nameserver 8.8.8.8
nameserver 8.8.8.4

But It does not work 🙁

On my laptop fortunately I also have Windows 10 on a small partition, I used it to download the .deb file of resolvconf from http://packages.ubuntu.com/ but it gives me a MIMEtype error and does not let me install it.

I tried downloading the tar.gz but when I extract it I can't do

./config (or configure)

because I get:

debconf: DbDriver "passwords" warning: could not open /var/cache/debconf/passwords.dat: Permission denied
Template parse error near `# These templates have been reviewed by the debian-l10n-english', in stanza #1 of ./templates

How do I reinstall resolvconf and how do I fix the "ping: unknown host google.com" internet problem? I tried to look online and on askubuntu but no luck so far 🙁

I am desperate as I am on holiday and I really need Lubuntu connected to the network, Windows 10 is damn slow and I don't like it 🙁

If anyone can help it would be great! Thank you in advance.

Edit: trying to run "cat /etc/resolv.conf" and "cat /etc/resolvconf/resolv.conf.d/base" gives me

no such file or directory

But if i check with Pacman in /etc/ I can find a "resolv.conf" file (which I opened and it is empty) and a "resolv.config" (which contains nameserver 8.8.8.8 and nameserver 8.8.4.4, which are Google DNS)

Best Answer

Problem: In my case I accidentally removed the resolvconf file. So my computer is connected to the internet, but it has no idea what a DNS server is and so it has no way of translating readable URLs into IP addresses. Hence you can do ping 8.8.8.8 and it will respond, but ping google.com fails.

So the solution is basically to reinstall resolvconf. You can download the package from the Ubunut archive: http://archive.ubuntu.com/ubuntu/pool/main/r/resolvconf

One neat hack around this is to go to another computer, or your phone, or whatever and find out the address of archive.ubuntu.com - just ping it and copy the IP address. You could also use a WHOIS service I guess.

Then go back to the Ubuntu system and open /etc/hosts and add:

x.x.x.x archive.ubuntu.com

where x.x.x.x is the IP address you found out via ping on another machine. So now your computer should know about archive.ubuntu.com. You can then open the page in a browser and navigate to the resolvconf package. Of course putting in that IP address would also work and you should probably avoid leaving it in your hosts file in case it changes later.

Download the most recent package, and then run sudo dpkg -i resolvconf_1.79ubuntu8_all.deb or whatever the deb file you downloaded was. I suggest manually running dpkg even if your browser prompts you to install it, it didn't work that way for me.

Presto: you now have resolveconf again and it should work more or less instantly.

Related Question