PowerDNS 3.x.x on Debian (Wheezy)

From HostmasterWiki
Jump to: navigation, search


Prepare[edit]

$ sudo apt-get install \
make \
g++ \
pkg-config \
libssl-dev \
libboost-program-options-dev \
libboost-serialization-dev \
libmysqlclient-dev \
libcrypto++-dev \
libgmp3-dev \
libbotan1.10-dev
 
$ wget https://downloads.powerdns.com/releases/pdns-3.4.5.tar.bz2
$ tar xvfj pdns-3.4.5.tar.bz2
$ cd pdns-3.4.5

Compile & Install[edit]

Compile[edit]

$ ./configure \
--prefix=/usr \
--sysconfdir=/etc/powerdns \
--enable-botan1.10 \
--enable-cryptopp \
--enable-pdns_server \
--enable-tools \
--without-lua \
--with-modules="gmysql" \
--with-dynmodules="" 
 
$ make


Install[edit]

$ sudo make install
$ sudo cp pdns/pdns /etc/init.d/
$ sudo chmod +x /etc/init.d/pdns
$ sudo update-rc.d pdns defaults
 
$ sudo adduser \
--system \
--home /var/spool/powerdns \
--shell /bin/false \
--group \
--disabled-password \
--disabled-login \
--gecos "PowerDNS" \
pdns


SQL[edit]

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,
  disabled              TINYINT(1) DEFAULT 0,
  ordername             VARCHAR(255) BINARY DEFAULT NULL,
  auth                  TINYINT(1) DEFAULT 1,
  PRIMARY KEY (id)
) Engine=InnoDB;
 
CREATE INDEX nametype_index ON records(name,TYPE);
CREATE INDEX domain_id ON records(domain_id);
CREATE INDEX recordorder ON records (domain_id, ordername);
 
 
CREATE TABLE supermasters (
  ip                    VARCHAR(64) NOT NULL,
  nameserver            VARCHAR(255) NOT NULL,
  account               VARCHAR(40) NOT NULL,
  PRIMARY KEY (ip, nameserver)
) Engine=InnoDB;
 
 
CREATE TABLE comments (
  id                    INT AUTO_INCREMENT,
  domain_id             INT NOT NULL,
  name                  VARCHAR(255) NOT NULL,
  TYPE                  VARCHAR(10) NOT NULL,
  modified_at           INT NOT NULL,
  account               VARCHAR(40) NOT NULL,
  comment               VARCHAR(64000) NOT NULL,
  PRIMARY KEY (id)
) Engine=InnoDB;
 
CREATE INDEX comments_domain_id_idx ON comments (domain_id);
CREATE INDEX comments_name_type_idx ON comments (name, TYPE);
CREATE INDEX comments_order_idx ON comments (domain_id, modified_at);
 
 
CREATE TABLE domainmetadata (
  id                    INT AUTO_INCREMENT,
  domain_id             INT NOT NULL,
  kind                  VARCHAR(32),
  content               TEXT,
  PRIMARY KEY (id)
) Engine=InnoDB;
 
CREATE INDEX domainmetadata_idx ON domainmetadata (domain_id, kind);
 
 
CREATE TABLE cryptokeys (
  id                    INT AUTO_INCREMENT,
  domain_id             INT NOT NULL,
  flags                 INT NOT NULL,
  active                BOOL,
  content               TEXT,
  PRIMARY KEY(id)
) Engine=InnoDB;
 
CREATE INDEX domainidindex ON cryptokeys(domain_id);
 
 
CREATE TABLE tsigkeys (
  id                    INT AUTO_INCREMENT,
  name                  VARCHAR(255),
  algorithm             VARCHAR(50),
  secret                VARCHAR(255),
  PRIMARY KEY (id)
) Engine=InnoDB;
 
CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm);
 
ALTER TABLE `records` ADD CONSTRAINT `records_ibfk_1` FOREIGN KEY (`domain_id`)
REFERENCES `domains` (`id`) ON DELETE CASCADE;


Config[edit]

$ sudo nano /etc/powerdns/pdns.conf


local-address=192.168.1.1
local-port=53
 
# performance
cache-ttl=60
log-dns-details=no
loglevel=2
 
disable-axfr=yes
disable-tcp=no
 
distributor-threads=1
guardian=yes
master=no
slave=no
out-of-zone-additional-processing=yes
 
launch=gmysql
 
module-dir=/usr/lib/powerdns
config-dir=/etc/powerdns
socket-dir=/var/run
daemon=yes
setgid=pdns
setuid=pdns
 
webserver=yes
webserver-address=192.168.1.1
webserver-password=admin
webserver-port=8081
 
version-string=powerdns
 
gmysql-host=192.168.1.1
gmysql-port=3306
gmysql-dbname=powerdns
gmysql-user=powerdns
gmysql-password=powerdns


Munin[edit]

$ cd /usr/share/munin/plugins
$ sudo wget https://github.com/avar/munin-pdns/raw/master/pdns_queries \
https://github.com/avar/munin-pdns/raw/master/pdns_latency
 
$ sudo chmod +x pdns_queries pdns_latency
 
$ sudo ln -s /usr/share/munin/plugins/pdns_queries /etc/munin/plugins/pdns_queries
$ sudo ln -s /usr/share/munin/plugins/pdns_latency /etc/munin/plugins/pdns_latency
 
$ sudo echo -ne "\n\n[pdns_*]\nuser root\n\n" >> /etc/munin/plugin-conf.d/munin-node