Today we are going to install a PowerDNS Authoritative server version 4.5 with MariaDB 10.5 backend on an Ubuntu 20.04 LTS Linux server.
Disclaimer: This tutorial comes with no warranty.
Installation Guide for PowerDNS Authoritative on Ubuntu 20.04 LTS
Ingredients:
- Virtual Machine 1GB memory, 1 ipv4 and 1 ipv6 address
- OS Linux Ubuntu 20.04 LTS
- Hostname for the server ns01.dnssec-script.com
1. Prepare the server
Build your virtual machine with the ingredients above, I assume you know how to do this.
By default Ubuntu listens on port 53 but we need that port
sudo apt install net-tools
netstat -apn|grep 53
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 452/systemd-resolve
udp 0 0 127.0.0.53:53 0.0.0.0:* 452/systemd-resolve
sudo systemctl stop systemd-resolved
sudo vim /etc/systemd/resolved.conf
DNS=8.8.8.8
DNSStubListener = no
sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
2. Install MariaDB 10.5
Now we are going to install the MariaDB database server:
sudo apt-get install software-properties-common dirmngr apt-transport-https -y
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://ams2.mirrors.digitalocean.com/mariadb/repo/10.5/ubuntu focal main'
sudo apt update
sudo apt install mariadb-server -y
sudo mysql_secure_installation
Default the “binlog_format” is set to ‘STATEMENT’, change this to ‘ROW’:
sudo vim /etc/mysql/mariadb.conf.d/50-server.cnf
Insert line under [mysqld]
binlog-format=ROW
sudo systemctl restart mariadb
And create a database for PowerDNS:
mysql -u root -p
MariaDB [(none)]> show variables like 'binlog_format';
MariaDB [(none)]> create database powerdns;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON powerdns.* TO 'powerdns'@'localhost' IDENTIFIED BY 'yourdatabasepassword';
Now create all the PowerDNS tables and indexes as described on this page in the PowerDNS docs https://doc.powerdns.com/authoritative/backends/generic-mysql.html#default-schema
MariaDB [(none)]> use powerdns;
MariaDB [powerdns]> CREATE TABLE domains ( … etc
3. Install PowerDNS Authoritative Server 4.5
Now we are ready to install PowerDNS, yeah! We are going to install PowerDNS from here https://repo.powerdns.com/
sudo vim /etc/apt/sources.list.d/pdns.list
deb [arch=amd64] http://repo.powerdns.com/ubuntu focal-auth-45 main
sudo vim /etc/apt/preferences.d/pdns
Package: pdns-*
Pin: origin repo.powerdns.com
Pin-Priority: 600
curl https://repo.powerdns.com/FD380FBB-pub.asc | sudo apt-key add - &&
sudo apt-get update &&
sudo apt-get install pdns-server pdns-backend-mysql -y
4. Configure PowerDNS
Now we are going to configure PowerDNS
vim /etc/powerdns/pdns.conf
launch=gmysql
gmysql-host=127.0.0.1
gmysql-user=powerdns
gmysql-password=yourdatabasepassword
gmysql-dbname=powerdns
gmysql-dnssec
secondary=yes
autosecondary=yes
local-address=0.0.0.0,::
version-string=anonymous
daemon=yes
guardian=yes
webserver=yes
webserver-address=0.0.0.0
webserver-allow-from=1.2.3.4
webserver-password=changeme
webserver-port=80
api=yes
api-key=xxx
Start the powerdns service:
sudo systemctl start pdns
Check the running services and connections to the database:
netstat -alnp4 | grep pdns
Check your logs if everything is allright:
tail -f /var/log/syslog
5. Create DNS records for the server
To be able to use your new server as a DNS server you need to add the DNS records for the server hostname.
Create the DNS records for your hostname
- ns01.dnssec-script.com A -> ipv4 1.2.3.4
- ns01.dnssec-script.com AAAA -> ipv6 1:2:3::4
Create the reverse DNS records for your ip’s
- ipv4 4.3.2.1.in-addr.arpa. PTR -> hostname ns01.dnssec-script.com
- ipv6 4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.0.2.0.0.0.1.0.0.0.ip6.arpa. PTR -> hostname ns01.dnssec-script.com
6. Test your DNS server
This sample query sent to the server should now return quickly without data:
dig +short www.example.com @127.0.0.1
7. Time Synchronisation
Make sure your server has the right date and time:
date
That’s it for now!