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.

vi /etc/dnsmasq.conf

Within the dnsmasq.conf file look for the line that says # listen-address= 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 or in the address bar.  If you are using a 2wire gateway the address will be, and if you are using another router such as a Linksys router, the address will be

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. and

DNS Cache Server Command Prompt

Now it is time to edit the /etc/resolv.conf file.

vi /etc/resolv.conf

Make sure you add 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, and  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 and addresses are referring to the same computer.

domain gateway.2wire.net

search gateway.2wire.net

nameserver <-----Localhost DNS

DNS Cache Server Resources:

What is DNS Cache Server

4 Responses to Ubuntu Free DNS Cache Server

  • Dolley says:

    This iofnmration is off the hizool!

  • Louisa Ellman says:

    i cant find my secondary dns server. i’ve already tried going to star run cmd ipconfig/all but it only lists one dns server

  • Lola Lockwood says:

    i registered my domain name with 1 provider and then registered the hosting with a 2nd provider, I now was told I have to do some dns domain registry thing so the website can be published with the second host…please explain what that is and how should i do it?

  • Lola Lockwood says:

    I’ve been playing around with the idea for some time. Ok, let me give a little background, and then my intentions. I’m a systems engineer with degrees in programming, networking, and analysis so feel free to get technical peoples. :)

    I’ve been researching more and more into security and have been experimenting with fundamental network operations. My goal is to set up my own personal WAN in my lab (in my house) and monitor packet payloads of rudimentary network operations such as dns cache updates, ARP, ns lookups, dn translations, maybe even as far as active directory replication, remote LDAP mods, DHCP, etc…

    I’ve got a collection of 9 computers dating back no more than 7 years in my lab that have been set up as DDNS web servers in the past, but i don’t need them anymore. I’d like to set up a series of dedicated DNS servers, routers, separate dubnets, a client machine, a couple web servers, and what not on a private WAN all objects running some kind of net monitor to document what goes on, how and when.

    I’m not sure how i’m going to model these after the real internet. What OS’s should i use for each object? I have access to any kind of OEM installer including Server2003 Enterprise, Redhat, Ubuntu, XP-Pro. Non of this model will be connected to the real net, ideally i’d like to try and break my system to try and prevent it at the office.

    Any advice? Any books, labs or documentation you could recommend? How would you do it? What experiments would you conduct?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to Newsletter

Sign Up Today

Get a free copy of Develop Your Own Database Software.
database software, pdf

For A Limited Time