Domain names have been made available to allow people to easily remember Internet sites, while the IP addresses enable computers to communicate and transfer data between them. A DNS server turns domain names into IP addresses that are usually provided by the same firm that provides the Internet access but you can, if you want, set up your own DNS server. This is, however, a more difficult process to complete. Moreover, if your ISP provides a rather slow DNS server, you can solve both problems with one solution: dnsmasq. dnsmasq is an easy to configure DNS forwarder, also known as a DNS cache application. This application will speed up the domain names look-up process with about 30-60ms per request by listening to the sent requests and saving the responses locally. This way, the next time a past request will be sent, dnsmasq will provide the response in a much shorter time than an usual DNS server.
dnsmasq can also be used for a small network. You can do this by using the computer's running dnsmasq IP as the DNS IP for all computers in the network.Installing
dnsmasq is a rather popular application, so you might find it in repositories for many distributions. To install it, you should first try using your distribution's package manager. The package used for caching nameserver lookups is called simple, dnsmasq
sudo apt-get install dnsmasq
(If you can't find it, make sure you have Universe
in your repositories list.)
- Login as root and type:Others
- Download the latest source package from SOFTPEDIA
- Uncompress the archive:
tar xfz dnsmasq-version.tar.gz
- Compile and install dnsmasq:
The basic configuration method that will quickly get dnsmasq up and running is:
- Open /etc/dnsmasq.conf with your favorite text editor.
- Search for the line:
- And replace it with ( also remove the "#"):
(for a single computer)
(for a small network)NOTE:
The secret for DNS caching to work is the /etc/resolv.conf file which must contain a nameserver 127.0.0.1.or.network.IP
. However, if you're computer gets its IP address using DHCP, the /etc/resolv.conf file will be overwritten and dnsmasq will no longer work properly. If you enter your network IP addresses manually, you can skip this next step.
To make sure that specific line will be automatically added to /etc/resolv.conf, you should:
: Open the /etc/dhcp3/dhclient.conf file in your favorite text editor, remove all its contents and paste these directives:
: Create a new file called dhclient.conf in /etc/ directory, open it with your favorite directory and paste these directives:
prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, host-name;
require subnet-mask, domain-name-servers;
If you're setting dnsmasq as a DNS server for a small network, you should replace the 127.0.0.1
IP with the computer's network IP.Starting
- First of all, if you're not using DHCP or you do but your computer hasn't gotten a new lease since you've installed dnsmasq, you have to manually add the following line to /etc/resolv.conf
(again, replace this IP with the computer's network IP if you're running dnsmasq for a local network)
- Start dnsmasq (start this command with sudo
- Open a terminal and type this command for a domain name you haven't visited since dnsmasq's installation:
The first time you'll see something like: ;; Query time: 72 msec
but if you run a dig again for the same domain name, you'll notice that the Query time has decreased to 1 or 2 msec. Multiply that difference by the number of websites you visit per day and you'll get an estimated speed improvement.