On Ubuntu 12.04, I’ve been looking on how to change the DNS servers withouth using the ones appointed by the DHCP server. This assumes that you have a general idea about DNS, if not do a quick Google search on it. In earlier versions, this has been done by modifying the resolv.conf file, but now it’s done by modifying the dhcp.conf file.
How to change your DNS servers from the command line in Ubuntu 12.04 (earlier/later versions may apply)
Modify the the dhcp.conf file:
sudo nano /etc/dhcp/dhclient.conf
I’ve added the line stating the custom DNS servers (in this example i’m using Google’s public DNS servers, for more, read below)
prepend domain-name-servers 18.104.22.168, 22.214.171.124;
Next i’ve commented the domain-name, domain-name-servers, domain-search, host-name, so that my PC is not requesting any DNS from the DHCP server, and replaced it with domain-name, domain-search, host-name,
You can probably understand better from the screenshot below:
Now restart your internet connection so that the changes may apply. In my case, i’m using my wireless network (wlan0) :
sudo ifconfig wlan0 down
sudo ifconfig wlan0 up
Why would you change your DNS servers?
- to access websites that your ISP is probably blocking (frequent case in countries where the goverment enforces strict policies on the internet service providers). A quick example is (infamous) PirateBay.Org , which in Denmark is blocked by the major ISP, as you can see in the picture below, displayed when trying to access it:
- to bypass the restrictions on certain networks – i’ve encountered networks, where upon bandwidth abuse (or similar activities) the user is banned from using the DNS
- avoid malicious DNS replies – when connected to (unknown/obscure) wireless networks (and not only) there is a high chance of being directed to a different website than the one written in the address bar of your browser. And you can’t really notice at first sight because the website looks exactly the same. This is called phishing and it’s very common with big websites with a lot of users. (check out Facebooks example)
- to cover your tracks (at least a part of them) when doing odd stuff on the network
Name some custom DNS servers
While some are specially built to evade censorship, some will not provide that benefit, but you can still use them when there is no alternative. Below you can see my top 3 DNS providers. I’ve chosen each for what they provide the best:
- for reliability – Googles Public DNS : 126.96.36.199 ; 188.8.131.52
- for censorship evasion – UncensoredDNS.Org : 184.108.40.206 ; 220.127.116.11
- for safety – Commodo Secure DNS : 18.104.22.168 ; 22.214.171.124
For a bigger list check here.