HOWTO install PowerDNS on CentOS

R

Rob

Guest
PowerDNS Authoritative Server is a great choice for handling DNS for your organization. For a successful install (and for this howto in particular) you'll need a Linux server running CentOS. This HOWTO will show you how to get a working pdns nameserver going along with a great web front-end.

The most common way to set up PowerDNS (pdns) on multiple servers (ns1, ns2, etc...) is to enable MySQL replication from the master (ns1) and the slave(s) (ns2, ns3). That's going to be part 2 of this HOWTO. Let's just get pdns set up on our master and answering queries for now...

First, let's make sure mysql is installed:
[xcode=bash]
yum install mysql mysql-server -y[/xcode]

Let's edit the /etc/my.cnf file and make sure that skip-networking is commented out
[xcode=bash]
#skip-networking
[/xcode]

Now make sure it starts when booting into levels 2, 3, 5 and we can start it up
[xcode=bash]
chkconfig --levels 235 mysqld on
service mysqld start
[/xcode]

Check via netstat that mysql is listening on all interfaces:
[xcode=bash]
netstat -tap |grep "*:mysql"
tcp 0 0 *:mysql *:* LISTEN 20319/mysqld
[/xcode]

Set the mysql root password (without it showing up in your bash history!)
[xcode=bash]
/usr/bin/mysql_secure_installation
(follow the prompts/questions)[/xcode]

Now we're ready to install powerdns:
[xcode=bash]
yum install pdns pdns-backend-mysql
[/xcode]

Connect to mysql, create the database, set the permissions, add some tables for pdns:
(make sure to replace 'pdns_admin_pass' with something else!)
[xcode=bash]
mysql -u root -p
CREATE DATABASE powerdns;
[/xcode]
Modify the following two lines with your own password
[xcode=bash]
GRANT ALL ON powerdns.* TO 'pdns_admin'@'localhost' IDENTIFIED BY 'pdns_admin_pass';
GRANT ALL ON powerdns.* TO 'pdns_admin'@'localhost.localdomain' IDENTIFIED BY 'pdns_admin_pass';
[/xcode]
Feel free to paste the rest of this in all at once
[xcode=bash]
FLUSH PRIVILEGES;
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
);
[/xcode]
No issues? Ok, quit out..
[xcode=bash]
quit
[/xcode]

Edit /etc/pdns/pdns.conf and tell it how to connect:
[xcode=bash]
launch=gmysql
gmysql-host=127.0.0.1
gmysql-user=pdns_admin
gmysql-password=pdns_admin_password
gmysql-dbname=powerdns
[/xcode]

Make sure pdns starts on boot & start it up:
[xcode=bash]
chkconfig --levels 235 pdns on
service pdns start
[/xcode]

This server should now answer on domains its authoritative for. Other domains, however, it has no idea. Let's tell pdns to look at another server for recursion.
Edit the /etc/pdns/pdns.conf file and modify your recursion lines:
[xcode=bash]
# allow recursion for our subnet only (default allows recursion for everyone)
allow-recursion=192.168.0.0/24
# recursion server
recursor=192.168.0.1
[/xcode]

Web based frontend:

There are many web based frontends out there for pdns. We're going to use 'PowerDNS-Webinterface' It's a great looking, simple GUI that uses easy templates so that you can make it your own once you're done. Plus, it has multi-user support - create sub-accounts for your users!

Let's make sure we have some pre-reqs installed:
[xcode=bash]
yum install httpd php php-mysql gettext -y
[/xcode]

Make sure you're running at least PHP 5.2:
[xcode=bash]
php -v
PHP 5.3.8 (cli) (built: Oct 31 2011 18:26:52)
Copyright (c) 1997-2011 The PHP Group
[/xcode]

Download the latest powerdns-webinterface package: http://code.google.com/p/powerdns-webinterface/downloads/list

Unpack it and install:
[xcode=bash]
tar zxvf powerdns-webinterface-1.4.1.tar.gz
cd powerdns-webinterface
mysql -u pdns_admin -p powerdns < install.sql
mv web/* /var/www/html/
chmod 777 /var/www/html/tmp/templates_c
vim /var/www/html/configs/db.php (enter your db info)
[/xcode]

Login and test it - user: admin pass: admin
(change that password once you log in please!)
 


Great write-up! Wish I had found this earlier. I think i'm going to try that gui that you listed though. I'm using poweradmin currently but always looking for something new to try.
 

Staff online

Members online


Latest posts

Top