DNS Caching

This page will explain how to install DNS caching to improve DNS lookup performance.

Install required packages:
Open Synaptic package manager and search for bind. Install below 2 packages.

bind-utils - for dig/nslookup bind      - for DNS caching

Change hostname and domain:
We will set the computername to compname and the domain to somedomain. You can choose any name of your choice for these.

In PCLinuxOS Control Center > Network & Internet > Host definitions add below entries

127.0.0.1 compname.somedomain 127.0.0.1 localhost

You can also add above entries directly to /etc/hosts file. You need to be a root user to edit this file.

Edit file /etc/sysconfig/network as root user and modify below line.

HOSTNAME=compname.somedomain

Start local DNS service:
In PCLinuxOS Control Center > System > "Manage system services..."

Go to named service line, select checkbox next to "on boot", click Start button

Add the new local DNS to network settings:
Add "nameserver 127.0.0.1" without any empty lines to /etc/resolvconf/resolv.conf.d/base

Add below lines to without any empty lines /etc/resolvconf/resolv.conf.d/tail

nameserver 208.67.222.222 nameserver 208.67.220.220

Open a terminal window and change user to root by using su command. Restart network by executing below command

service network resetart

Below is a sample output for the command. Output will vary depending on your network setup. [root@icsserver andrzejl]# service network restart Shutting down interface eth1:                                             [  OK  ] Shutting down interface ppp0:                                             [  OK  ] Shutting down loopback interface:                                         [  OK  ] Disabling IPv4 packet forwarding:                                         [  OK  ] Bringing up loopback interface:                                           [  OK  ] Enabling IPv4 packet forwarding                                           [  OK  ] Configuring wireless regulatory domain                                    [  OK  ] Bringing up interface eth1:                                               [  OK  ] Bringing up interface ppp0:                                               [  OK  ] [root@icsserver andrzejl]#

Verification of the setup:
Open a terminal window, execute below commands and look for similar output. [root@icsserver andrzejl]# cat /etc/resolv.conf nameserver 127.0.0.1 nameserver 208.67.222.222 nameserver 208.67.220.220 Below command does a DNS lookup. The first lookup takes 265 msec. The second lookup only takes 1 msec. [andrzejl@icsserver ~]$ dig pclinuxos.com
 * 1) Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(
 * 2)     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN


 * <<>> DiG 9.8.1-P1 <<>> pclinuxos.com
 * global options: +cmd
 * Got answer:
 * ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10203
 * flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 0

...


 * Query time: 265 msec

...


 * SERVER: 127.0.0.1#53(127.0.0.1)
 * WHEN: Sat Dec 10 21:41:28 2011
 * MSG SIZE rcvd: 131

[andrzejl@icsserver ~]$ dig pclinuxos.com


 * <<>> DiG 9.8.1-P1 <<>> pclinuxos.com
 * global options: +cmd
 * Got answer:
 * ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8272
 * flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 2

...


 * Query time: 1 msec

...


 * SERVER: 127.0.0.1#53(127.0.0.1)
 * WHEN: Sat Dec 10 21:41:29 2011
 * MSG SIZE rcvd: 163