Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


powerdns_on_centos_6.4

PowerDNS Recursor and Authoritative Server on one server

  • OS: CentOS 6.5
  • EPEL repository
  • Backend: MySQL

Install PowerDNS and backend

yum install -y bind-utils pdns pdns-recursor pdns-backend-mysql mysql-server

Start at boot:

chkconfig mysqld on
chkconfig pdns on
chkconfig pdns-recursor on

Post configure MySQL:

service mysqld start
/usr/bin/mysql_secure_installation

Create database

mysqladmin -u root -p create powerdns 
mysql -u root -p
create user 'powerdns'@'localhost' identified by 'password';
grant all privileges on powerdns.* to 'powerdns'@'localhost';
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)
) Engine=InnoDB;

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(10) DEFAULT NULL,
  content         VARCHAR(64000) DEFAULT NULL,
  ttl             INT DEFAULT NULL,
  prio            INT DEFAULT NULL,
  change_date     INT DEFAULT NULL,
  primary key(id)
) Engine=InnoDB;

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
) Engine=InnoDB;

Configure MySQL binlog

Add the binlog_format=ROW line to /etc/my.cnf.

[mysqld]
binlog_format=ROW

Configure PowerDNS

/etc/pdns/pdns.conf

allow-axfr-ips=<IPs allowed axfr>
allow-recursion=<IPs allowed recursion>
launch=gmysql
gmysql-host=127.0.0.1
gmysql-user=<yourdbuser>
gmysql-password=<yourdbpassword>
gmysql-dbname=powerdns
local-address=<yourserverIPs>
local-port=53
master=yes
recursor=127.0.0.1:5353
setgid=pdns
setuid=pdns
webserver=yes
webserver-address=<bindipaddress>
webserver-password=<yourpassword>
webserver-port=8081

Start PowerDNS

Test:

service pdns monitor

Start:

service pdns start

Configure recursor

/etc/pdns-recursor/recursor.conf

setuid=pdns-recursor
setgid=pdns-recursor
allow-from=127.0.0.0/8
local-address=127.0.0.1
local-port=5353

Start recursor

service pdns-recursor start

Test Recursor

host ping.xs4all.nl 127.0.0.1
Using domain server:
Name: 127.0.0.1
Address: 127.0.0.1#53
Aliases:

ping.xs4all.nl has address 194.109.6.8
ping.xs4all.nl has IPv6 address 2001:888:0:25:194:109:21:66

Configure iptables

  • Open port tcp/8081 for PowerDNS webstats
  • Open port tcp/53 and udp/53 for DNS traffic
powerdns_on_centos_6.4.txt · Last modified: 2021/10/09 15:14 by 127.0.0.1