Wikia

How To Wiki

How to setup pdnsd DNS server on Gentoo Linux

1,794pages on
this wiki
Talk0


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.

InstallingEdit

  • execute: emerge pdnsd

ConfiguringEdit

  1. cp /etc/pdnsd/pdnsd.conf.sample /etc/pdnsd/pdnsd.conf
  2. Edit: /etc/pdnsd/pdnsd.conf
    1. Replace the global section with
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. In the server section
      • 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
    1. Comment out all lines with nameserver
    2. Add line: nameserver 127.0.0.1
      This will make pdnsd you default DNS nameserver
  2. Edit /etc/conf.d/net
    • Add line
      dns_servers_lo=( "127.0.0.1" )
      This will ensure Gentoo respects the change
  3. Start Server:
    /etc/init.d/pdnsd start
  4. test as described in the test section
    • If it doesn't work debug
    • Or
      • To disable pdnsd
        • Stop Server:
          /etc/init.d/pdnsd stop#**
        • Return to normal configuration:
          Edit /etc/resolv.conf
          Return to previous configuration
  5. If pdnsd works, enable pdnsd to automatically startup
    • rc-update -a pdnsd default
      Output: * pdnsd added to runlevel default



TestingEdit

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
  • emerge bind-tools for dig
  • dig www.google.com
    Example Output:
 ; <<>> DiG 9.3.2 <<>> www.google.com
;; 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

;; ANSWER SECTION:
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.........
  • nslookup google.com
    Example Output:
Server:         127.0.0.1
Address:        127.0.0.1#53

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
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
  • pdnsd-ctl status
    Long detailed output
  • pdnsd-ctl server myisp retest
    Example Output:
    Opening socket
    /var/cache/pdnsd/pdnsd.status
    Succeeded

Dynamical DNS configurationEdit

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.

HelpEdit

  • read :
    • /etc/resolvconf/update.d/pdnsd
    • /etc/pdnsd/pdnsd.sample
  • man:
    • pdnsd
    • pdnsd.conf
    • -
From HowTo Wiki, a Wikia wiki.