If 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 188.8.131.52 and 184.108.40.206), though OpenDNS is also a pretty popular one (public DNS servers are at 220.127.116.11 and 18.104.22.168).
sudo nano /etc/resolv.conf
The resulting changes should look like this:
#temporary fix nameserver 22.214.171.124 nameserver 126.96.36.199 #existing, currently not working entries nameserver 188.8.131.52 nameserver 184.108.40.206
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):
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:
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.