Share your love
Install PowerDNS on AlmaLinux 9 – Full and Easy Setup
In this guide, we intend to teach you How To Install PowerDNS on AlmaLinux 9, Configure it and also configure PowerAdmin.
PowerDNS is a versatile nameserver that supports a large number of different backends ranging from simple zone files to relational databases and load balancing/failover algorithms. It tries to emphasize speed and security.
PowerDNS Admin is a powerful web administrative tool for PowerDNS. It allows us to create as well as manage DNS zones easily from a web browser.
You can now proceed to the following steps provided by the Orcacore team to Install PowerDNS on AlmaLinux 9.
Table of Contents
Steps To Install and Configure PowerDNS and PowerAdmin on AlmaLinux 9
To Install PowerDNS on AlmaLinux 9, 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 AlmaLinux 9.
Also, you need to disable your AlmaLinux SELinux. To do this, you can follow our guide on Disable SELinux on AlmLinux.
Now proceed to the guide steps to Install PowerDNS on AlmaLinux 9.
Step 1 – Install PowerDNS Dependencies on AlmaLinux 9
First, you need to update your local package index 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-9.rpm
Now you need to enable your PHP Remi. Here we will enable PHP Remi 7.4 by using the command below:
sudo dnf module enable php:remi-7.4 -y
Step 2 – Install MariaDB on AlmaLinux 9
At this point, we will 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.
Configure MariaDB for PowerDNS
At this point, you need to log in to your MariaDB shell, create a database for PowerDNS installation, and add a user to manage the database.
Log in to your MariaDB shell on AlmaLinux by using the command below:
sudo mysql -u root -p
From your MariaDB shell, create a database for PowerDNS, here we named it powerdb:
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 AlmaLinux 9:
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 the 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);
ALTER TABLE domains ADD options VARCHAR(64000) DEFAULT NULL;
ALTER TABLE domains ADD catalog VARCHAR(255) DEFAULT NULL;
ALTER TABLE domains MODIFY type VARCHAR(8) NOT NULL;
CREATE INDEX catalog_idx ON domains(catalog);
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.003 sec)
Finally, exit from your MariaDB shell:
MariaDB [powerdb]> quit;
Step 3 – Install PowerDNS on AlmaLinux 9
At this point, you can start to install PowerDNS on AlmaLinux 9, 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 AlmaLinux 9:
sudo dnf -y install pdns pdns-backend-mysql bind-utils
Step 4 – Configure PowerDNS on AlmaLinux 9
At this point that you have learned to Install PowerDNS on AlmaLinux 9, 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 vi:
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
Remember to put your database value. When you are done, save and close the file.
Start and Enable PowerDNS Service
Now you can start and enable the PowerDNS service to start on boot by using the commands below:
# sudo systemctl start pdns
# sudo systemctl enable pdns
Verify your PowerDNS service is active and running on AlmaLinux 9:
sudo systemctl status pdns
Output
● pdns.service - PowerDNS Authoritative Server
Loaded: loaded (/usr/lib/systemd/system/pdns.service; enabled; vendor pres>
Active: active (running) since Tue 2022-12-20 05:37:11 EST; 38s ago
Docs: man:pdns_server(1)
man:pdns_control(1)
https://doc.powerdns.com
Main PID: 74378 (pdns_server)
...
Configure Firewall
At this point, 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
Now that you have learned to Install PowerDNS on AlmaLinux 9, let’s see how to install PowerDNS Admin.
Step 5 – Install PowerAdmin on AlmaLinux 9
PowerAdmin is a web-based application for managing PowerDNS and it is based on PHP. So you need to install PHP and its 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:
sudo pear install db
Start and enable your httpd service:
# sudo systemctl start httpd
# sudo systemctl enable httpd
Verify your httpd service is active and running on your AlmaLinux 9:
sudo systemctl status httpd
Output
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor pre>
Drop-In: /usr/lib/systemd/system/httpd.service.d
└─php-fpm.conf
Active: active (running) since Tue 2022-12-20 05:53:33 EST; 42s ago
Docs: man:httpd.service(8)
Main PID: 80139 (httpd)
Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes>
Tasks: 213 (limit: 23609)
...
Download PowerAdmin Source Code
At this point, you need to use the following command to download the PowerDNS Admin on AlmaLinux 9. First, switch to your HTML directory:
cd /var/www/html/
Then, use the following wget 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 6 – Access PowerAdmin Web Interface
At this step of Install PowerDNS on AlmaLinux 9, you can continue your PowerDNS Admin installation on AlmaLinux 9 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 AlmaLinux 9, 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. When you are done, save and close the file. And Click Go to step 7.
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, enter the PowerAdmin password you have created in the step 4 installation, and click Go:
Finally, you will see your PowerAdmin Administrator page.
Your installation is complete! You can now go ahead to add a master zone.
Conclusion
PowerDNS is widely used due to its features and its open-source nature, offering a reliable and scalable solution for DNS services. At this point, you have learned to Install PowerDNS on AlmaLinux 9 and Configure PowerDNS and PowerAdmin on AlmaLinux 9 step by step.
Hope you enjoy it. You may like these articles:
AlmaLinux HPC and AI Compatibility
Reset Root Password on AlmaLinux 9
Install SVN Server on AlmaLinux 9
Install Notepad++ on AlmaLinux 9
FAQs
Can PowerAdmin manage multiple PowerDNS servers on AlmaLinux 9?
PowerAdmin offers a centralized interface for administrators. So you can easily manage multiple DNS servers with PowerAdmin.
Is it possible to migrate from another DNS server to PowerDNS on AlmaLinux 9?
Yes. You can simply migrate from another DNS server to PowerDNS by transferring DNS records and configurations.