How to Install and Configure ‘PowerDNS’ (with MariaDB) and ‘PowerAdmin’ in RHEL/CentOS 7

To Install and Configure ‘ PowerDNS’ (with MariaDB) and ‘ PowerAdmin’ in RHEL/CentOS 7

PowerDNS is a DNS available for many Linux/Unix derivatives. It is configured with different backends like relational databases, BIND data-style zone files or load balancing/failover algorithms. Installation and configuration of PowerDNS and PowerAdmin is explained in this article.

To installing PowerDNS with MariaDB Backend

Enable the EPEL repository

[root@linuxhelp1 ~]# yum install epel-release -y
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
* base: centos.webwerks.com
* extras: centos.webwerks.com
* updates: centosx4.centos.org
Resolving Dependencies
-->  Running transaction check
--->  Package epel-release.noarch 0:7-6 will be installed
.
.
.
Installed:
epel-release.noarch 0:7-6

Complete!

Install mariadb and mariadb-server

[root@linuxhelp1 ~]# yum install mariadb mariadb-server -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.webwerks.com
* epel: mirror01.idc.hinet.net
* extras: centos.webwerks.com
* updates: centosx4.centos.org
Resolving Dependencies
-->  Running transaction check
--->  Package mariadb.x86_64 1:5.5.47-1.el7_2 will be installed
-->  Processing Dependency: mariadb-libs(x86-64) = 1:5.5.47-1.el7_2 for package: 1:mariadb-5.5.47-1.el7_2.x86_64
--->  Package mariadb-server.x86_64 1:5.5.47-1.el7_2 will be installed
.
.
.
Dependency Installed:
perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
perl-DBD-MySQL.x86_64 0:4.023-5.el7 perl-DBI.x86_64 0:1.627-4.el7
perl-Data-Dumper.x86_64 0:2.145-3.el7 perl-IO-Compress.noarch 0:2.061-2.el7
perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7

Dependency Updated:
mariadb-libs.x86_64 1:5.5.47-1.el7_2

Complete!

Start and enable mysql service

[root@linuxhelp1 ~]# systemctl enable mariadb.service
ln -s ' /usr/lib/systemd/system/mariadb.service'  ' /etc/systemd/system/multi-user.target.wants/mariadb.service' 
[root@linuxhelp1 ~]# systemctl start mariadb.service

Setup a password for MariaDB by running the following command.

[root@linuxhelp1 ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

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):
OK, successfully used password, moving on...

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

Set root password? [Y/n] y
New password:
Re-enter 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] n
... skipping.

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
installation should now be secure.

Thanks for using MariaDB!


After configuring MariaDB, install the PowerDNS

[root@linuxhelp1 ~]# yum install pdns pdns-backend-mysql -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.webwerks.com
* epel: epel.mirror.net.in
* extras: centos.webwerks.com
* updates: centosx4.centos.org
Resolving Dependencies
-->  Running transaction check
--->  Package pdns.x86_64 0:3.4.8-1.el7 will be installed
-->  Processing Dependency: liblmdb.so.0.0.0()(64bit) for package: pdns-3.4.8-1.el7.x86_64
.
.
.
Installed:
pdns.x86_64 0:3.4.8-1.el7 pdns-backend-mysql.x86_64 0:3.4.8-1.el7

Dependency Installed:
boost-program-options.x86_64 0:1.53.0-25.el7 boost-serialization.x86_64 0:1.53.0-25.el7 cryptopp.x86_64 0:5.6.2-9.el7
lmdb-libs.x86_64 0:0.9.18-1.el7

Complete!

Connect to the MySQL server and create a database with the name powerdns

[root@linuxhelp1 ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with   or g.
Your MariaDB connection id is 9
Server version: 5.5.47-MariaDB MariaDB Server

Copyright (c) 2000, 2015, 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.01 sec)

Create a database user called powerdns

MariaDB [(none)]>  GRANT ALL ON powerdns.* TO ' powerdns' @' localhost'  IDENTIFIED BY ' linuxc'  
Query OK, 0 rows affected (0.15 sec)

MariaDB [(none)]>  GRANT ALL ON powerdns.* TO ' powerdns' @' linuxhelp1'  IDENTIFIED BY ' linuxc'  
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]>  FLUSH PRIVILEGES 
Query OK, 0 rows affected (0.04 sec)

Then create a tables inside powerdns database.

MariaDB [(none)]>  use powerdns 
Database changed
MariaDB [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)) 
Query OK, 0 rows affected (0.08 sec)

