How To Install PowerDNS on CentOS

Updated on November 21, 2023
How To Install PowerDNS on CentOS header image

Introduction

In this Vultr tutorial, you'll learn how to install PowerDNS. PowerDNS is a program for running your own nameservers. It is very useful when combined with Vultr's DDoS protected network. The steps in the tutorial will work on both CentOS 5 and CentOS 6 (on both x64 and i686 variants).

Prerequisites

Install wget if it's not already installed.

yum install wget -y

Installing PowerDNS

Install MySQL and start the service.

yum install mysql mysql-server -y
service mysqld start

Set the MySQL password.

mysqladmin -u root password <your desired password>

Log into your MySQL server and create a database for PowerDNS.

mysql -u root -p 
CREATE DATABASE powerdns;

Create the PowerDNS user.

user powerdns;

Populate the required tables for 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
-> );

Exit the MySQL console.

quit;

Install the PowerDNS software (pdns).

yum install pdns pdns-backend-mysql -y

Open the PowerDNS configuration with your favorite text editor.

vi /etc/pdns/pdns.conf

You should see the following section in the configuration file. Update the MySQL password accordingly.

# launch=
launch=gmysql
gmysql-host=127.0.0.1
gmysql-user=root
gmysql-password=<your_mysql_password>
gmysql-dbname=powerdns

Start the PowerDNS service.

service pdns start

Configure both PowerDNS and MySQL to start on boot.

chkconfig --levels 235 mysqld on
chkconfig --levels 235 pdns on

Conclusion

Congratulations, you now have a running PowerDNS server. In order to add, remove, edit, or even move a zone, simply connect to the database and push the required changes. At this point, you are ready to point a domain to your server.