Quick Reference

Cheatsheets

Practical command references for Linux, networking, servers, containers, databases, and more.

Cheatsheet#powerdns-cheatsheet

PowerDNS Cheatsheet

PowerDNS is a high-performance, open-source authoritative DNS server that supports multiple backends (MySQL, PostgreSQL, BIND zone files, etc.).

Installation

# Debian / Ubuntu
sudo apt install pdns-server pdns-backend-bind
 
# RHEL / CentOS / Fedora
sudo dnf install pdns pdns-backend-bind
 
# Arch Linux
sudo pacman -S powerdns

Service Management

sudo systemctl enable --now pdns       # Start and enable on boot
sudo systemctl restart pdns            # Restart service
sudo systemctl reload pdns             # Reload configuration
sudo systemctl status pdns             # Check status

Configuration

Config File Locations

  • Authoritative Server: /etc/powerdns/pdns.conf
  • Recursor: /etc/powerdns/recursor.conf

Common Settings (pdns.conf)

launch=gmysql                          # Backend to use (gmysql, gpgsql, bind, etc.)
gmysql-host=127.0.0.1
gmysql-user=pdns
gmysql-password=secret
gmysql-dbname=pdns
 
local-address=0.0.0.0                 # Listen on all interfaces
local-port=53                          # DNS port
api=yes                                # Enable REST API
api-key=changeme                       # API key for authentication
webserver=yes                          # Enable built-in web server
webserver-address=0.0.0.0
webserver-port=8081

Zone Management (pdnsutil)

# Create a new zone
pdnsutil create-zone example.com
 
# Add DNS records to a zone
pdnsutil add-record example.com www A 192.168.1.10
pdnsutil add-record example.com mail MX "10 mail.example.com"
pdnsutil add-record example.com @ AAAA 2001:db8::1
pdnsutil add-record example.com @ TXT "v=spf1 mx -all"
 
# Delete a specific record
pdnsutil delete-rrset example.com www A
 
# Delete an entire zone
pdnsutil delete-zone example.com
 
# List all zones
pdnsutil list-all-zones
 
# Show all records in a zone
pdnsutil list-zone example.com
 
# Check zone consistency and report errors
pdnsutil check-zone example.com
 
# Rectify zone (fix ordering, required for DNSSEC)
pdnsutil rectify-zone example.com

DNSSEC

# Enable DNSSEC for a zone
pdnsutil secure-zone example.com
 
# Show DNSSEC keys and DS records for a zone
pdnsutil show-zone example.com
 
# Disable DNSSEC for a zone
pdnsutil disable-dnssec example.com

Backup and Restore

# Export zone in BIND format
pdnsutil b2b-export example.com > example.com.zone
 
# Import zone from BIND format file
pdnsutil load-zone example.com example.com.zone

PowerDNS Recursor

The recursor is a separate service for recursive DNS resolution.

# Install (Debian / Ubuntu)
sudo apt install pdns-recursor
 
# Service management
sudo systemctl enable --now pdns-recursor
sudo systemctl restart pdns-recursor
sudo systemctl status pdns-recursor
 
# Recursor control commands
rec_control ping                       # Check if recursor is running
rec_control reload-zones               # Reload forward/auth zones
rec_control wipe-cache example.com     # Clear cache for a specific domain
rec_control get-all                    # Dump all statistics

Troubleshooting

# View PowerDNS logs
journalctl -u pdns -f
journalctl -u pdns-recursor -f
 
# Test DNS resolution against localhost
dig @localhost example.com
dig @localhost example.com AAAA
dig @localhost example.com MX

Resources