Would you like to install PowerDNS on CentOS 7? Here’s how we do it.
Here at Bobcares, we have seen several such CentOS related installations as part of our Server Management Services for web hosts and online service providers.
Today we’ll take a look at how to install PowerDNS.
A few facts about PowerDNS
PowerDNS is an open-source DNS Server program that is written in C++. Also, it is one of the best alternatives for the traditional DNS server.
Generally, it provides two products, the Authoritative server, and the Recursor. We can configure the PowerDNS Authoritative server through different backend that includes the plain Bind zone files, RDBMS such as MySQL, PostgreSQL, SQLite3, or LDAP.
Today, we shall see how to install and configure a PowerDNS Authoritative server with the MariaDB database server as a Backend and using Poweradmin for easy DNS management.
How we install PowerDNS on CentOS 7
Now let’s take a look at how our Support Engineers install the PowerDNS.
1. Installing the EPEL and Remi Repositories
As a first step, we need to install the dependencies. So we will install the EPEL repository and the REMI for PHP 7.2 installation. For that, we run the below commands.
# yum -y install epel-release
# yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
After adding the above repositories, we install the ‘yum-utils’ package.
# yum -y install yum-utils
Then we enable the PHP 7.2 Remi repository using the below command.
# yum-config-manager –enable remi-php72
2. Installing and Configuring MariaDB
We run the below command to install MariaDB.
# yum -y install mariadb mariadb-server
Once the MariaDB installation completes, we start it and add it to the startup boot time.
# systemctl start mariadb
# systemctl enable mariadb
Now, we configure the root password for the MariaDB using the interactive tool called ‘mysql_secure_installation’. For that, we run the below command.
# mysql_secure_installation
Now, you will be prompted for configuring the root password. Type ‘Y’ to set up the root password and enter a strong password.
Set root password? [Y/n] Y New password: Re-enter new password:
By now, you have installed the MariaDB server and set up the root password for authentication.
Now, we will create a new database and user for the PowerDNS installation. For that, log into the MySQL shell with the user root and your password by running the below command.
# mysql -u root -p
PASSWORD
Next, create a new database called ‘powerdns’ and grant all the database privileges to a new user named ‘pdns’ with the password ‘Password123’.
create database powerdns;
grant all privileges on powerdns.* to pdns@localhost identified by ‘Password123’;
flush privileges;
Then, create the tables structures for the PowerDNS database by running following MySQL queries below.
use powerdns;
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;
Now, a MariaDB database and a user for PowerDNS installation have been created.
3. Install PowerDNS on CentOS 7
We run the below command to install the PowerDNS and all its packages by running the below command.
# yum -y install pdns pdns-backend-mysql bind-utils
Once the installation completes, we go to the ‘/etc/pdns/’ directory and edit the configuration file ‘pdns.conf’ using vim editor.
# cd /etc/pdns/
# vim pdns.conf
PowerDNS uses ‘bind’ as the backend by default. So, type comment ‘#’ in the front of ‘launch=bind’ configuration and paste the MySQL backend configuration as shown below.
#launch=bind
launch=gmysql
gmysql-host=localhost
gmysql-user=pdns
gmysql-password=pdnspassword2018
gmysql-dbname=powerdns
Now save and close it.
Then start the pdns service and add it to the startup boot time.
# systemctl start pdns
# systemctl enable pdns
After that, add the DNS service to the firewall.
# firewall-cmd –add-service=dns –permanent
# firewall-cmd –reload
Now, the PowerDNS service must be up and running well. You can check it by running.
# netstat -tap | grep pdns
# netstat -tulpn | grep 53
# dig @10.9.9.10
As a result, you must see the PowerDNS up and running on the port 53.
4. Install PowerAdmin
Now, we need to install a DNS management for PowerDNS called ‘Poweradmin’. Since it is a web application based on PHP, so we need to install PHP and web server in order to run the application.
For that, install an httpd web server and PHP packages using the following command.
# yum -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
Once the installation completes, we need to install the PHP Pear packages as well. So run the below command.
# yum -y install php-pear-DB php-pear-MDB2-Driver-mysqli
After the completion of httpd and PHP installation, start the httpd service and add it to the startup boot time.
# systemctl start httpd
# systemctl enable httpd
Then go to the ‘/var/www/html’ directory and download the poweradmin source code.
# cd /var/www/html/
# wget http://downloads.sourceforge.net/project/poweradmin/poweradmin-2.1.7.tgz
Now, extract the poweradmin compressed file and rename it.
# tar xvf poweradmin-2.1.7.tgz
# mv poweradmin-2.1.7/ poweradmin/
After that, add the HTTP and HTTPS protocols to the firewall.
# firewall-cmd –add-service={http,https} –permanent
# firewall-cmd –reload
5. Poweradmin Post-Installation
Now, open your web browser and type the server IP address along with the /poweradmin/install/ path URL for the installation.
Select the preferred language and ‘Go to Step 2’ button.
Now just click the ‘Go to Step 3’ button.
Now, a database configuration page is displayed. Enter the PowerDNS database details that was created earlier and the admin password for PowerDNS.
Click the ‘Go to Step 4’ button.
Then you would need to create a new user with limited privileges. Type the necessary details and change the user, password, etc with your own.
Now click the ‘Go to Step 5’ button.
Re-open your terminal server, log in with the root user and password. Then run the MySQL queries as on the page.
# mysql -u root -p
PASSWORD
GRANT SELECT, INSERT, UPDATE, DELETE
ON powerdns.*
TO ‘hakase’@’localhost’
IDENTIFIED BY ‘hakase-labs123’;
Now get back to the web browser and click the ‘Go to Step 6’ button.
If the installer was unable to create a new configuration ‘../inc/config.inc.php’. Then you need to create it manually.
So for that, go back to the terminal and go to ‘/var/www/html/poweradmin’ directory and create a new configuration file ‘inc/config.inc.php’.
# cd /var/www/html/poweradmin
# vim inc/config.inc.php
Then paste the below PHP script on the page.
<?php
$db_host = ‘localhost’;
$db_user = ‘hakase’;
$db_pass = ‘hakase-labs123’;
$db_name = ‘powerdns’;
$db_type = ‘mysql’;
$db_layer = ‘PDO’;
$session_key = ‘xTNxUiXIu320Z@N=uetwJeD2#uApgO)2Ekj+S#oN1Khhoj’;
$iface_lang = ‘en_EN’;
$dns_hostmaster = ‘server.hakase-labs.io’;
$dns_ns1 = ‘ns1.hakase-labs.io’;
$dns_ns2 = ‘ns2.hakase-labs.io’;
Now save and close the file. This completes the installation.
Now, go back to the web browser and log into the Poweradmin dashboard using the URL as below.
http://10.9.9.10/poweradmin/
Then log in using the default user ‘admin’ and the password. Then click on the ‘Go’ button.
As a result, Poweradmin dashboard is shown.
[Need any further assistance with CentOS queries? – We are here to help you.]
Conclusion
In today’s writeup, we saw a step-by-step procedure to install PowerDNS on CentOS 7.
0 Comments