PowerDNS is a DNS server running on many Linux/Unix derivatives. It can be configured with different backends including BIND style zone files, relational databases or load balancing/failover algorithms. It can also be setup as a DNS recursor running as a separate process on the server.
The latest version of PowerDNS Authoritative server is 3.4.4, but the one available in the EPEL repository right now is 3.4.3. I would recommend installing the one for the EPEL repository due to the fact that this version is tested in CentOS and Fedora. That way you will also be able to easily update PowerDNS in future.
This article intends to show you how to install and setup master PowerDNS server with a MariaDB backend and the PowerAdmin – a friendly web interface managing tool for PowerDNS.
For the purpose of this article I will be using server with:
Hostname: centos7.localhost IP Address 192.168.0.102
Step 1: Installing PowerDNS with MariaDB Backend
1. First you need to enable the EPEL repository for your server simply use:
# yum install epel-release.noarch
2. The next step is to install the MariaDB server. This can be easily done by running the following command:
# yum -y install mariadb-server mariadb
3. Next we will configure MySQL to enable and start upon system boot:
# systemctl enable mariadb.service # systemctl start mariadb.service
4. Now that the MySQL service is running, we will secure and setup a password for MariaDB by running:
/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): 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 authorisation. Set root password? [Y/n] y New password: ← Set New Password Re-enter new password: ← Repeat Above 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 ← Choose “y” to disable that user ... 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 ← Choose “n” for no ... 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 ← Choose “y” for yes - 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 ← Choose “y” for yes ... 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!
5. Once MariaDB configuration done successfully, we can proceed further with the installation of PowerDNS. This is easily completed by running:
# yum -y install pdns pdns-backend-mysql
6. The configuration file for PowerDNS is located in
/etc/pdns/pdns, but before editing it, we will setup a MySQL database for PowerDNS service. First we will connect to the MySQL server and will create a database with name powerdns:
# mysql -u root -p MariaDB [(none)]> CREATE DATABASE powerdns;
7. Next, we will create a database user called powerdns:
MariaDB [(none)]> GRANT ALL ON powerdns.* TO 'powerdns'@'localhost' IDENTIFIED BY 'tecmint123'; MariaDB [(none)]> GRANT ALL ON powerdns.* TO 'powerdns'@'centos7.localdomain' IDENTIFIED BY 'tecmint123'; MariaDB [(none)]> FLUSH PRIVILEGES;
Note: Replace “tecmint123” with the actual password that you want to use for your setup.
8. We proceed by creating the database tables used by PowerDNS. Execute those block by block:
MariaDB [(none)]> USE powerdns; MariaDB [(none)]> 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) );
MariaDB [(none)]> CREATE UNIQUE INDEX name_index ON domains(name); MariaDB [(none)]> 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) );
MariaDB [(none)]> CREATE INDEX rec_name_index ON records(name); MariaDB [(none)]> CREATE INDEX nametype_index ON records(name,type); MariaDB [(none)]> CREATE INDEX domain_id ON records(domain_id);
MariaDB [(none)]> CREATE TABLE supermasters ( ip VARCHAR(25) NOT NULL, nameserver VARCHAR(255) NOT NULL, account VARCHAR(40) DEFAULT NULL );
You can now exit the MySQL console by typing:
MariaDB [(none)]> quit;
9. Finally we can proceed with configuring our PowerDNS in a way that, it will use MySQL as backend. For that purpose open PowerDNS configuration file located at:
# vim /etc/pdns/pdns.conf
In that file look for the lines looking like this:
################################# # launch Which backends to launch and order to query them in # # launch=
Just after that put the following code:
launch=gmysql gmysql-host=localhost gmysql-user=powerdns gmysql-password=user-pass gmysql-dbname=powerdns
Change “user-pass” with the actual password that you set earlier. Here is how my configuration looks like:
Save your change and exit from.
10. Now we will start and add PowerDNS to the list of services starting at system boot:
# systemctl enable pdns.service # systemctl start pdns.service
At this point your PowerDNS server is up and running. For more information about PowerDNS you can refer to the manual available at http://downloads.powerdns.com/documentation/html/index.html