Ubuntu 17.04 Internet Connection DNS Problem Resolved

I was running into some issues with the wifi connection on a fresh install of Ubuntu 17.04. The network showed it was connected and everything looked ok but I still couldn’t visit any sites. Turns out that for whatever reason the DNS wasn’t working properly. I did the following steps to debug and fix the problem.

First off I read one article that mentioned pinging these three things to see where the problem was. The first one is pinging localhost. The second Google’s public DNS server and the third is just a regular URL.

[bash light=”true”]ping -c3 192.168.0.1
ping -c3 8.8.8.8
ping -c3 www.ubuntu.com[/bash]

In my case the first two worked ok but the third wouldn’t work so that showed it was a DNS problem. So following instructions I found here. I updated /etc/hosts so it could connect to us.archive.ubuntu.com and also fi.archive.ubuntu.com.

The second one is country specific so you’ll need the IP for the country you’re in. If you try and run the ‘sudo apt-get update’ command then you’ll see which archive it’s trying to get files from.

Once I knew which archive I needed, I just pinged fi.archive.ubuntu.com from a working computer to get the ip. Then following the instructions I added entries for those two archives into hosts. The instructions had the IP and address the other way round from what was already in my file, so after switching those around and restarting, they worked.

My /etc/hosts file looked like this:

[bash light=”true”]127.0.0.1 localhost
91.189.91.23 security.ubuntu.com
91.189.91.23 us.archive.ubuntu.com
91.189.88.149 fi.archive.ubuntu.com[/bash]

I tested the hosts file by restarting and trying the following commands:

[bash light=”true”]sudo apt-get update
sudo apt-get dist-upgrade[/bash]

After letting those run (they took a while), my connection worked great 🙂