MariaDB [powerdns]>  CREATE UNIQUE INDEX name_index ON domains(name) 
Query OK, 0 rows affected (0.15 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [powerdns]>  CREATE TABLE records (id INT auto_increment,domain_id INT DEFAULT NULL,name VARCHAR(255) DEFAULT NULL,type VARCHAR(6) DEFAULT NULL,content VARCHAR(255) DEFAULT NULL,ttl INT DEFAULT NULL,prio INT DEFAULT NULL,change_date INT DEFAULT NULL,primary key(id)) 
Query OK, 0 rows affected (0.00 sec)

MariaDB [powerdns]>  CREATE INDEX rec_name_index ON records(name) 
Query OK, 0 rows affected (0.09 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [powerdns]>  CREATE INDEX nametype_index ON records(name,type) 
Query OK, 0 rows affected (0.18 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [powerdns]>  CREATE INDEX domain_id ON records(domain_id) 
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [powerdns]>  CREATE TABLE supermasters ( ip varchar(25) NOT NULL, nameserver VARCHAR(255) NOT NULL, account VARCHAR(40) DEFAULT NULL) 
Query OK, 0 rows affected (0.00 sec)

MariaDB [powerdns]>  quit 
Bye

Open the powerdns configuration file.

[root@linuxhelp1 ~]# vim /etc/pdns/pdns.conf

Add the following lines into it.

Enable launch=gmysql

gmysql-host=localhost
gmysql-user=powerdns
gmysql-password=linuxc
gmysql-dbname=powerdns

Start and enable the pdns.service

[root@linuxhelp1 ~]# systemctl start pdns.service
[root@linuxhelp1 ~]# systemctl enable pdns.service
ln -s ' /usr/lib/systemd/system/pdns.service'  ' /etc/systemd/system/multi-user.target.wants/pdns.service' 

Install the dependency packages before installing Power admin.

[root@linuxhelp1 ~]# yum 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 -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.webwerks.com
* epel: mirror01.idc.hinet.net
* extras: centos.webwerks.com
* updates: centosx4.centos.org
Package gettext-0.18.2.1-4.el7.x86_64 already installed and latest version
Resolving Dependencies
-->  Running transaction check
--->  Package httpd.x86_64 0:2.4.6-40.el7.centos.1 will be installed
.
.
.
Dependency Installed:
apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7
autoconf.noarch 0:2.69-11.el7 automake.noarch 0:1.13.4-3.el7
httpd-tools.x86_64 0:2.4.6-40.el7.centos.1 libc-client.x86_64 0:2007f-4.el7.1
libmcrypt.x86_64 0:2.5.8-13.el7 libzip.x86_64 0:0.10.1-8.el7
m4.x86_64 0:1.4.16-10.el7 mailcap.noarch 0:2.1.41-2.el7
pcre-devel.x86_64 0:8.32-15.el7_2.1 perl-Test-Harness.noarch 0:3.28-3.el7
perl-Thread-Queue.noarch 0:3.02-2.el7 php-cli.x86_64 0:5.4.16-36.1.el7_2.1
php-pdo.x86_64 0:5.4.16-36.1.el7_2.1 php-process.x86_64 0:5.4.16-36.1.el7_2.1
t1lib.x86_64 0:5.1.2-14.el7 unixODBC.x86_64 0:2.3.1-11.el7

Dependency Updated:
pcre.x86_64 0:8.32-15.el7_2.1

Complete!

Install the pear packages for poweradmin

[root@linuxhelp1 ~]# yum install php-pear-DB php-pear-MDB2-Driver-mysql -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.webwerks.com
* epel: mirror01.idc.hinet.net
* extras: centos.webwerks.com
* updates: centosx4.centos.org
Package php-pear-DB-1.7.14-6.el7.noarch already installed and latest version
Resolving Dependencies
-->  Running transaction check
--->  Package php-pear-MDB2-Driver-mysql.noarch 0:1.5.0-0.8.b4.el7 will be installed
.
.
.
Installed:
php-pear-MDB2-Driver-mysql.noarch 0:1.5.0-0.8.b4.el7

Dependency Installed:
php-pear-MDB2.noarch 0:2.5.0-0.9.b5.el7

Complete!

Start and enable the apache services

[root@linuxhelp1 ~]# systemctl start httpd.service
[root@linuxhelp1 ~]# systemctl enable httpd.service
ln -s ' /usr/lib/systemd/system/httpd.service'  ' /etc/systemd/system/multi-user.target.wants/httpd.service' 

Now download the Poweradmin package from the location /var/www/html/

[root@linuxhelp1 ~]# cd /var/www/html/
[root@linuxhelp1 html]# wget http://downloads.sourceforge.net/project/poweradmin/poweradmin-2.1.7.tgz
--2016-06-22 05:11:06-- http://jaist.dl.sourceforge.net/project/poweradmin/poweradmin-2.1.7.tgz
Resolving jaist.dl.sourceforge.net (jaist.dl.sourceforge.net)... 150.65.7.130, 2001:df0:2ed:feed::feed
Connecting to jaist.dl.sourceforge.net (jaist.dl.sourceforge.net)|150.65.7.130|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 296469 (290K) [application/octet-stream]
Saving to: ‘ poweradmin-2.1.7.tgz’ 

100%[==============================================================================> ] 2,96,469 381KB/s in 0.8s

2016-06-22 05:11:07 (381 KB/s) - ‘ poweradmin-2.1.7.tgz’  saved [296469/296469]
[root@linuxhelp1 html]# tar xvf poweradmin-2.1.7.tgz
poweradmin-2.1.7/
poweradmin-2.1.7/.gitignore
poweradmin-2.1.7/LICENSE
poweradmin-2.1.7/README.md
.
.
.
poweradmin-2.1.7/data-style/
poweradmin-2.1.7/data-style/example.css
poweradmin-2.1.7/users.php

Open the browser and enter http://192.168.7.235/poweradmin-2.1.7/install/, Choose the language for your Poweradmin and click " Go to step 2" button.

Click " Go to step 3 " to proceed further.

Enter the database credentials as setup earlier and click " Go to step 4" .

Create a new user with a limited rights for Poweradmin.

Now you have to set limited power to admin by executing the code provided by Poweradmin in the terminal.

[root@linuxhelp1 html]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with   or g.
Your MariaDB connection id is 12
Server version: 5.5.47-MariaDB MariaDB Server

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

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

MariaDB [(none)]>  GRANT SELECT, INSERT, UPDATE, DELETE ON powerdns.* TO ' powermain' @' localhost'  IDENTIFIED BY ' linuxc'  
Query OK, 0 rows affected (0.03 sec)

MariaDB [(none)]>  quit 
Bye

Then navigate to the browser and click on " Go to step 6" . Open the terminal and rename the config file as " ./inc/config.inc.php" and add the following lines as follows. Finally click " Go to step 7"

[root@linuxhelp1 html]# cd poweradmin-2.1.7/inc/
[root@linuxhelp1 inc]# ls
auth.inc.php database.inc.php file.inc.php i18n.inc.php record.inc.php version.inc.php
benchmark.php dns.inc.php footer.inc.php migrations.inc.php templates.inc.php
config-me.inc.php dnssec.inc.php header.inc.php PDOCommon.class.php toolkit.inc.php
countrycodes.inc.php error.inc.php helper.js PDOLayer.php users.inc.php
[root@linuxhelp1 inc]# mv config-me.inc.php config.inc.php
[root@linuxhelp1 inc]# vim config.inc.php
$db_host = ' localhost'  
$db_port = ' '  
$db_user = ' powermain'  
$db_pass = ' linuxc'  
$db_name = ' powerdns'  
$db_type = ' mysql'  
$session_key = ' 2Y~R{^Wo!zHh%N%Lxk)qX3^%hphVSb9^Q]7m-@J8FJba-('  
$dns_hostmaster = ' linuxhelp1'  
$dns_ns1 = ' ns1.localhost.com'  
$dns_ns2 = ' ns2.localhost.com'  

Now we have configured the Poweradmin

Run the following command to support the URL' s used by the other dynamic DNS provider.

[root@linuxhelp1 poweradmin-2.1.7]# cp install/htaccess.dist .htaccess

Then enable mod_rewrite in Apache’ s configuration.

Remove the " install" folder from Poweradmin’ s root directory.

[root@linuxhelp1 poweradmin-2.1.7]# rm -rf /var/www/html/poweradmin-2.1.7/install/

Now open the browser and type http://192.168.7.235/poweradmin-2.1.7/ to access poweradmin.


To add new master zone, simply click on the “ Add master zone” :

Click “ Add zone” button to add the DNS zone.

Choose " List zones" to list the available zones.

To edit or add new records, click the edit icon.

On the next page you will see the entries for the DNS zone.

Add new DNS zone and set the following information.

Finally click “ Add record ” button.

To delete a DNS zone, go back to the “ List zone” page and click on the “ Trash” icon.

Click " Yes" to delete zone.

Tag : Poweradmin
Comment
elhem
May 26 2022
hello i have a problem pdns.service failed who can help me
Add a comment
FAQ
Q
Where is the location of Open the powerdns configuration file.
A
Following is location of powerdns configuration file

vim /etc/pdns/pdns.conf
Q
What is the command to install the PowerDNS ?
A
the command to install the PowerDNS is

yum install pdns pdns-backend-mysql -y
Q
How to Start and enable mysql service ?
A
Start and enable MySQL service using the following commands

systemctl enable mariadb.service
Q
How to Enable the EPEL repository on centos 7 ?
A
To enable the EPEL repository on centos 7 use the following command

yum install epel-release -y
Q
Can I upgrade Powerdns to a newer version – or is that a bad idea ?
A
We recommend to the use of the "cpanel-pdns" RPM that's automatically installed when you choose PowerDNS as your name server.