ubuntu-10-logoIf your hosted environment’s DNS services fail rendering your hosted Ubuntu 10.04 server unable to make connections to the outside world (maybe a cURL call to Google or Amazon is required by your system to function), a quick temporary fix is to change your environment’s DNS server settings to point to another, public provider.

To do this, make a change to the /etc/resolv.conf file and enter some new ‘nameserver’ entries which point to public DNS server addresses (which you can usually find with a pretty basic Google search). The most common one to switch to is Google (public DNS servers are at 8.8.8.8 and 8.8.4.4), though OpenDNS is also a pretty popular one (public DNS servers are at 208.67.222.222 and 208.67.220.220).

In practice:

sudo nano /etc/resolv.conf

The resulting changes should look like this:

#temporary fix
nameserver 8.8.8.8
nameserver 8.8.4.4
#existing, currently not working entries
nameserver 41.204.202.244
nameserver 196.7.147.46

The changes are instantaneous, meaning that once you saved the file, those new nameservers will be hit for any outgoing network requests.

Note that this is for Ubuntu 10.04. In Ubuntu 12.04 the handling of resolv.conf changed.

If you want to add your own nameserver address(es) in 12.04, then edit the file /etc/resolvconf/resolv.conf.d/head:

sudo nano /etc/resolvconf/resolv.conf.d/head

and add your nameserver there (eg: Google DNS):

nameserver 8.8.8.8

Save the file and then run

sudo resolvconf -u

Again, no reboot is required, though you might have to restart the network-manager:

sudo service network-manager restart

You can test if your fix is working by running the nslookup command against a valid domain:

nslookup www.google.com

If successful you’ll get a print out of the Server and Address being used to perform the lookup, followed by the Name/Address answer.