Install Slave DNS Server on prewebhost dedicated server

Same steps as for out MASTER PowerDNS server:
-get install mysql-server pdns-server pdns-backend-mysql

Create database and mysql user

mysql -u root -p
Create database pdns;
CREATE USER ‘pdns’@’localhost’ IDENTIFIED BY ‘mypass’;
GRANT ALL PRIVILEGES ON pdns.* TO ‘pdns’@’localhost’;

Download and populate the database

mysql -u root -pmysqlpassword pdns < pdns.sql

Edit /etc/powerdns/pdns.conf


If you want to enable recursion on the slave also, find this :

#  recursor=

and change to this:


Check that everything was entered correct by running
/etc/init.d/pdns monitor

/etc/init.d/pdns monitor



the exit the monitor mode and start PowerDNS with

/etc/init.d/pdns start

By now we have two working DNS server, time to make sure that they will have the same information.
MySQL Replication to Slaves

This part is really important and needs to be done correctly. All the slaves need to contact the master to get the MySQL updates and keep in sync. It may seem complicated but once it’s setup you don’t need to touch it again and you will achieve instant DNS updates across your cluster.
Master Replication Setup

This part needs to be performed on the MASTER dns server only.

Edit /etc/mysql/my.cnf with the following settings:

server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
binlog_do_db = pdns

Also find this:

bind-address            =

and change it this:

bind-address            =

Exit, save and restart MySQL:

/etc/init.d/mysql restart

MySQL Replication User

A new SQL user needs to be created on the master:

mysql -u root -p

After entering the SQL root password:
Here is an important part that I noticed, I could not get the replication to work if I set a wildcard host to the mysql user. I had to use the IP of the slave. If you get it to work, leave a comment on how you did it.

grant replication slave on *.* to ‘pdnsslave’@’<ip or dnsname of your slave>’ identified by ‘mynewpassword’;
flush privileges;

Next we need some information from the master SQL that we will use on the slave later on:
while still connected to the mysql server, run this command:

show master status;

You should see something like this:

| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
| mysql-bin.000001 | 106 | pdns | |
1 row in set (0.00 sec)

Make a note of the File and Position values.
Slave Replication Setup

This part needs to be performed on the slave dns server(s) only.
Edit my.cnf

Edit /etc/mysql/my.cnf with the following settings:


[alert style=”green”]
The server-id variable needs to be different on each of the slave dns servers. i.e server-id=2, server-id=3

Restart MySQL:

/etc/init.d/mysql restart

Request Replication Access from the Master

mysql -u root -p

After entering the password:
(remember the filename and position from the master server? It’s time to enter them below)

change master to
master_password=’mynewpassword’, master_log_file=’mysql-bin.000001′, master_log_pos=106;
start slave;

You can see the status by using the following command:
show slave status;

Thats it! Replication is setup on the slave. When showing the status on the slave, if it says error anywhere, you need to troubleshoot the reason for the failure.
If you need to setup more DNS slaves, just follow the instructions again.

Common errors:
* Creating the pdnsslave user with * as host, I couldn’t get this to work. The slave wasn’t allowed to connect to the master! So when adding a new slave to the cluster you might need to add a new pdnsslave user for each new host.

Next step: Setup the webinterface so you easily can edit your DNS-entries.
I have decided to use Poweradmin 2.1.6, which was released on May 7th, 2012 in this guide.

* MySQL or PostgreSQL.
* A webserver. Apache 2.2.3 has been tested. ( I used nginX for this guide )
* PHP. It needs the mysql or pgsql extension and the PHP modules: session, gettext, mcrypt.
* PEAR and its packages PEAR::MDB2, PEAR::MDB2_Driver_mysql or PEAR::MDB2_Driver_pgsql.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.