Content

How to setup PowerDNS

 

PowerDNS is a high-performance DNS server alternative to BIND written in C++ . In this tutorial, we will show you how to install it in Ubuntu 14

1. Prerequisites

Since we will install  Poweradmin which is PHP/MySQL based front end tool for managing Power-DNS, therefor you must have LAMP/LEMP server installed in your server.

Install LAMP
The easiest way to install LAMP stack in Ubuntu is through tasksel or by using apt-get install lamp-server. Run tasksel from terminal and select LAMP server by pressing space-bar and then select “OK”. Provide mysql root password in the installation process.

# sudo apt-get install lamp-server
      OR
# sudo tasksel
and then select LAMP server

2. Create database and user for PowerDNS DNS Server

Unlikes BIND, Power-DNS stores the DNS records in a database server instead of writing directly to files. We will have to install a database for it. It supports MySQL/MariaDB, Postgres, Oracle as Database back-end. Create the database and  a new user called “powerdns” and grant access to the database.

 mysql > CREATE DATABASE powerdns;
mysql > CREATE USER 'powerdns@'localhost' IDENTIFIED by 'somepasword';
mysql > GRANT ALL ON powerdns.* TO 'powerdns'@'localhost';
mysql > FLUSH PRIVILEGES;
mysql > exit;

Create MySQL user

Create SQL file with following content. Save this file as schema.sql in /root directory

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) );

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) );

CREATE INDEX rec_name_index ON records(name);

CREATE TABLE supermasters (
ip VARCHAR(25) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) DEFAULT NULL
);

Now import the above SQL file into the database

mysql > use powerdns;
mysql > source /root/schema.sql;

Import schema into MySQL database

Change the location of schema.sql in the above command if you saved it in a different location.

3. Install PowerDNS DNS Server

Execute the following command to install it in your system.

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

Install powerDNS

In the process of installing it, it will ask you to configure MySQL. Select ‘No’

Configure pdns backend

The installation is now complete.

4. Configure PowerDNS DNS Server

First remove all configuration file from /etc/powerdns/pdns.d

# rm -rf /etc/powerdns/pdns.d

Now edit the file /etc/powerdns/pdns.conf and add the following in launch section.

 launch=gmysql
gmysql-host=localhost
gmysql-user=powerdns
gmysql-password=somepassword
gmysql-dbname=powerdns

PowerDNS mysql configuration

We are changing the local-port from 53 to 50 as, in our system dnsmasq is running in port no 53. If you don’t change this port and want to run dnsmasq also then, you will get the following error.

binding UDP socket to ‘0.0.0.0’ port 53: Address already in use
Fatal error: Unable to bind to UDP socket

Also edit /etc/default/pdns and change the value of RESOLVCONF_UPDATE_FORWARDERS to yes.

Update pdns configuration file

Keeping the value of the RESOLVCONF_UPDATE_FORWARDERS to no will result in following error if you want to start/restart dnsmasq and hence it will not work.

“Not updating PowerDNS, disabled in /etc/default/pdns.”

Powerdns setting in /etc/default/pdns

Now start Power-DNS and dnsmasq ( if you are using it )

# service pdns restart
# service dnsmasq restart

Restart pdns and dnsmasq

Check if Power-DNS is listening

# netstat -tap | grep pdns

Check PDNS status

Check if Power-DNS responds correctly

# dig @127.0.0.1

Check PDNS server

5. Install Poweradmin

Poweradmin is a PHP based DNS administration tool for Power-DNS. It has full support for all zone types  namely master, native and slave. Clone poweradmin from their site. Move the file poweradmin/inc/config-me.inc.php to config.inc.php.

# cd /usr/src
# git clone git://github.com/poweradmin/poweradmin.git
# cd poweradmin/inc
# mv config-me.inc.php config.inc.php

Clone PowerDNS

Now, edit  config.inc.php in database section and add the following DB parameter values.

$db_host = 'localhost';
$db_port = '3306';
$db_user = 'powerdns';
$db_pass = 'somepassword';
$db_type = 'mysql';

Power admin setting

Next move poweradmin to the default web root and change the ownership.

# cd /usr/src
# mv poweradmin /var/www/html
# chown -R apache:apache /var/www/html/poweradmin

Restart apache

# service apache2 restart

Next point your favorite web browser to http://demohost.com/poweradmin You will be welcome by installation step1.

Step1 install poweradmin

Click ‘Goto Step 2’

Step2 install poweradmin

Now enter database details and click ‘Goto Step 3’.

Step 3 Enter database details

Create PowerAdmin user and set Admin password click ‘Goto Step 4’.

Enter hostmaster and nameserver details

PowerAdmin will display a bit of SQL that you  need to execute in the command line mysql client. Once done then click Go to Step 5.

Step5 Copy MySQL statements

Power DNS will now present you with your php configuration file. Since your web server does not have permissions to create the file itself (this is a good thing) you need to manually create it.

Step6 copy PHP code

# cd /var/www/html/poweradmin/inc
# nano config.inc.php

Now paste the configuration into this file and save and exit. And click Goto Step 7 in the installer.

Installation of poweradmin complete

Remove the installation directory and log in to poweradmin

# cd /var/www/html/poweradmin/
# rm -rf install

Poweradmin login form

Add a zone

Add a zone in Poweradmin

Zone has been added successfully.

Zone added successfully

 

Thats all there to setting up PowerDNS and PowerAdmin.

Was this article helpful to you?

DD2016

Comments are closed.