Follow
CMS Ubuntu Linux

How to Install PowerDNS on Ubuntu Linux

Richard
Written by
Richard
Oct 7, 2022 Updated Apr 18, 2026 3 min read
How to Install PowerDNS on Ubuntu Linux

You can install PowerDNS on Ubuntu Linux to manage your domain names and network traffic efficiently.

PowerDNS is a highly regarded, open-source authoritative DNS server known for its speed and flexibility, often integrating with databases like MariaDB for configuration storage.

This guide focuses on installing the PowerDNS Authoritative Server, specifically version 4.9, on a recent Ubuntu LTS release.

By following these steps, you’ll have a robust DNS solution running on your Ubuntu machine.

Why use PowerDNS?

You use PowerDNS to take full control of your DNS infrastructure. It provides a scalable way to manage thousands of records with a modern web interface. When you are done, you will have a professional-grade DNS management system accessible through your browser.

Install the MariaDB database server

We use MariaDB to hold all your DNS records securely. Follow our guide here to get it running: How to install MariaDB database server on Ubuntu Linux

Once installed, open your terminal and connect to the database:

sudo mysql

Run these commands to create your database and user:

CREATE DATABASE pdns;
CREATE USER 'pdnsadmin'@'localhost' IDENTIFIED BY 'your_secure_password';
GRANT ALL PRIVILEGES ON pdns.* TO 'pdnsadmin'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Install PowerDNS

First, we need to handle the system resolver. Instead of deleting files, we update the system configuration. Run these commands:

sudo resolvectl dns eth0 8.8.8.8
sudo sed -i 's/#DNS=/DNS=8.8.8.8/' /etc/systemd/resolved.conf
sudo systemctl restart systemd-resolved

Now, install the PowerDNS server:

sudo apt update
sudo apt install pdns-server pdns-backend-mysql

Import the database structure:

sudo mysql -u pdnsadmin -p pdns < /usr/share/pdns-backend-mysql/schema/schema.mysql.sql

Configure PowerDNS

Edit the configuration file to connect your database:

sudo nano /etc/powerdns/pdns.d/pdns.local.gmysql.conf

Add your database details:

launch+=gmysql
gmysql-host=127.0.0.1
gmysql-user=pdnsadmin
gmysql-password=your_secure_password
gmysql-dbname=pdns

Install the PowerDNS Admin web application

You need a web tool to manage settings easily. First, install the necessary Python tools:

sudo apt install python3-venv python3-pip gunicorn nginx certbot python3-certbot-nginx

Set up the application folder and virtual environment:

sudo git clone https://github.com/ngoduykhanh/PowerDNS-Admin.git /var/www/html/pdns
cd /var/www/html/pdns
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Run database migrations to prepare the app:

export FLASK_APP=powerdnsadmin/__init__.py
flask db upgrade

Configure PowerDNS and Nginx

Enable the API in /etc/powerdns/pdns.conf by adding:

api=yes
api-key=generate_a_very_long_random_string_here

Restart PowerDNS: sudo systemctl restart pdns

Configure Nginx to serve the site and secure it with HTTPS:

sudo certbot --nginx -d yourdomain.com

PowerDNS Admin interface on Ubuntu Linux

Start the Service

Create a Gunicorn service file to keep the application running in the background. After creating the service file in /etc/systemd/system/pdnsadmin.service, start it:

sudo systemctl daemon-reload
sudo systemctl enable --now pdnsadmin

Creating a PowerDNS user account on Ubuntu

Open your browser to your domain name, log in, and enter the API key you generated earlier to finish the setup.

[Unit] [Service] [Install] [Unit] [Socket] [Install] [1] [10066] [2022-10-07 12:55:24 -0500] [10066] [INFO] [10066] [2022-10-07 12:55:24 -0500] [10066] [INFO] [10066] [2022-10-07 12:55:24 -0500] [10066] [INFO] [10067] [2022-10-07 12:55:24 -0500] [10067] [INFO] [1]

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

How to Install Let's Chat on Ubuntu Linux
Ubuntu Linux How to Install Let's Chat on Ubuntu Linux
Change Power Button Behavior in Ubuntu Linux
Ubuntu Linux Change Power Button Behavior in Ubuntu Linux
How to Change Default Distro in Windows Subsystem for Linux
Windows How to Change Default Distro in Windows Subsystem for Linux
How to Install GNOME Desktop on Ubuntu 24.04
Ubuntu Linux How to Install GNOME Desktop on Ubuntu 24.04

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *