PowerDNS: Alternative to BIND9
After my Raspberry Pi SD card got fried, I was left without a DNS server on my home network. So I wanted to reconfigure my other existing server box running Debian to serve as a DNS server.
But I was tired of using the same old Bind9. It’s configuration was somewhat cryptic, to say the least. As always, it was Google to the rescue, and PowerDNS was one of the listed alternatives that really caught my eye.
There were some quick tutorials here and there, that came in handy. But in short, it all boils down to the following core operations on my setup which I believe is way simpler than stated in either sites:
apt-get install pdns-server pdns-backend-mysql pdns-recursor
Edit the file /etc/powerdns/pdns.conf, uncomment or add the following lines:
allow-recursion=127.0.0.1,192.168.0.0/24 #depending on your IP and netmask
allow-recursion-override=on # This is the most important step if you want to serve your fake domains on your home network.
recursor=192.168.0.9:5300 # Again this would point to the actual recursor which we will configure later.
local-port=53 # This is the default DNS port
Edit the file /etc/powerdns/recursor.conf:
local-address=192.168.0.9
Edit the file /etc/powerdns/pdns.d/pdns.local:
gmysql-host=127.0.0.1
gmysql-user=power_admin
gmysql-password=power_admin_password
gmysql-dbname=powerdns
Run the following SQL script on MySQL:
CREATE DATABASE powerdns;
GRANT ALL ON powerdns.* TO 'power_admin'@'localhost' IDENTIFIED BY 'power_admin_password';
GRANT ALL ON powerdns.* TO 'power_admin'@'localhost.localdomain' IDENTIFIED BY 'power_admin_password';
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)
);
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
);
INSERT INTO domains (name, type) values ('example.com', 'NATIVE');
INSERT INTO records (domain_id, name, content, type,ttl,prio)
VALUES (1,'example.com','localhost [email protected] 1','SOA',86400,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
VALUES (1,'example.com','dns-us1.powerdns.net','NS',86400,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
VALUES (1,'example.com','dns-eu1.powerdns.net','NS',86400,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
VALUES (1,'www.example.com','192.168.5.9','A',120,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
VALUES (1,'mail.example.com','192.168.5.9','A',120,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
VALUES (1,'localhost.example.com','127.0.0.1','A',120,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
VALUES (1,'example.com','mail.example.com','MX',120,25);
Then startup the processes:
/etc/init.d/pdns-recursor start
Then do some digging and have fun: