Bobcares

For every $500 you spend, we will provide you with a $500 credit on your account*

BLACK FRIDAY SPECIAL EXTENSION

*The maximum is $4000 in credits, Offer valid till December 6th, 2024, New Customers Only, Credit will be applied after purchase and expires after six (6) months

For every $500 you spend, we will provide you with a $500 credit on your account*

BLACK FRIDAY SPECIAL EXTENSION

*The maximum is $4000 in credits, Offer valid till December 6th, 2024, New Customers Only, Credit will be applied after purchase and expires after six (6) months

Install PowerDNS with PDNS Manager

by | Nov 11, 2021

Wondering how to install PowerDNS with PDNS Manager? We can help you.

As part of our Server Management Services, we assist our customers with several PDNS queries.

Today let us see how we can perform the installation as an authoritative nameserver on a Debian-based system.

 

Install PowerDNS with PDNS Manager

In order to begin our Support Techs recommend the following steps.

  • Install Apache

We use PHP in version 7.4 or above, and enable the PHP apcu and json extension.

apt update;
apt install php7.4-json php7.4-apcu -y;

In addition, we need to install and enable PHP MySQL native driver

  • Install PDNS Manager

Prior to the installation, we need to go to Download and get the latest stable version.

Then we need to unpack the archive and put the content in a folder on the system.

After that, we configure an Apache VHost with a config like the following:

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName ns20.bob.com
DocumentRoot /var/www/html/frontend
RewriteEngine On
RewriteRule ^index\.html$ - [L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule !^/api/\.* /index.html [L]
Alias /api /var/www/html/backend/public
<Directory /var/www/html/backend/public>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
</Directory>
</VirtualHost>

Here, we assume that the hostname is “https://pdns.example.com”.

To start the installation, we open a browser and navigate to “https://pdns.example.com/setup”.

Now, we have to supply the database credentials.

Once we complete all necessary steps, we press Setup. After the installation, it will redirect to the login page.

  • Install PowerDNS

Initially, we setup the repo as below:

vim /etc/apt/sources.list.d/pdns.list

deb [arch=amd64] http://repo.powerdns.com/ubuntu focal-auth-45 main

vim /etc/apt/preferences.d/pdns

Package: pdns-*
Pin: origin repo.powerdns.com
Pin-Priority: 600

Then we run the following commands:

curl https://repo.powerdns.com/FD380FBB-pub.asc | sudo apt-key add -
apt-get update
apt-get install pdns-server

Eventually, we enable and start the service:

systemctl enable pdns.service;
systemctl restart pdns.service;
systemctl status pdns.service;
  • Install and Configure MariaDB Server

By default, it is not available in the Ubuntu 20.04 default repository. So we need to add the MariaDB repository to the system.

Initially, we install the necessary packages:

apt-get install software-properties-common gnupg2 -y

Once done, we add the MariaDB signing key:

apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'

Next, we go ahead and add the MariaDB repository:

add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://mirrors.ukfast.co.uk/sites/mariadb/repo/10.5/ubuntu focal main'

After that, we install the MariaDB server:

apt-get install mariadb-server -y

Later we run the following command and finish it:

mysql_secure_installation

An example is given below:

root@pdns1:~# mysql_secure_installation
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
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] n
... skipping.
You already have your root account protected, so you can safely answer 'n'.
Change the 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 acces

Now, we need to setup /root/.my.cnf:

vi /root/.my.cnf

[client]
user=root
password=password_here

chmod 400 /root/.my.cnf;

And we need to create a database and user for PowerDNS.

To do so, we log in to MariaDB:

login

Then we create a database and user:

create database pdns;
grant all on pdns.* to pdnsadmin@localhost identified by 'password_here';
flush privileges;
exit;
  • Install PDNS

To install, we run the following command:

apt-get install pdns-server pdns-backend-mysql

Once done, we open /etc/powerdns/pdns.conf with an editor and enter the following:

allow-axfr-ips=127.0.0.1 <ip of your secondary nameserver>
config-dir=/etc/powerdns
daemon=yes
disable-axfr=no
guardian=yes
local-address=0.0.0.0
local-port=53
master=yes
slave=yes
module-dir=/usr/lib/x86_64-linux-gnu/pdns
setgid=pdns
setuid=pdns
#socket-dir=/var/run
version-string=powerdns
include-dir=/etc/powerdns/pdns.d

Now we have to supply the configuration for the MySQL backend.

To do so, we open /etc/powerdns/pdns.d/pdns.local.gmysql.conf with an editor and configure it as follows:

launch=gmysql
gmysql-host=localhost
gmysql-port=3306
gmysql-dbname=pdns
gmysql-user=pdns
gmysql-password=pdns
gmysql-dnssec=no

We need to replace the parameters according to our setup.

Then we go ahead and remove the bind-config:

cp -pvr /etc/pdns.d /etc/pdns.d-backup-21;
rm -vf /etc/pdns.d/bind.conf;

Eventually, we can restart PowerDNS and it will be up and running.

systemctl enable pdns;
systemctl restart pdns;

Now, we will configure master config: /etc/powerdns/pdns.conf as below:

launch=
allow-axfr-ips=127.0.0.1 135.181.95.52
config-dir=/etc/powerdns
daemon=yes
disable-axfr=no
guardian=yes
local-address=0.0.0.0
local-port=53
master=yes
slave=yes
module-dir=/usr/lib/x86_64-linux-gnu/pdns
setgid=pdns
setuid=pdns
#socket-dir=/var/run
version-string=powerdns
api=yes
api-key=key_here
log-dns-queries=yes
log-timestamp=yes
loglevel=5
master=yes
primary=yes
query-logging=yes
include-dir=/etc/powerdns/pdns.d

And then configure slave config: /etc/powerdns/pdns.conf as below:

launch=
allow-axfr-ips=127.0.0.1
config-dir=/etc/powerdns
daemon=yes
disable-axfr=no
guardian=yes
local-address=0.0.0.0
local-port=53
module-dir=/usr/lib/x86_64-linux-gnu/pdns
setgid=pdns
setuid=pdns
#socket-dir=/var/run
version-string=powerdns
api=yes
api-key=key_here
log-dns-queries=yes
log-timestamp=yes
query-logging=yes
slave=yes
slave-cycle-interval=60
superslave=yes
include-dir=/etc/powerdns/pdns.d

Once we perform this change, we restart the service:

systemctl restart pdns;

Then we update the database in slave as below:

use pdns;
insert into pdns.supermasters values ('master_ip', 'slave_hostname', 'admin');

An example is as follows:

MariaDB [(none)]> use pdns;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [pdns]>
MariaDB [pdns]>
MariaDB [pdns]> select * from supermasters;
Empty set (0.000 sec)
MariaDB [pdns]> insert into pdns.supermasters values ('83.222.142.60', 'ns21.maxihoster.com', 'admin');
Query OK, 1 row affected (0.001 sec)
MariaDB [pdns]> select * from supermasters;
+---------------+---------------------+---------+
| ip | nameserver | account |
+---------------+---------------------+---------+
| 83.222.142.60 | ns21.maxihoster.com | admin |
+---------------+---------------------+---------+
1 row in set (0.000 sec)

Finally, after the config change, we restart service:

systemctl restart pdns;

[Stuck in between? We’d be glad to assist you]

 

Conclusion

In short, we saw how our Support Techs perform the installation of PowerDNS with the PDNS Manager.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.