Ubuntu Free DNS Cache Server
A DNS cache server is piece of software that runs on a computer that will translate a domain name into the true ip address. In other words when you type a web address into your web browser, your internet provider’s DNS server will look into it records and search for the domain name that your are requesting. The main reason you would want a local dns cache server is to lower the ping rate when you request a specific web page. Another reason to have a free dns cache server is because the dns records will be tailored to your browsing experience.
Once you request a specific web address or domain in your web browser, one of two things will happen on the internet providers free DNS server. The first thing that could happen when you request a domain is that the address is already located within the internet providers dns records.
The second thing that could happen when you request a web address is that domain is not located within your internet providers records. If the domain that you are requesting is not with your internet providers free DNS server, then the address will have to be found at a different dns server, then will be added to your internet providers dns server records.
If you are already using a linux os such as Ubuntu, simply open up your terminal program and type in dig web-address.com. For example I used Yahoo, so I typed in dig yahoo.com. As you can see from the picture below that my ping rate took 30 milliseconds for my request to reach the dns server. For the experts out there, you will also realize that I am already using a local dns server.
Now once you have run the dig command once, rerun same command again to see what you will get. Once I ran dig yahoo.com again you will now notice that my ping rate to my dns server is only 1 millisecond. Now you may think saving only 29 milliseconds doing one search, but if you add this time up over many searches, it pays itself off. For those out there that still use dial up or satellite internet will gain the most benefit by having their own local DNS server. For example a satellite internet provider such as Wild Blue or Hughes Net might have anywhere from a 200 msec – 1500 msec ping time, so if you could cut this time down to a few milliseconds would end up saving a lot of time.
Setup DNS Cache Server
Now it is time to get down to the guts of setting up your very own free dns cache server. In this tutorial I will be showing you how setup your local dns cache server on one computer, but you could set your dns server to control your whole local network. This would allow every computer on your network to talk to the free dns cache server, saving time for everyone on the local network. If you have multiple computers on you network and would like to setup a local network dns server, follow the Ubuntu gateway firewall tutorial, then come back to this page to setup you freel dns cache server. Just make sure that you install dnsmasq instead of bind9.
The first that you will need to do in setting up your local dns cache server is to install the dns server software.
sudo apt-get install dnsmasq vim
Once dnsmasq is installed, you will now need to configure the dnsmasq to act as a cache server.
Within the dnsmasq.conf file look for the line that says # listen-address=127.0.0.1 and remove the # to make this line active.
The next thing that you will need to do is edit the /etc/resolv.conf file to allow your local dns to be able to talk to your internet providers dns server, just in case your local dns server doesn’t contain the web addresses your are looking for. When you first setup your local caching dns server, there will not be addresses in your dns server, so your dns server will need to be able to find this address somewhere.
You internet providers dns address can be found using many different techniques, so I will explain just a few of these ways. If you are using a router try typing one of these addresses to access your default gateway. Open a web browser and type in 192.168.1.1 or 192.168.1.254 in the address bar. If you are using a 2wire gateway the address will be 192.168.1.254, and if you are using another router such as a Linksys router, the address will be 192.168.1.1.
If you are on a Windows based pc, simply open up the command prompt by going to Start –> Accessories –> Command Prompt, or search for “cmd”. Once you have the command prompt open, type in ipconfig /all. Once you have typed the ipconfig /all command just look though the list for DNS servers. If you still don’t know what the hell I’m talking about you can also use the address of your default gateway or the dns addresses provided by OpenDNS.com. 184.108.40.206 and 220.127.116.11.
Now it is time to edit the
Make sure you add 127.0.0.1 to the file, since this will tell the resolv.conf file to look at your local host first for the dns translation. As you can see from my resolv.conf file that I have added 127.0.0.1, 10.0.0.1 and 192.168.1.254. Since I am running a local dns server on my whole network, I have also added the address of my dns cache server. In all reality 127.0.0.1 and 10.0.0.1 addresses are referring to the same computer.
nameserver 127.0.0.1 <-----Localhost DNS