This section covers the basic installation of PowerDNS. Execute these steps on both your primary and secondary Instances.
- dns
- ubuntu
- PowerDNS
- server
- MariaDB
The PowerDNS authoritative server is an open-source DNS server written in C++. An authoritative DNS server contains a database of public IP addresses and their associated domain names, serving the purpose of resolving those common names into machine-understandable IP addresses.
PowerDNS runs on most Linux distributions, including Ubuntu. This tutorial demonstrates how to install PowerDNS authoritative server with a MariaDB backend and PowerDNS Admin frontend, running on Ubuntu 22.04 LTS (Jammy Jellyfish).
Before you start
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- An SSH key
- At least 2 Instances running on Ubuntu Jammy Jellyfish (22.04 LTS)
Installing PowerDNS
-
Log into your Instance using SSH:
ssh root@<your_virtual_instance_ip> -
Update the
apt
package cache and upgrade the software to the latest version available:apt update && apt upgrade -y -
Install MariaDB using the
apt
package manager:apt install mariadb-server -y -
Initialize the database server by running the interactive setup wizard:
mysql_secure_installationYou will be prompted with the following questions:
- Enter current password for root: Press
Enter
if none is set. - Set root password?
Y
- Type in the new MariaDB root password and confirm it.
- Remove anonymous users?
Y
- Disallow root login remotely?
Y
- Remove test database and access to it?
Y
- Reload privilege tables now?
Y
- Enter current password for root: Press
-
Install PowerDNS and the MySQL backend:
apt install pdns-server pdns-backend-mysql -yConfirm that you want to use
dbconfig-common
to automatically configure the database.During the installation, you’ll be asked to enter a password for the MySQL backend user. Press
Enter
to generate a random password automatically.
Configuring the primary Instance
On the primary Instance, three main options need to be configured in the pdns.conf
configuration file: allow-axfr-ips
, api
, and master
.
-
Open the PowerDNS configuration file:
nano /etc/powerdns/pdns.conf -
Configure zone transfers to other hosts by editing the
allow-axfr-ips
block. In this example, we set up one primary (ns1.example.com
with IP192.0.2.1
) and one secondary (ns2.example.com
with IP192.0.2.2
) DNS server:allow-axfr-ips=192.0.2.2 -
Enable the API and set an
api-key
:api=yesapi-key=<MY_SECRET_API_KEY> -
Specify that this Instance is the primary server:
master=yes -
Save the file and restart the PowerDNS server to apply the configuration:
systemctl restart pdns.service
Configuring the secondary Instance
For the secondary Instance, configure PowerDNS to act as a secondary server.
If you have more than one secondary Instance, repeat these steps and change the DNS hostnames accordingly (e.g., ns3.example.com
).
-
Open the PowerDNS configuration file on the secondary Instance:
nano /etc/powerdns/pdns.conf -
Enable the slave mode and configure it to regularly refresh its data with the
slave-cycle-interval
option:slave=yesslave-cycle-interval=60 -
Add the primary Instance as a supermaster to the MariaDB backend. Connect to MariaDB and insert the necessary values:
mysql -p -u rootinsert into pdns.supermasters values ('192.0.2.1', 'ns2.example.com', 'admin');quit; -
Restart the PowerDNS service on the secondary Instance:
systemctl restart pdns.service
Testing replication
-
On the primary Instance, create a test DNS zone:
pdnsutil create-zone example.com -
Add the primary NS entry:
pdnsutil add-record example.com @ NS ns1.example.com -
Add the secondary NS entry:
pdnsutil add-record example.com @ NS ns2.example.com -
Increase the zone’s serial number to prepare for the zone transfer:
pdnsutil increase-serial example.com -
Send a
NOTIFY
message to the secondary Instance:pdns_control notify example.com -
Verify the replication by querying the secondary Instance:
dig NS example.com @ns2.example.com
Setting up a graphical interface (PowerDNS Admin)
-
Install Docker prerequisites:
apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y -
Download and install Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - -
Add Docker’s official repository:
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" -
Update the package list and install Docker:
apt update && apt install docker-ce docker-ce-cli containerd.io -y -
Run PowerDNS Admin using Docker:
docker run --net=host -d -v pda-data:/data ngoduykhanh/powerdns-admin:latest -
Open your Instance IP in a web browser:
http://<your_powerdns_admin_ip>
. Create a user account and log in. -
On your first login, enter the API credentials for your PowerDNS Instance.
-
After logging in, you can manage your DNS zones through the PowerDNS Admin web interface.
Conclusion
You have successfully installed a replicated PowerDNS server with a MariaDB backend on Ubuntu 22.04 LTS. Additionally, you have set up PowerDNS Admin, a web-based interface to manage your DNS zones.
For more advanced configuration options, refer to the PowerDNS documentation and the PowerDNS Admin project for further customization.