はじめに
以前はDNSサーバと言えば,
DNSはサイト固有の要件が増えることが多く,
PowerDNSとは
ここでは,
PowerDNSは豊富なバックエンドをサポートするDNSサーバです。コンテンツDNSサーバとキャッシュDNSサーバの両方をサポートしており,
前提
ここではOSにGentoo/
- 使用するバックエンドはPostgreSQL
- ドメインはexample.
org - example.
orgのauthoritativeなDNSサーバはns. example. org - PostgreSQLサーバはpostgres.
example. org - PowerDNSは127.
0.0. 1でlisten - 既存のBINDから移行
PostgreSQLへデータの移行
BINDの設定をデータベースに移行します。移行には付属のzone2sqlコマンドを使用します。
> cd /etc/namedb > zone2sql --gpgsql > ~/domain.sql
既存のBINDの設定ファイルが利用できない場合は,
> dig example.org any @ns.example.org > db.example.org > vim named.conf zone "example.org" { type master; file "db.example.org"; }; > zone2sql --gpgsql > ~/domain.sql
PostgreSQLにユーザを作成します。
> psql -U postgres --password -h postgres.example.org template1 template1=# CREATE USER pdns PASSWORD 'password'; template1=# CREATE DATABASE pdns owner pdns; template1=# \q
テーブルを作成します。
> vim pdsn.sql CREATE TABLE domains ( id SERIAL PRIMARY KEY, 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 ); CREATE UNIQUE INDEX name_index ON domains(name); CREATE TABLE records ( id SERIAL PRIMARY KEY, 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, CONSTRAINT domain_exists FOREIGN KEY(domain_id) REFERENCES domains(id) ON DELETE CASCADE ); 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 ); GRANT SELECT ON supermasters TO pdns; GRANT ALL ON domains TO pdns; GRANT ALL ON domains_id_seq TO pdns; GRANT ALL ON records TO pdns; GRANT ALL ON records_id_seq TO pdns; > psql -U pdns --password -h postgres.example.org pdns < ~/pdns.sql
データをPostgreSQLにインポートします。
> psql -U pdns --password -h postgres.example.org pdns < ~/domain.sql