Installing PowerDNS (With MySQL Backend) And Poweradmin On Debian Etch

Want to support HowtoForge? Become a subscriber!
 
Submitted by falko (Contact Author) (Forums) on Sun, 2009-01-18 18:38. :: Debian | PowerDNS | DNS

Installing PowerDNS (With MySQL Backend) And Poweradmin On Debian Etch

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 01/12/2009

This article shows how you can install the PowerDNS nameserver (with MySQL backend) and the Poweradmin control panel for PowerDNS on a Debian Etch system. PowerDNS is a high-performance, authoritative-only nameserver - in the setup described here it will read the DNS records from a MySQL database (similar to MyDNS), although other backends such as PostgreSQL are supported as well. Poweradmin is a web-based control panel for PowerDNS.

I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

In this example I'm using a Debian Etch host with the hostname server1.example.com and the IP address 192.168.0.100, set up according to the first 5 chapters of this tutorial: The Perfect Setup - Debian Etch (Debian 4.0).

I will set up just one PowerDNS server in this example (a master); adding PowerDNS slave(s) can easily be achieved by using MySQL database replication from the master to the slave(s), therefore no zone transfers are needed (this again is similar to MyDNS). MySQL database replication can be set up according to this tutorial: How To Set Up Database Replication In MySQL (PowerDNS also supports native zone transfers (for scenarios where you cannot use MySQL replication) - see http://downloads.powerdns.com/documentation/html/replication.html).

 

2 Installing MySQL

In order to install MySQL, we run

apt-get install mysql-server mysql-client

We want MySQL to listen on all interfaces (this is important for MySQL database replication!), not just localhost, therefore we edit /etc/mysql/my.cnf and comment out the line bind-address = 127.0.0.1:

vi /etc/mysql/my.cnf

[...]
#bind-address           = 127.0.0.1
[...]

Then we restart MySQL:

/etc/init.d/mysql restart

Now check that networking is enabled. Run

netstat -tap | grep mysql

The output should look like this:

server1:~# netstat -tap | grep mysql
tcp        0      0 *:mysql                 *:*                     LISTEN     3031/mysqld
server1:~#

Run

mysqladmin -u root password yourrootsqlpassword
mysqladmin -h server1.example.com -u root password yourrootsqlpassword

to set a password for the user root (otherwise anybody can access your MySQL database!) (replace yourrootsqlpassword with a password of your choice).

 

3 Installing PowerDNS

To install PowerDNS, we run

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

The PowerDNS configuration is located in the /etc/powerdns directory - I'll come to that in a moment.

Now we connect to MySQL:

mysql -u root -p

Type in your MySQL root password, and you should be on the MySQL shell. On the MySQL shell, we create a database for PowerDNS:

CREATE DATABASE powerdns;

Next we create a database user (powerdns) for PowerDNS:

GRANT ALL ON powerdns.* TO 'power_admin'@'localhost' IDENTIFIED BY 'power_admin_password';
GRANT ALL ON powerdns.* TO 'power_admin'@'localhost.localdomain' IDENTIFIED BY 'power_admin_password';
FLUSH PRIVILEGES;

(Replace power_admin_password with a password of your choice.)

Now we create the tables needed by PowerDNS...

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

CREATE UNIQUE INDEX name_index ON domains(name);

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 INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);

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

... and finally leave the MySQL shell:

quit;

Now we must configure PowerDNS so that it uses the MySQL backend:

vi /etc/powerdns/pdns.conf

Add the line launch=gmysql to pdns.conf:

[...]
#################################
# launch        Which backends to launch and order to query them in
#
# launch=
launch=gmysql
[...]

Then open /etc/powerdns/pdns.d/pdns.local and make it look as follows:

vi /etc/powerdns/pdns.d/pdns.local

# Here comes the local changes the user made, like configuration of
# the several backends that exists.

gmysql-host=127.0.0.1
gmysql-user=power_admin
gmysql-password=power_admin_password
gmysql-dbname=powerdns

Then restart pdns:

/etc/init.d/pdns restart

That's it, PowerDNS is now ready to be used. To learn more about it, please refer to its documentation: http://downloads.powerdns.com/documentation/html/index.html

 

4 Installing Poweradmin

Now let's install Poweradmin, a web-based control panel for PowerDNS. Poweradmin is written in PHP, so we must install a web server (I'm using Apache2 in this example) and PHP:

apt-get install apache2 libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php-pear php5-imap php5-mcrypt php5-mhash php5-ming php5-mysql php5-xmlrpc gettext

Continue installing libc-client without Maildir support? <-- Yes

Poweradmin also requires the following two PEAR packages:

pear install DB
pear install pear/MDB2#mysql

Now all prerequisites for Poweradmin are installed, and we can begin with the Poweradmin installation (I will install it in a subdirectory of /var/www - /var/www is the document root of Apache's default web site on Debian; if you've created a vhost with a different document root, please adjust the paths).

Go to https://www.poweradmin.org/trac/wiki/GettingPoweradmin and download the latest Poweradmin package, e.g. as follows:

cd /tmp
wget https://www.poweradmin.org/download/poweradmin-2.1.2.tgz

Then install it to the /var/www/poweradmin directory as follows:

tar xvfz poweradmin-2.1.2.tgz
mv poweradmin-2.1.2 /var/www/poweradmin
touch /var/www/poweradmin/inc/config.inc.php
chown -R www-data:www-data /var/www/poweradmin/

Now open a browser and launch the web-based Poweradmin installer (http://server1.example.com/poweradmin/install or http://192.168.0.100/poweradmin/install).

Select your language (English or Dutch):

Click on the Go to step 3 button to proceed:

Now fill in your database details. It is important that you fill in the details for the MySQL root user, not the powerdns MySQL user we created earlier! Also provide a password for the admin user for the Poweradmin web interface (that's the password that the user admin will use to log in to Poweradmin later on):

On the next page, fill in the details for the power_admin MySQL user that we created in chapter 3. Also fill in the two default nameservers that will be used in your zones unless you provide different nameservers when you create a zone (typically these are the names of the current system and of the slave server (for which you can set up MySQL replication, see my preliminary notes in chapter 1)):


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by pichunter (not registered) on Fri, 2014-01-31 19:50.
I wonder why I should install php5-dev?
Submitted by mbsouth (not registered) on Tue, 2009-09-01 21:51.

Thanks to falko for this tutorial!

First, PowerDNS looks good for me 2nd I realized that this product is outdated.
It´s not possible to set a TXT record for useing DKIM (DomainKeys Identified Mail DomainKeys Identified Mail ) [1].

mbsouth

[1] DKIM http://www.dkim.org/

Submitted by mbsouth (not registered) on Wed, 2009-09-02 13:05.

Sorry about the resent post!
I tried other possibilities and found out - powerDNS works perfect!
Exactly what I searched for!

Submitted by bvidinli (not registered) on Tue, 2009-02-24 09:22.
?