Share your love
Install and Configure PowerDNS on Rocky Linux 8
This tutorial intends to teach you to Install and Configure PowerDNS (pdns) and PowerAdmin on Rocky Linux 8 Step by Step.
PowerDNS is a DNS server solution. It is a secure, scalable, and reliable software under the GPL. PowerAdmin is a Web GUI tool that helps you to manage your DNS zones from a web interface.
In this guide, you will learn the complete installation and configuration of PowerDNS on Rocky Linux 8 by following the steps below:
- Install PowerDNS Dependencies
- Install MariaDB
- Configure MariaDB for PowerDNS
- Install and Configure PowerDNS
- Manage PowerDNS Service
- Configure Firewall
- Install PowerAdmin
- Access PowerAdmin Web Interface
Steps To Install and Configure PowerDNS on Rocky Linux 8
To complete this guide, you must log in to your server as a non-root user with sudo privileges and set up a basic firewall. To do this, you can follow our guide on Initial Server Setup with Rocky Linux 8.
Also, If you have an enabled SELinux, you need to disable it.
Step 1 – Dependencies for PowerDNS on Rocky Linux 8
First, you need to run the system update with the following command:
sudo dnf update -y
Then, you need to install EPEL and Remi repositories on your server:
# sudo dnf -y install epel-release
# sudo dnf -y install http://rpms.remirepo.net/enterprise/remi-release-8.rpm
Now you need to enable your PHP Remi 7.4 by using the command below:
sudo dnf module enable php:remi-7.4 -y
Step 2 – MariaDB Installation
At this point, you will need to install MariaDB as our database server. To do this, run the following command:
sudo dnf -y install mariadb mariadb-server
When your installation is completed, start and enable the MariaDB service to start on boot:
# sudo systemctl start mariadb
# sudo systemctl enable mariadb
Now run the MySQL security script to set a password for your MariaDB service:
sudo mysql_secure_installation
Answer the questions by default and set a password for your MySQL root user.
Step 3 – Configure MariaDB for PowerDNS
At this point, you need to log in to your MariaDB shell and create a database for PowerDNS installation and add a user to manage the database on Rocky Linux 8.
Log in to your MariaDB shell by using the command below:
sudo mysql -u root -p
From your MariaDB shell, create a database for PowerDNS, here we named it powerdb, you can choose your desired name:
MariaDB [(none)]> CREATE DATABASE powerdb;
Then, create a user to manage your PowerDNS DB and set a strong password for it, here we named it poweruser:
MariaDB [(none)]> CREATE USER 'poweruser' identified by 'strongpassword';
At this point, you need to grant all the permissions to your PowerDNS user and database on Rocky Linux 8:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON powerdb.* to 'poweruser'@'localhost' identified by 'strongpassword';
Next, flush the privileges by using the following command:
MariaDB [(none)]> FLUSH PRIVILEGES;
At this point, you need to create table structures for your created DB. To do this, change your database to the PowerDNS DB with the command below:
MariaDB [(none)]> USE powerdb;
Then, run the following MySQL commands to create the table structures:
MariaDB [powerdb]> CREATE TABLE domains (
id INT AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL,
PRIMARY KEY (id)
) Engine=InnoDB;
CREATE UNIQUE INDEX name_index ON domains(name);
CREATE TABLE records (
id BIGINT AUTO_INCREMENT,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(10) DEFAULT NULL,
content VARCHAR(64000) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
disabled TINYINT(1) DEFAULT 0,
ordername VARCHAR(255) BINARY DEFAULT NULL,
auth TINYINT(1) DEFAULT 1,
PRIMARY KEY (id)
) Engine=InnoDB;
CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);
CREATE INDEX recordorder ON records (domain_id, ordername);
CREATE TABLE supermasters (
ip VARCHAR(64) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) NOT NULL,
PRIMARY KEY (ip, nameserver)
) Engine=InnoDB;
CREATE TABLE comments (
id INT AUTO_INCREMENT,
domain_id INT NOT NULL,
name VARCHAR(255) NOT NULL,
type VARCHAR(10) NOT NULL,
modified_at INT NOT NULL,
account VARCHAR(40) NOT NULL,
comment VARCHAR(64000) NOT NULL,
PRIMARY KEY (id)
) Engine=InnoDB;
CREATE INDEX comments_domain_id_idx ON comments (domain_id);
CREATE INDEX comments_name_type_idx ON comments (name, type);
CREATE INDEX comments_order_idx ON comments (domain_id, modified_at);
CREATE TABLE domainmetadata (
id INT AUTO_INCREMENT,
domain_id INT NOT NULL,
kind VARCHAR(32),
content TEXT,
PRIMARY KEY (id)
) Engine=InnoDB;
CREATE INDEX domainmetadata_idx ON domainmetadata (domain_id, kind);
CREATE TABLE cryptokeys (
id INT AUTO_INCREMENT,
domain_id INT NOT NULL,
flags INT NOT NULL,
active BOOL,
content TEXT,
PRIMARY KEY(id)
) Engine=InnoDB;
CREATE INDEX domainidindex ON cryptokeys(domain_id);
CREATE TABLE tsigkeys (
id INT AUTO_INCREMENT,
name VARCHAR(255),
algorithm VARCHAR(50),
secret VARCHAR(255),
PRIMARY KEY (id)
) Engine=InnoDB;
CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm);
When you are done, you can confirm your tables with the command below:
MariaDB [powerdb]> SHOW TABLES;
Output
+-------------------+
| Tables_in_powerdb |
+-------------------+
| comments |
| cryptokeys |
| domainmetadata |
| domains |
| records |
| supermasters |
| tsigkeys |
+-------------------+
7 rows in set (0.001 sec)
Finally, exit from your MariaDB shell:
MariaDB [powerdb]> quit;
Step 4 – PowerDNS Installation on Rocky Linux 8
At this point, you can start to install PowerDNS on your server, but first, you must disable systemd-resolve. This is meant to prevent conflicting ports since PowerDNS will also use port 53. To do this, run the command below:
# sudo systemctl disable systemd-resolved
# sudo systemctl stop systemd-resolved
Then, you must remove the symlinked resolve.conf and create a new one with the following commands:
# ls -lh /etc/resolv.conf
# echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
Now you can use the following command to install PowerDNS on Rocky Linux 8:
sudo dnf -y install pdns pdns-backend-mysql bind-utils
Step 5 – PowerDNS Configuration
At this point, you need to make some configuration changes to the PowerDNS default config file(/etc/pdns/pdns.conf). By default, PowerDNS is used to bind as the backend. You need to disable this by commenting on the line launch=bind and allowing MySQL backend configuration.
To do this, open the file with your favorite text editor, here we use the vi editor:
sudo vi /etc/pdns/pdns.conf
Find the line launch=bind and comment on it as shown below:
#launch=bind
Then, add the following content after the line you have commented on:
launch=gmysql
gmysql-host=localhost
gmysql-user=poweruser
gmysql-password=strongpassword
gmysql-dbname=powerdb
Note: Remember to change your database value.
When you are done, save and close the file.
Step 6 – Manage PowerDNS Service
Here you can start and enable your PowerDNS service by using the following commands:
# sudo systemctl start pdns
# sudo systemctl enable pdns
Verify your PowerDNS service is active and running on Rocky Linux 8:
sudo systemctl status pdns
Output
● pdns.service - PowerDNS Authoritative Server
Loaded: loaded (/usr/lib/systemd/system/pdns.service; enabled; vendor preset>
Active: active (running) since Sun 2023-05-21 04:35:57 EDT; 59s ago
Docs: man:pdns_server(1)
man:pdns_control(1)
https://doc.powerdns.com
Main PID: 93969 (pdns_server)
Tasks: 8 (limit: 23699)
Memory: 47.9M
CGroup: /system.slice/pdns.service
└─93969 /usr/sbin/pdns_server --socket-dir=/run/pdns --guardian=no ->
...
Step 7 – Configure Firewall for PowerDNS
We assumed that you have enabled firewalld, now you need to allow the DNS service through the firewall by using the command below:
sudo firewall-cmd --add-service=dns --permanent
Reload the firewall to apply the new rules:
sudo firewall-cmd --reload
At this point, your PowerDNS installation and configuration are completed, you can proceed to the next step to set up your PowerDNS Admin dashboard.
For more information, you can visit the PowerDNS Documentation page.
Step 8 – Install PowerAdmin on Rocky Linux 8
PowerAdmin is a web-based application for managing PowerDNS and it is based on PHP. So you need to install PHP, Apache, and PHP extensions with the command below:
sudo dnf install php httpd php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mhash gettext php-pear -y
Then, install PHP pear DB by using the command below on Rocky Linux 8:
sudo pear install db
Output
downloading DB-1.11.0.tgz ...
Starting to download DB-1.11.0.tgz (132,549 bytes)
.............................done: 132,549 bytes
install ok: channel://pear.php.net/DB-1.11.0
Start and enable your httpd service:
# sudo systemctl start httpd
# sudo systemctl enable httpd
Verify your httpd service is active and running on your Rocky Linux 8:
sudo systemctl status httpd
Output
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor prese>
Drop-In: /usr/lib/systemd/system/httpd.service.d
└─php-fpm.conf
Active: active (running) since Sun 2023-05-21 04:45:15 EDT; 37s ago
Docs: man:httpd.service(8)
Main PID: 98925 (httpd)
Status: "Running, listening on: port 80"
Tasks: 213 (limit: 23699)
Memory: 28.9M
CGroup: /system.slice/httpd.service
...
Download PowerAdmin Source Code
At this point, you need to use the following command to download the PowerDNS Admin on Rocky Linux 8. First, switch to your HTML directory:
cd /var/www/html/
Then, use the following command to download the PowerAdmin:
sudo wget https://sourceforge.net/projects/poweradmin/files/poweradmin-2.2.1.tar.gz
Extract your downloaded file:
sudo tar xvf poweradmin-2.2.1.tar.gz
Then, move your extracted file to the following directory:
sudo mv poweradmin-2.2.1 /var/www/html/poweradmin/
Finally, you need to allow the HTTP and HTTPS protocols through the firewall:
# sudo firewall-cmd --add-service={http,https} --permanent
# sudo firewall-cmd --reload
Step 9 – Access PowerAdmin Dashboard on Rocky Linux 8
At this point, you can continue your PowerDNS Admin installation on Rocky Linux 8 through the web interface. To do this, type your server’s IP address in your web browser followed by /poweradmin/install:
http://your-server-ip/poweradmin/install
You will see the step 1 installation of PowerAdmin, choose your desired language and click Go to step 2:
In Step 2 read the content and click Go to Step 3.
Next, you must enter your PowerDNS database credentials on Rocky Linux 8 and set a PowerAdmin administrator password and click Go to step 4:
Then, you need to enter a new user for PowerAdmin and set a password for it. Also, you need to set your hostmaster and nameservers and click Go to step 5.
At this point, the installer will tell you that log in to your MariaDB shell and perform the task given to you. To do this, you can use the command below:
sudo mysql -u root -p
Then, add the commands that you have seen from your installation step 5. When you are done, click Go to step 6.
Here you need to copy your config-me.inc.php file and make a change to the file. Switch to the following directory:
cd /var/www/html/poweradmin/inc
Then copy the file into a new file named config.inc.php:
cp config-me.inc.php config.inc.php
Now open the new file with your favorite text editor, here we use vi:
vi config.inc.php
From there you need to add the lines that you have got from the installer into the file. When you are done, save and close the file. And Click Go to step 7.
Finish PowerAdmin Configuration
Next, If you want support for the URLs used by other dynamic DNS providers, run “cp install/htaccess.dist .htaccess” and enable mod_rewrite in Apache. You must remove the directory “install/” from the Poweradmin root directory. To do this, you can switch to the following directory:
cd /var/www/html/poweradmin/install
And copy the htaccess.dist to a new file in poweradmin directory:
cp htaccess.dist ../.htaccess
Then, remove the install directory with the command below:
# cd ..
# rm -rf install
When you are done, click on Poweradmin:
Here you will see the PoweAdmin login page, you need to enter admin as the username and enter the PowerAdmin password you have created in the step 4 installation, and click Go:
Finally, you will see your PowerAdmin Administrator page.
That’s it you are done. From here you can manage your DNS Zones from the web interface.
Conclusion
At this point, you have learned to Install and Configure PowerDNS on Rocky Linux 8 Step by Step. Also, you have learned to access the PowerAdmin web GUI Tool for PowerDNS to manage your DNS zones.
Hope you enjoy it. You may be interested in these articles on the orcacore website: