Syed Jahanzaib – Personal Blog to Share Knowledge !

June 13, 2011

Ubuntu : Persistent DNS Caching with pdnsd.

Filed under: Linux Related — Syed Jahanzaib / Pinochio~:) @ 8:30 AM

When I setup Squid on Ubutu, there was one problem that I faced frequently, is the slow DNS look-up performance, especially compared with the same hardware running Windows. I found one way of improving performance is to provide DNS caching on the local machine and to disable ipv6.
First to disable ipv6 on ubuntu, Add
net.ipv6.conf.all.disable_ipv6=1
to /etc/sysctl.conf and run sysctl -p

Now install pdnsd by
apt-get install pdnsd

now edit its config file
ano /etc/pdnsd.conf
and paste the following config, its mine, u can edit accordingly.


global {
perm_cache=1024;
cache_dir="/var/cache/pdnsd";
run_as="pdnsd";
#server_ip = 127.0.0.1;
#server_port=53;
status_ctl = on;
paranoid=on;
query_method=udp_tcp;
max_ttl=1w; # One week.
timeout=10;
}

server {
label=Lan;
ip=129.168.2.1;
timeout=30;
uptest=ping;
interval=30;
ping_timeout=300;
purge_cache=off;
caching=on;
preset=off;
}
server {
label=OpenDNS;
ip=221.132.112.8;
ip=221.132.112.9;
timeout=30;
uptest=ping;
interval=30;
ping_timeout=300;
purge_cache=off;
caching=on;
preset=off;
}

source {
owner=localhost;
serve_aliases=on;
file=”/etc/hosts”;
}

rr {
name=localhost;
reverse=on;
a=127.0.0.1;
owner=localhost;
soa=localhost,root.localhost,42,86400,900,86400,86400;
}

Now in /etc/resolv.conf , replace your nameserver with this
nameserver 127.0.0.1

restart pdnsd , and enjoy fast websites response due to local DNS caching 🙂 , also dont forget to add dns_nameservers 127.0.0.1 in squid.conf

2 Comments »

  1. is there’s any way to use the pdnsd along with open dsn i do not want to leave the opendns , i am new to ubuntu plz help me out

    Like

    Comment by Gunjan Parashar — December 9, 2012 @ 3:39 PM

  2. Hello bro
    server {
    label=Lan;
    ip=129.168.2.1; when I put the server ip address give error :
    my ip address is : 192.168.43.53
    Local name-server address “192.168.43.53” ignored in config file.
    Error in config file (line 24): Server section contains only local IP addresses.
    Bind pdnsd to a different local IP address or specify different port numbers in global section and server section if you want pdnsd to query servers on the same machine.
    [fail]
    server {
    label=Lan;
    ip=192.168.43.53;
    timeout=30;
    uptest=ping;
    interval=30;
    ping_timeout=300;
    purge_cache=off;
    caching=on;
    preset=off;

    and if possible to secure it ? to make only my local ips using cache and how to increase the cache size .

    this is the DNS server for my ISP ?

    server {
    label=OpenDNS;
    ip=221.132.112.8;
    ip=221.132.112.9;

    Like

    Comment by alfanet1 — January 16, 2014 @ 12:23 AM


RSS feed for comments on this post. TrackBack URI

Leave a comment