SANOG 41 DNS workshop
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Auth DNS Lab

Authoritative DNS Setup using PowerDNS (4.9)

In this lab, we will configure the Authoritative DNS server with PowerDNS along with zone replication

Goal 1: Setup primary server

Login to the primary server (e.g

Step 1: Update repo using apt.

sudo apt update -y

Step 2: Add PowerDNS repository

(These instructions are based on PowerDNS official documentation which can be found here)

Create the file /etc/apt/sources.list.d/pdns.list with this content:

sudo vim /etc/apt/sources.list.d/pdns.list
deb [signed-by=/etc/apt/keyrings/auth-49-pub.asc arch=amd64] jammy-auth-49 main

Put this in /etc/apt/preferences.d/auth-49:

Package: auth*
Pin: origin
Pin-Priority: 600

and execute the following commands:

sudo install -d /etc/apt/keyrings; curl | sudo tee /etc/apt/keyrings/auth-49-pub.asc &&
sudo apt-get update &&
sudo apt-get install pdns-server

Step 3: Install powerdns with SQLite as the backend using apt.

sudo apt install pdns-server pdns-backend-sqlite3 sqlite3 -y

Step 4: Setup sqlite backend

Dump sqlite3 schema to be used powerdns as backend

sudo sqlite3 /var/lib/powerdns/pdns.sqlite3 < /usr/share/doc/pdns-backend-sqlite3/schema.sqlite3.sql

Change ownership of pdns.sqlite3 to pdns user and group.

sudo chown -R pdns:pdns /var/lib/powerdns/pdns.sqlite3

Step 5: Update pdns.conf to make use of sqlite backend

Change pdns configuration to use sqllite3 as backend, edit file and add lines on end of the file.

sudo vi /etc/powerdns/pdns.conf

Next, remove default config which uses bind backend
sudo rm /etc/powerdns/pdns.d/bind.conf

Step 6: Now, do the config checks.

sudo pdns_server --config=check

Step 7: Restart PowerDNS

sudo systemctl restart pdns     

Step 8: Verify that PowerDNS is running:

sudo systemctl status pdns   

● pdns.service - PowerDNS Authoritative Server
     Loaded: loaded (/lib/systemd/system/pdns.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2024-04-23 04:01:15 UTC; 4s ago
       Docs: man:pdns_server(1)
   Main PID: 8715 (pdns_server)
      Tasks: 8 (limit: 2244)
     Memory: 46.7M
        CPU: 126ms
     CGroup: /system.slice/pdns.service
             └─8715 /usr/sbin/pdns_server --guardian=no --daemon=no --disable-syslog --log-timestamp=>

Also, verify if powerdns is listening on port 53.

sudo ss -plantu


Netid    State      Recv-Q     Send-Q         Local Address:Port          Peer Address:Port     Process
udp      UNCONN     0          0                 *         users:(("pdns_server",pid=250237,fd=5))
udp      UNCONN     0          0                       [::]:53                    [::]:*         users:(("pdns_server",pid=250237,fd=6))

Query localhost with a random query. It should return with “status: REFUSED” since we are not hosting this zone:

dig @localhost ns

; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> @localhost ns
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 21343
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

; EDNS: version: 0, flags:; udp: 1232
;                 IN      NS

;; Query time: 0 msec
;; SERVER: ::1#53(localhost) (UDP)
;; WHEN: Tue Apr 23 04:10:30 UTC 2024
;; MSG SIZE  rcvd: 42

Goal 2: Setup secondary server

Repeat step 1 to step 8 on secondary server (e.g Proceed to next step only after verifying that both primary and secondary server have PowerDNS running as per step 8.

Next, proceed to Replication Setup to setup zone replication between primary and secondary.