How to Install PowerDNS on Ubuntu 24

PowerDNS is a robust and scalable DNS server solution that supports multiple backends. This guide will walk you through installing and configuring PowerDNS with a MySQL backend on Ubuntu 24.04. Example IP addresses and credentials are used in this tutorial—replace them with your actual values where necessary.

Step 1: Install MariaDB

  1. Add the MariaDB signing key:
curl -o /etc/apt/keyrings/mariadb-keyring.pgp 'https://mariadb.org/mariadb_release_signing_key.pgp'
  1. Create a repository file for MariaDB:
nano /etc/apt/sources.list.d/mariadb.sources

Add the following content:

# MariaDB 11.4 repository list - created 2025-01-06 08:21 UTC
# https://mariadb.org/download/
X-Repolib-Name: MariaDB
Types: deb
# deb.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# URIs: https://deb.mariadb.org/11.4/ubuntu
URIs: https://mirrors.neterra.net/MariaDB/repo/11.4/ubuntu
Suites: noble
Components: main main/debug
Signed-By: /etc/apt/keyrings/mariadb-keyring.pgp
  1. Update package lists and install MariaDB:
apt update
apt install -y mariadb-client mariadb-server
  1. Secure the MariaDB installation:
mysql_secure_installation

Step 2: Configure MariaDB for PowerDNS

  1. Log in to MariaDB:
mysql
  1. Create a database and user for PowerDNS:
CREATE DATABASE pdns;
GRANT ALL ON pdns.* TO 'pdnsadmin'@'localhost' IDENTIFIED BY 'example-password';
FLUSH PRIVILEGES;
EXIT;

Step 3: Install PowerDNS

  1. Disable the systemd-resolved service and update DNS settings:
systemctl disable --now systemd-resolved
rm -rf /etc/resolv.conf
echo "nameserver 8.8.8.8" > /etc/resolv.conf
  1. Install PowerDNS and its MySQL backend:
apt install -y pdns-server pdns-backend-mysql
  1. Initialize the PowerDNS database:
mysql -u pdnsadmin -p pdns < /usr/share/pdns-backend-mysql/schema/schema.mysql.sql

Step 4: Configure PowerDNS

  1. Create and edit the MySQL backend configuration:
nano /etc/powerdns/pdns.d/pdns.local.gmysql.conf

Add the following:

# MySQL Configuration
launch+=gmysql
gmysql-host=127.0.0.1
gmysql-port=3306
gmysql-dbname=pdns
gmysql-user=pdnsadmin
gmysql-password=example-password
gmysql-dnssec=yes
  1. Secure the configuration file:
chmod 640 /etc/powerdns/pdns.d/pdns.local.gmysql.conf
chown pdns:pdns /etc/powerdns/pdns.d/pdns.local.gmysql.conf
  1. Edit the main configuration file:
nano /etc/powerdns/pdns.conf

Replace its contents with:

config-dir=/etc/powerdns
daemon=yes
disable-axfr=no
guardian=yes
local-address=0.0.0.0
local-port=53
log-dns-details=on
loglevel=3
module-dir=/usr/lib/x86_64-linux-gnu/pdns
master=yes
slave=yes
slave-cycle-interval=60
slave-renotify=yes
setgid=pdns
setuid=pdns
version-string=powerdns
include-dir=/etc/powerdns/pdns.d
api=yes
api-key=example-api-key
webserver-port=8001
webserver-address=127.0.0.1
webserver-allow-from=127.0.0.1/32
launch=

Step 5: Test and Start PowerDNS

  1. Test PowerDNS:
systemctl stop pdns
pdns_server --daemon=no --guardian=no --loglevel=9
  1. If there are no errors, start the PowerDNS service:
systemctl start pdns

Conclusion

You now have a fully functional PowerDNS installation on Ubuntu 24.04 using a MySQL backend. Remember to replace example values such as passwords, IP addresses, and API keys with your actual configuration. Always ensure your DNS server is secured before exposing it to the internet.