How to Install PowerDNS on Ubuntu Linux
PowerDNS is a powerful, open-source tool used to manage domain names and network traffic. It is fast and works well with databases like MariaDB to store your settings. This guide helps you set it up on Ubuntu Linux for 2026.
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

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

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?
Leave a Reply