PowerDNS is a leading provider of secure open-source and commercial DNS software. PowerDNS solutions are focused on large-scale DNS service providers, including mobile and fixed-line broadband operators, and hosting and cloud service providers. PowerDNS also underpins scalable security solutions from market-leading vendors.
Providers trust PowerDNS to deliver an excellent user experience and protection against DDoS and malware attacks, as well as ensuring internet performance for Hosters and ISPs.
Setting up an authoritative PowerDNS server involves several steps. Below is a detailed guide on how to install and configure PowerDNS as an authoritative server on a Linux system, such as Ubuntu.
Step 1: Update Your System
Before installing any new software, ensure your system is up to date:
sudo apt update
sudo apt upgrade -y
Step 2: Install PowerDNS and Backend
PowerDNS supports multiple backends (e.g., MySQL, PostgreSQL, SQLite, etc.). For this guide, we’ll use the MySQL backend.
- Install PowerDNS and MySQL Backend:
sudo apt install pdns-server pdns-backend-mysql
- Install MySQL Server:
If MySQL server is not already installed, install it:
sudo apt install mysql-server
Step 3: Configure MySQL for PowerDNS
- Secure MySQL Installation:
sudo mysql_secure_installation
- Log in to MySQL:
sudo mysql -u root -p
- Create PowerDNS Database and User:
CREATE DATABASE powerdns;
CREATE USER 'pdns'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON powerdns.* TO 'pdns'@'localhost';
FLUSH PRIVILEGES;
EXIT;
- Create PowerDNS Tables:
Download the PowerDNS schema and import it into the database:
curl -O https://raw.githubusercontent.com/PowerDNS/pdns/master/modules/gmysqlbackend/schema.sql
mysql -u pdns -p powerdns < schema.sql
Step 4: Configure PowerDNS
- Edit the PowerDNS Configuration File:
Open/etc/powerdns/pdns.conf
in a text editor:
sudo nano /etc/powerdns/pdns.conf
- Set the MySQL Backend Configuration:
Add the following lines, replacingyourpassword
with the password you set for thepdns
MySQL user:
launch=gmysql
gmysql-host=127.0.0.1
gmysql-user=pdns
gmysql-password=yourpassword
gmysql-dbname=powerdns
Step 5: Start and Enable PowerDNS
- Start PowerDNS Service:
sudo systemctl start pdns
- Enable PowerDNS to Start on Boot:
sudo systemctl enable pdns
Step 6: Verify PowerDNS Operation
- Check the Status of PowerDNS:
sudo systemctl status pdns
- Test PowerDNS:
You can use thedig
command to test if PowerDNS is working correctly. For example:
dig @localhost example.com
Step 7: Adding Zones and Records
- Log in to MySQL:
mysql -u pdns -p powerdns
- Add a Zone:
INSERT INTO domains (name, type) VALUES ('example.com', 'NATIVE');
- Add DNS Records:
INSERT INTO records (domain_id, name, type, content, ttl) VALUES ((SELECT id FROM domains WHERE name='example.com'), 'example.com', 'SOA', 'ns1.example.com hostmaster.example.com 1 10800 3600 604800 3600', 86400);
INSERT INTO records (domain_id, name, type, content, ttl) VALUES ((SELECT id FROM domains WHERE name='example.com'), 'example.com', 'NS', 'ns1.example.com', 86400);
INSERT INTO records (domain_id, name, type, content, ttl) VALUES ((SELECT id FROM domains WHERE name='example.com'), 'example.com', 'A', '192.0.2.1', 86400);
INSERT INTO records (domain_id, name, type, content, ttl) VALUES ((SELECT id FROM domains WHERE name='example.com'), 'www.example.com', 'A', '192.0.2.2', 86400);
That’s it! You have now set up an authoritative PowerDNS server with a MySQL backend. Ensure that your firewall settings allow traffic on port 53 (both TCP and UDP) to your DNS server.