PowerDNS 29.2.22 on Mac OS X 10.5.8

Based on this hint and the official docs I got PowerDNS running on my mac.

Prerequisites

  • mac os x developer tools
  • mysql 5.0 or later (I’m using 5.1.31-osx10.5-x86)

Installation steps

  • Download boost library (I’m using 1_42_0) and extract
  • Download PowerDNS source distribution (I’m using 29.2.22) and extract
  • Compile and install:
$ CXXFLAGS="-I/Users/lsimons/Downloads/boost_1_42_0 -DDARWIN" ./configure \
    --with-mysql=/usr/local/mysql-5.1.31-osx10.5-x86 \
    --with-mysql-includes=/usr/local/mysql-5.1.31-osx10.5-x86/include \
    --without-pgsql \
    --without-sqlite \
    --without-sqlite3 \
    --prefix=/usr/local/pdns-2.9.22
$ make
$ sudo make install
$ cd /usr/local/pdns-2.9.22/etc
$ sudo cp pdns.conf-dist pdns.conf
$ vi pdns.conf
# look for the line #launch, just below add into pdns.conf:
#   launch=gmysql
#   gmysql-host=127.0.0.1
#   gmysql-user=root
#   gmysql-dbname=pdnstest
$ cd ../bin
$ sudo cp /Users/lsimons/Downloads/pdns-2.9.22/pdns/pdns .
$ sudo cp /Users/lsimons/Downloads/pdns-2.9.22/pdns/precursor .

Set up mysql database

Create pdns.sql:

CREATE TABLE domains (
    id              INT UNSIGNED NOT NULL PRIMARY KEY 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,

    UNIQUE INDEX name_index (name)
) ENGINE=InnoDB;

CREATE TABLE records (
    id              INT UNSIGNED NOT NULL PRIMARY KEY 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,

    INDEX rec_name_index (name),
    INDEX nametype_index (name, type),
    INDEX domain_id (domain_id)
) ENGINE=InnoDB;

create table supermasters (
    ip              VARCHAR(25) NOT NULL, 
    nameserver      VARCHAR(255) NOT NULL, 
    account         VARCHAR(40) DEFAULT NULL
) ENGINE=InnoDB;

GRANT SELECT ON supermasters TO pdns;
GRANT ALL ON domains TO pdns;
GRANT ALL ON domains TO pdns@localhost;
GRANT ALL ON records TO pdns;
GRANT ALL ON records TO pdns@localhost;

Create pdns_sample_data.sql:

INSERT INTO domains (name, type) values ('test.com', 'NATIVE');
INSERT INTO records (domain_id, name, content, type,ttl,prio) 
    VALUES (1,'test.com','localhost ahu@ds9a.nl 1','SOA',86400,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
    VALUES (1,'test.com','dns-us1.powerdns.net','NS',86400,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
    VALUES (1,'test.com','dns-eu1.powerdns.net','NS',86400,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
    VALUES (1,'www.test.com','199.198.197.196','A',120,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
    VALUES (1,'mail.test.com','195.194.193.192','A',120,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
    VALUES (1,'localhost.test.com','127.0.0.1','A',120,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
    VALUES (1,'test.com','mail.test.com','MX',120,25);

Populate mysql database:

$ echo "CREATE DATABASE pdnstest" | mysql -uroot -e
$ mysql -uroot < pdns.sql
$ mysql -uroot < pdns_sample_data.sql

Run pdns

$ cd /usr/local/pdns-2.9.22
$ sudo bin/pdns start

Test

$ dig www.test.com @127.0.0.1
...
www.test.com.		120	IN	A	199.198.197.196
...