How to setup pdnsd DNS server on Gentoo Linux

This is incomplete: to be completed

pdnsd is a light weight DNS server that has the added benefit of caching DNS entires, which most DNS servers do not do. This allows users who shutdown or restart their computers to keep DNS caches.

Installing

 * execute: emerge pdnsd

Configuring
global { perm_cache=2048; run_as="pdnsd"; status_ctl = on;  # Important to enable status control run_ipv4=on; par_queries=2;    # How many servers are probed in parallel interface = "lo"; # Interface on which the pdnsd listens }
 * 1) cp /etc/pdnsd/pdnsd.conf.sample /etc/pdnsd/pdnsd.conf
 * 2) Edit: /etc/pdnsd/pdnsd.conf
 * 3) Replace the global section with
 * 1) In the server section
 * 2) * edit the 'ip' variable to be your ISP's DNS forwarding servers
 * Example: ip = "202.101.22.33","202.101.22.34";
 * 1) Edit: /etc/resolv.conf
 * 2) Comment out all lines with nameserver
 * 3) Add line: nameserver 127.0.0.1
 * This will make pdnsd you default DNS nameserver
 * 1) Edit /etc/conf.d/net
 * 2) *Add line
 * dns_servers_lo=( "127.0.0.1" )
 * This will ensure Gentoo respects the change
 * 1) Start Server:
 * /etc/init.d/pdnsd start
 * 1) test as described in the test section
 * 2) * If it doesn't work debug
 * Or
 * 1) **To disable pdnsd
 * 2) ***Stop Server:
 * /etc/init.d/pdnsd stop#**
 * 1) ***Return to normal configuration:
 * Edit /etc/resolv.conf
 * Return to previous configuration
 * 1) If pdnsd works, enable pdnsd to automatically startup
 * 2) *rc-update -a pdnsd default
 * Output: * pdnsd added to runlevel default

Testing
Some of these tests are redundant, but it never hurts.


 * Start DNS Server
 * /etc/init.d/pdnsd start


 * Try the following command line test
 * Execute the following

; <<>> DiG 9.3.2 <<>> www.google.com
 * emerge bind-tools for dig
 * dig www.google.com
 * Example Output:
 * global options: printcmd
 * Got answer:
 * ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52275
 * flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 6, ADDITIONAL: 6


 * QUESTION SECTION:
 * www.google.com.                       IN      A

www.google.com. 481428 IN      CNAME   www.l.google.com. www.l.google.com. 249    IN      A       66.102.7.104 www.l.google.com. 249    IN      A       66.102.7.147 www.l.google.com. 249    IN      A       66.102.7.99 .........etc......... Server:        127.0.0.1 Address:       127.0.0.1#53
 * ANSWER SECTION:
 * nslookup google.com
 * Example Output:

Non-authoritative answer: Name:  google.com Address: 64.233.167.99 Name:  google.com Address: 64.233.187.99 Name:  google.com Address: 72.14.207.99 PING google.com (64.233.167.99) 56(84) bytes of data. 64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=1 ttl=245 time=116 ms
 * ping google.com
 * pdnsd-ctl status
 * Long detailed output
 * pdnsd-ctl server myisp retest
 * Example Output:
 * Opening socket
 * /var/cache/pdnsd/pdnsd.status
 * Succeeded

Dynamical DNS configuration
One advantage of pdnsd that it allows several ways to set DNS servers of you ISP without having to manually put them into /etc/pdnsd/pdnsd.conf file. This is handy when you get DNS servers through DHCP, especially on laptop which could access internet in unfamiliar places.

The simplest way is the following


 * In the server section delete "ip" line. Instead, insert a 'file' directive pointing to /etc/resolv.conf file="/etc/resolv.conf"; Now pdnsd will parse /etc/resolv.conf and take nameservers from there.
 * Created by DHCP, /etc/resolv.conf does not contain 127.0.0.1. To correct for this, create /etc/resolv.conf.head file with one line nameserver 127.0.0.1 It will be inserted in the beginning of /etc/resolv.conf and will be used first. pdnsd will skip 127.0.0.1 from the list of external DNS servers, since it coincides with its own address.

Help

 * read :
 * /etc/resolvconf/update.d/pdnsd
 * /etc/pdnsd/pdnsd.sample
 * man:
 * pdnsd
 * pdnsd.conf

From HowTo Wiki, a Wikia wiki.