Install PowerDNS on Ubuntu 20.04

PowerDNS is an OpenSource DNS server.

Update apt repo

apt-get update && apt-get upgrade -y

On Ubuntu, systemd-resolved listen to port 53. This is a local DNS resolver, we need to stop this service before we can install PowerDNS.

systemctl disable systemd-resolved
systemctl stop systemd-resolved
rm -f /etc/resolv.conf
echo "nameserver 1.1.1.1" > /etc/resolv.conf
echo "nameserver 8.8.8.8" >> /etc/resolv.conf

To install PowerDNS with MySQL backend, run

apt install pdns-server pdns-backend-mysql

Since we are using MySQL backend to store DNS zones, we need to install MySQL database.

apt install mariadb-server

Login to MySQL, create a database and user.

mysql
CREATE DATABASE powerdns;
GRANT ALL ON powerdns.* TO 'powerdns'@'localhost' IDENTIFIED BY 'YOUR_MYSQL_PW_HERE';

Restore database scheme provided by powerdns

mysql powerdns < /usr/share/pdns-backend-mysql/schema/schema.mysql.sql

You can see this scheme in PowerDNS documentation.

Configure PowerDNS to use MySQL backend

vi /etc/powerdns/pdns.d/mysql.conf

Add following content

# MySQL Configuration
# Launch gmysql backend
launch+=gmysql
# gmysql parameters
gmysql-host=localhost
gmysql-port=3306
gmysql-dbname=powerdns
gmysql-user=powerdns
gmysql-password=YOUR_MYSQL_PW_HERE
gmysql-dnssec=yes
# gmysql-socket=

Restart PowerDNS

systemctl restart pdns

If PowerDNS started properly, you will see it listening to port 53. You can verify with command netstat -lntp

PowerDNS netstat

In above picture, you will see PowerDNS listen to port 53 and 8081. Port 8081 is API port, you won't see it unless you enabled it.

To verify PowerDNS is running, you can use command

root@vultr:~# dig @127.0.0.1

; <<>> DiG 9.16.1-Ubuntu <<>> @127.0.0.1
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 63898
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;.				IN	NS

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Oct 12 06:53:40 UTC 2020
;; MSG SIZE  rcvd: 28

root@vultr:~# 

Back to PowerDNS

Need help with Linux Server or WordPress? We can help!

Leave a Reply

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