In this tutorial we’ll install the Debian Linux 9 (squeeze), Apache 2 with mpm-itk (to run each web as a isolated user),...
Installing PowerDNS as supermaster with slaves
Ástþór IPThe PowerDNS Nameserver is a modern, advanced and high performance authoritative-only nameserver. It is written from scratch and conforms to all relevant DNS standards documents. Furthermore, PowerDNS interfaces with almost any database.
This tutorial has been tested to be working on Debian squeeze. It’s assumed that you are installing one supermaster and one or more slaves that will sync with the master automatically.
On all servers
1. Install the PowerDNS server and MySql backend using apt
apt-get install pdns-server pdns-backend-mysql
2. Create a new database (or use existing) and execute the following SQL queries to create the PowerDNS table structure:
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)
)type=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(6) DEFAULT NULL,
content VARCHAR(255) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
primary key(id)
)type=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
);
3. Configure PowerDNS to use the MySql backend by adding this line into the configuration file (pico /etc/powerdns/pdns.conf)
launch=gmysql
4. Configure MySql login information for the PowerDNS by adding lines similar to these (pico /etc/powerdns/pdns.d/pdns.local).
gmysql-host=127.0.0.1
gmysql-user=pdns
gmysql-password=password
gmysql-dbname=pdns
Replace the username, password and dbname with a valid login information and database name. Each DNS server in the cluster needs to have a dedicated local database.
On the master server
5. Allow zone transferes and enable master operation. (pico /etc/powerdns/pdns.conf)
allow-axfr-ips=10.0.0.2
disable-axfr=no
master=yes
6. Add a new zone
INSERT INTO domains (name, type) VALUES ('example.org', 'MASTER');
INSERT INTO records (domain_id, name, content, type, ttl, prio) VALUES (1, 'example.org', 'ns1.example.org hostmaster.example.org 1', 'SOA', 86400, NULL);
INSERT INTO records (domain_id, name, content, type, ttl, prio) VALUES (1, 'example.org', 'ns1.example.org', 'NS', 86400, NULL);
INSERT INTO records (domain_id, name, content, type, ttl, prio) VALUES (1, 'example.org', 'ns2.example.org', 'NS', 86400, NULL);
INSERT INTO records (domain_id, name, content, type, ttl, prio) VALUES (1, 'ns1.example.org', '10.0.0.1', 'A', 86400, NULL);
INSERT INTO records (domain_id, name, content, type, ttl, prio) VALUES (1, 'ns2.example.org', '10.0.0.2', 'A', 86400, NULL);
On the slaves
7. Enable slave operation (pico /etc/powerdns/pdns.conf)
slave=yes
8. Make the master server a supermaster for the slave. If supermaster is specified, all new zones will be added automatically to the slave when notified by the master.
INSERT INTO supermasters (ip, nameserver, account) VALUES ('10.0.0.1', 'ns2.example.org', '');
Assuming the master IP address is 10.0.0.1
On master and slaves
9. Restart PowerDNS
/etc/init.d/pdns restart
On the master
10. Trigger a notify
UPDATE records SET content = 'ns1.example.org hostmaster.example.org 2' WHERE type = 'SOA' AND name = 'example.org';
Increasing the serial will sync data from the master to the slave