Install PowerDNS on CentOS 8 using MariaDB and PowerDNS-Admin

To
You can download this article in PDF format to support us through the following link.

Download the guide in PDF format

turn off
To

To
To

What is PowerDNS? PowerDNS is an open source authoritative name server that has been used as an alternative to BIND DNS. PowerDNS provides higher performance with minimal memory usage. Authoritative name servers provide records directly from themselves, while recursive name servers query other name servers to get the answers they need. In this guide, we will study how to install PowerDNS on CentOS 8 using MariaDB and PowerDNS-Admin.

Step 1: Prepare the server

First, we will disable CentOS SElinux to ensure that it does not prevent any installation that we will perform.

$ sudo vim /etc/selinux/config

Edit the line as shown to disable SElinux. Save the file and restart the server

# This file controls the state of SELinux on the system. 
# SELINUX= can take one of these three values: 
#     enforcing - SELinux security policy is enforced. 
#     permissive - SELinux prints warnings instead of enforcing. 
#     disabled - No SELinux policy is loaded. 
SELINUX=disabled
# SELINUXTYPE= can take one of these three values: 
#     targeted - Targeted processes are protected, 
#     minimum - Modification of targeted policy. Only selected processes are protected.  
#     mls - Multi Level Security protection. 
SELINUXTYPE=targeted

Restart the server

sudo reboot

Step 2: Install EPEL and Remi repository.

We need to install PowerDNS dependencies first. In this case, we will install EPEL repository and REMI for PHP installation. Run the following commands.

sudo dnf -y install epel-release
sudo dnf -y install http://rpms.remirepo.net/enterprise/remi-release-8.rpm

After adding the repository, you can use the following command to enable the PHP 7.4 Remi repository.

sudo dnf module enable php:remi-7.4

Step 3: Install and configure MariaDB

Run the following command to install MariaDB on the server.

sudo dnf -y install mariadb mariadb-server

After the installation is complete, start the MariaDB service and enable it to start at boot time.

sudo systemctl start mariadb
sudo systemctl enable mariadb

MariaDB service is now running. We need to protect it and set a root password. Use the command shown below.

sudo mysql_secure_installation

Answer the following prompts:

Answer the prompts as shown:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB 
     SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY! 

In order to log into MariaDB to secure it, we'll need the current 
password for the root user.  If you've just installed MariaDB, and 
you haven't set the root password yet, the password will be blank, 
so you should just press enter here. 

Enter current password for root (enter for none):  Press Enter
OK, successfully used password, moving on... 

Setting the root password ensures that nobody can log into the MariaDB 
root user without the proper authorization. 

Set root password? [Y/n] y
New password:  Enter New Password
Re-enter new password:  Repeat New Password 
Password updated successfully! 
Reloading privilege tables.. 
... Success! 
By default, a MariaDB installation has an anonymous user, allowing anyone 
to log into MariaDB without having to have a user account created for 
them.  This is intended only for testing, and to make the installation 
go a bit smoother.  You should remove them before moving into a 
production environment. 

Remove anonymous users? [Y/n] Y 
... Success! 

Normally, root should only be allowed to connect from 'localhost'.  This 
ensures that someone cannot guess at the root password from the network. 

Disallow root login remotely? [Y/n] Y 
... Success! 

By default, MariaDB comes with a database named 'test' that anyone can 
access.  This is also intended only for testing, and should be removed 
before moving into a production environment. 

Remove test database and access to it? [Y/n] Y 
- Dropping test database... 
... Success! 
- Removing privileges on test database... 
... Success! 
Reloading the privilege tables will ensure that all changes made so far 
will take effect immediately. 

Reload privilege tables now? [Y/n] Y 
... Success! 

Cleaning up... 

All done!  If you've completed all of the above steps, your MariaDB

Next, we need to create a database for the PowerDNS installation and add a user to manage the database. First, log in to MariaDB using the following command:

$ mysql -u root -p 

Enter the password you set above, then continue to create the database and user, and grant the user all permissions on the database.

Enter password:  Enter your DB root password
Welcome to the MariaDB monitor.  Commands end with ; or g. 
Your MariaDB connection id is 17 
Server version: 10.3.17-MariaDB MariaDB Server 

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. 

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. 

MariaDB [(none)]> create database powerdns; 
Query OK, 1 row affected (0.000 sec) 

MariaDB [(none)]> create user 'pdns' identified by 'mypassword' ;
Query OK, 0 rows affected (0.000 sec) 

MariaDB [(none)]>  grant all privileges on powerdns.* to 'pdns'@'localhost' identified by 'mypassword';          
Query OK, 0 rows affected (0.000 sec) 

MariaDB [(none)]> flush privileges; 
Query OK, 0 rows affected (0.001 sec) 

After creating the database and user, create the table structure for the created database by running the MySQL command shown below:

use powerdns;

Run the following MySQL command

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);
 
 quit;

You can confirm whether the table was created as follows:

MariaDB [powerdns]> show tables; 
+--------------------+ 
| Tables_in_powerdns | 
+--------------------+ 
| comments           | 
| cryptokeys         | 
| domainmetadata     | 
| domains            | 
| records            | 
| supermasters       | 
| tsigkeys           | 
+--------------------+ 
7 rows in set (0.000 sec)

Step 4: Install PowerDNS on CentOS 8

First, you need to disable the systemd-resolve that comes with CentOS by default. This is to prevent port conflicts, because PowerDNS will also use Port 53

sudo systemctl disable systemd-resolved
sudo systemctl stop systemd-resolved

