Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Install PowerDNS on Ubuntu with a MariaDB Backend

Install the PowerDNS authoritative server, store the zones in MariaDB and check that it runs.

Domains and DNS2 min read9 screenshots

Step 1: Update the system

sudo apt update && sudo apt upgrade -y
Updating the system

Step 2: Install MariaDB

sudo apt install mariadb-server -y
Installing MariaDB

Step 3: Create the database for PowerDNS

sudo mysql -u root -p
Opening the MariaDB shell
CREATE DATABASE powerdns;
CREATE USER 'pdns'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON powerdns.* TO 'pdns'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Creating the database and the user
  • CREATE DATABASE powerdns; makes the database.
  • CREATE USER 'pdns'@'localhost' ... makes a user with a password.
  • GRANT ALL PRIVILEGES ... gives that user all rights on that database.
  • FLUSH PRIVILEGES; makes the rights active.
  • EXIT; leaves the shell.

Step 4: Install PowerDNS and the backend

sudo apt install pdns-server pdns-backend-mysql -y
Installing PowerDNS and the MySQL backend
Note: On Ubuntu, systemd-resolved listens on port 53 on localhost, which clashes with PowerDNS. If PowerDNS does not start, turn off the stub listener: set DNSStubListener=no in /etc/systemd/resolved.conf and restart systemd-resolved.

Step 5: Configure PowerDNS

The backend package adds a config for the database. Check the files in /etc/powerdns/pdns.d/ and remove the default bind backend file if there is one. Then set:

sudo nano /etc/powerdns/pdns.conf
launch=gmysql
gmysql-host=127.0.0.1
gmysql-user=pdns
gmysql-password=your_password
gmysql-dbname=powerdns
The PowerDNS configuration
  • launch=gmysql tells PowerDNS to use the MySQL backend.
  • gmysql-host is the address of the database server.
  • gmysql-user and gmysql-password are the login of the PowerDNS user.
  • gmysql-dbname is the database name.

Step 6: Create the tables

Import the schema:

sudo mysql -u root -p powerdns < /usr/share/doc/pdns-backend-mysql/schema.mysql.sql
Importing the PowerDNS schema

(The path can differ. Look in /usr/share/doc/pdns-backend-mysql/. The file may be compressed as schema.mysql.sql.gz.)

Step 7: Start and enable PowerDNS

sudo systemctl start pdns
sudo systemctl enable pdns
Starting PowerDNS

Step 8: Check the status

sudo systemctl status pdns
The PowerDNS status

Test with a query to the server:

dig @127.0.0.1 example.com SOA

At first the answer is empty, because there are no zones yet. Add zones with pdnsutil create-zone example.com and records with pdnsutil add-record, or with a web tool such as PowerDNS-Admin.

Quick recap

  • Create the MariaDB database and user.
  • Install pdns-server and pdns-backend-mysql, set launch=gmysql and import the schema.
  • Start pdns and add zones.