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.
For Ubuntu:
For Fedora:
- Login as root and type:
- Download the latest source package from SOFTPEDIA. - Uncompress the archive:
make install
Configuring
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:
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:
- Ubuntu: Open the /etc/dhcp3/dhclient.conf file in your favorite text editor, remove all its contents and paste these directives: - Fedora: Create a new file called dhclient.conf in /etc/ directory, open it with your favorite directory and paste these directives:
request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, host-name;
require subnet-mask, domain-name-servers;
timeout 60;
retry 60;
reboot 10;
select-timeout 5;
initial-interval 2;
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
- Start dnsmasq (start this command with sudo for Ubuntu):
Testing
- Open a terminal and type this command for a domain name you haven't visited since dnsmasq's installation: