CentOS 7 PowerDNS installation guide

Although BIND is the most popular DNS-server in Linux, there are interesting alternatives such as PowerDNS. In our CentOS 7 PowerDNS installation guide we will provide all necessary instructions on how to install and configure PowerDNS and it’s web-front-end, Poweradmin.  PowerDNS shows high performance and is distributed under the GPL license. It is the only solution, that stores zones in different backends like MySQL, PostgreSQL, LDAP and others. In addition, the PowerDNS Authoritative Server is the leading DNSSEC implementation. There are many advantages in comparison with BIND, such as:Choice of backend – store zones where you like – MySQL, PostgreSQL or just BIND-like flat files

  • Choice of replication principles – replicate with traditional master-slave scheme, or replicate back-ends
  • Caching capabilities – Cache queries and packets
  • Supermaster – when new zone is added to the supermaster, the slave will create the zone on itself and request an AXFR. There is no such mechanism in BIND, for example

Next, we will install second service, Recursor, which is a high-end, high-performance resolving name server. It will be located on the same server as the authoritative DNS.

Enough reasons to try? For me – yes, and now – to the installation. Traditionally, I will use latest CentOS 7 minimal installation with firewalld and SElinux enabled for security reasons.

CentOS 7 PowerDNS installation guide – Step 1: PowerDNS with MySQL backend installation

1. First, add EPEL repository:

2. Next, proceed with MySQL(MariaDB) installation. In this step, we will install MariaDB, enable and start the service and make initial configuration through MySQL_secure_installation script

3. Backend is successfully installed – next, the PowerDNS and Recursor installation:

CentOS 7 PowerDNS installation guide – Step 2: Set up MariaDB backend

1. Create a database for PowerDNS, create a user for the database and grant him all privileges:

2. Next, set up the database created earlier –  create scheme for it. We will follow official instructions from PowerDNS site:

CentOS 7 PowerDNS installation guide – Step 3: Configure PowerDNS

1. Now all is ready for configuration.First, configure PowerDNS:

2. Insert the following part of config at the beginning of the file, and don’t forget to enter password for the database user created earlier:

3. Start and enable the service:

CentOS 7 PowerDNS installation guide – Step 4: Post-installation tasks

1. Create firewall rule to allow dns traffic and reload rules:

CentOS 7 PowerDNS installation guide – Step 5: Test how it works

We have finished configuring our PowerDNS server – let’s test how it works.

As you can see, server refused to answer – and this is correct, because it is not authoritative for this domain. Now let’s change config a little to get the answer. We will add a recursor entry in the config file and restart pdns:

We allowed the recursion and added the recursor IP-address. Let’s check again:

As you can see, everything works fine! But what if we want to use authoritative DNS server as well as use primary and secondary servers, or to create split-brain DNS scenario? And here another program product will help – the Recursor. In the next steps, we will install and configure the Recursor.

CentOS 7 PowerDNS installation guide – Step 6: Recursor – installation and configuration

1. Install the recursor:

2. Now change the default config. We will change default port – because the default port of recursor is 53 – and this port is already occupied with PowerDNS, so let’s chose 8090, for example. Next, we add a forwarding rule: it means – forward all queries for . domain to 8.8.8.8 (primary) or if it is not reachable – to 8.8.4.4. (secondary). After making changes, start pdns-recursor and enable the service:

3. Change the PowerDNS configuration as well and restart the service:

4. Finally, let’s check how it works:

As you can see, everything works fine through pdns-redirector.

But to manage zones and records effectively, we must add a web front-end to our installation. There are several different possibilities: Poweradmin, PowerDNS on Rails and JPower Admin. In this manual, I will choose Poweradmin because of support for most features of PowerDNS.

CentOS 7 PowerDNS installation guide – Step 7: PowerAdmin installation

1. We will use Apache as our web-server, so install all necessary php modules and Apache itself:

2. Start and enable httpd service, and configure firewall rules. Do not forget – we left SElinux enabled, so we must edit the Boolean for httpd:

3. Download the package and extract files in /var/www/html:

4. Start web-based installation by opening http://%your-ip-address%/poweradmin-2.1.7/install/ and Go to Step 2

CentOS 7 PowerDNS installation guide Step 1

5. Strange step, but – just proceed to Step 3

CentOS 7 PowerDNS installation guide Step 2

6. Provide credentials we created earlier – Username and psssword – for connection to MariaDB, database name – that we created earlier, and a password for administrative account:

CentOS 7 PowerDNS installation guide Step 3

7. Provide credentials for limited user, Hostmaster and NS records, and proceed to step 5:

CentOS 7 PowerDNS installation guide Step 4

8. Now we need to create that limited user from the previous step and grant him needed privileges. Back to console, enter MariaDB prompt and insert the code provided by web-installer:

CentOS 7 PowerDNS installation guide Step 5

9. The installer will attempt to create its configuration file in /var/www/html/poweradmin-2.1.7/inc. If the script couldn’t make these changes, we will have to make them manually. Create a file, then paste the strings provided by web-installer, and then save-exit :

CentOS 7 PowerDNS installation guide Step 6

10. Now the final step – remove install folder. You will see a warning message, if you will try to access web-interface without deletion of that folder, but my advice – check the availability of http://%your-IP-address%/poweradmin-2.1.7/ – and only after seeing this warning proceed with the deletion:

CentOS 7 PowerDNS installation guide Step 7

CentOS 7 PowerDNS installation guide: Final thoughts

So, for now, you have configured PowerDNS with PowerAdmin web-interface and Recursor on the single host. Everything went fine? Good. But there are some errors you can face, and this is how you can deal with them:

1. After finishing web-installer, you see an empty page or an 500 error. Solution: check the file and folder permissions. Try to move the contents of /var/www/html/poweradmin-2.1.7 to the root of web-server.

2. After finishing web-installer, you see – Unable to connect to database. You check all the passwords – and they are correct. Solution: Try to avoid special characters li, and consider changing the password