Also delete the resolve.conf of the symbolic link and create a new one.

$ ls -lh /etc/resolv.conf
$ echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf

Now it’s time to install PowerDNS. Use the following command:

sudo dnf -y install pdns pdns-backend-mysql bind-utils

The default PowerDNS configuration file is /etc/pdns/pdns.conf. Open the file with your favorite editor. By default, PowerDNS uses bind as the backend. We need to disable it by commenting the following line Start = bind And allow MySQL backend configuration. Edit the file as follows:

#launch=bind
launch=gmysql 
gmysql-host=localhost 
gmysql-user=pdns 
gmysql-password=mypassword 
gmysql-dbname=powerdns

Save the changes and close the file. Continue to start the PowerDNS service and enable it to start at boot time.

sudo systemctl start pdns.
sudo systemctl enable pdns

Also allow DNS service through firewall

sudo firewall-cmd --add-service=dns --permanent
sudo firewall-cmd –reload

At this point, PowerDNS has been installed and is running. You can confirm the status with the following command.

$ systemctl status pdns

Output

Step 5: Install PowerAdmin on CentOS 8

PowerAdmin is a web-based application for managing PowerDNS, which is based on PHP. To install it, we first need to install PHP to enable us to run the application.

sudo dnf -y install httpd php 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

In addition, install other php pear packages as follows:

sudo dnf -y install php-pear-DB

Now start httpd service and enable it to start at system boot

sudo systemctl start httpd
sudo systemctl enable httpd

Use the following command to confirm httpd service

systemctl status httpd

Output

Install PowerDNS on CentOS 8 using MariaDB and PowerDNS-Admin

Next, you need to download the PowerDNS code. Change to /var/www/html and run the seeded command

wget http://downloads.sourceforge.net/project/poweradmin/poweradmin-2.1.7.tgz

Now unzip the archive file and rename it

tar xvf poweradmin-2.1.7.tgz
mv poweradmin-2.1.7/ cd /var/www/html/poweradmin/

Allow HTTP and HTTPS protocols through the firewall.

sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd –reload

At this point, we can continue with the online settings of PowerAdmin. Open the browser and enter http: ///poweradmin/install. You will see a page as shown below

Install PowerDNS on CentOS 8 using MariaDB and PowerDNS-Admin

Choose your preferred language and click Go to step 2 Then on the next page, click Go to step 3

You will see a page to configure the database. Here, use the details you used when creating the PowerDNS database.

Install PowerDNS on CentOS 8 using MariaDB and PowerDNS-Admin

The next step is to create users with limited permissions.

Install PowerDNS on CentOS 8 using MariaDB and PowerDNS-Admin

Please click Go to step 5 Here you will see the details of the added user. At this point, you will return to the terminal and grant naming permissions to the new user by running the following MySQL command.

GRANT SELECT, INSERT, UPDATE, DELETE  ON powerdns.* TO 'lorna'@'localhost' IDENTIFIED BY 'mypassword'

Now, go back to the web browser and click to go to step 6. You will see the following page telling you to manually create the file “../inc/config.inc.php”.

Install PowerDNS on CentOS 8 using MariaDB and PowerDNS-Admin

On the terminal, run the command shown:

cd /var/www/html/poweradmin
sudo vim inc/config.inc.php

And paste the content in the webpage and save the file.

Go back to the browser and click Go to step 7. You will see that the configuration is complete.

Install PowerDNS on CentOS 8 using MariaDB and PowerDNS-Admin

To support URLs used by other dynamic providers, run the following command:

cd /var/www/html/poweradmin
sudo cp install/htaccess.dist .htaccess

Note that you have to Removeinstallation"The list continues.

sudo rm -rf /var/www/html/poweradmin/install

Now go back to the browser and type http: ///poweradmin.

Install PowerDNS on CentOS 8 using MariaDB and PowerDNS-Admin

Log in with the user "admin" and the password you set for the admin user, then click go. You will see the page as shown.

Install PowerDNS on CentOS 8 using MariaDB and PowerDNS-Admin

Your installation is complete! Now you can continue to add a main area.

This is a step by step guide on how to install PowerDNS on CentOS 8 using MariaDB and PowerAdmin. Check out more fascinating guides below!

  • Configure master/slave BIND DNS server on CentOS 8 / RHEL 8
  • How to install and configure DNS server on Windows Server 2019
  • Bound vs dnsmasq vs PowerDNS vs unbound
  • Install PowerDNS and PowerDNS-Admin on Ubuntu 18.04/Debian 9 with MariaDB backend

Linux learning courses:


Linux Proficiency: Master the Linux command line in 11.5 hours

Linux Proficiency: Master the Linux command line in 11.5 hours

★★★★★
(8905)

$ 16.25

$ 174.11

In stock

Buy now

Install PowerDNS on CentOS 8 using MariaDB and PowerDNS-AdminUdemy.com


Linux Administration Bootcamp: from entry to advanced

Linux Administration Bootcamp: from entry to advanced

★★★★☆
(13333)

$ 13.93

$ 150.89

In stock

Buy now

Install PowerDNS on CentOS 8 using MariaDB and PowerDNS-AdminUdemy.com


Complete Linux training courses to help you realize your dream IT job in 2020

Complete Linux training courses to help you realize your dream IT job in 2020

★★★★★
(6607)

$ 15.09

$162.50

In stock

Buy now

Install PowerDNS on CentOS 8 using MariaDB and PowerDNS-AdminUdemy.com

You can download this article in PDF format via the link below to support us.

Download the guide in PDF format

turn off
To

To
To

Sidebar