Difference between revisions of "PowerDNS: Instalasi Master dan Slave sekaligus jadi satu"
Onnowpurbo (talk | contribs) |
Onnowpurbo (talk | contribs) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
Disini akan digunakan | Disini akan digunakan | ||
− | * IP address 192.168.0.100 ( | + | * IP address 192.168.0.100 (powerdns server) |
− | * IP address | + | * IP address 127.0.01 (recursor) |
− | |||
− | |||
− | |||
− | |||
− | |||
Line 17: | Line 12: | ||
apt-get install pdns-server pdns-backend-mysql pdns-recursor mysql-server | apt-get install pdns-server pdns-backend-mysql pdns-recursor mysql-server | ||
+ | Akan ada error / warning karena pdns-server dan pdns-recursor sebetulnya tidak bisa jalan di satu mesin. Kita akan mengakali dari sisi konfigurasi. | ||
+ | |||
+ | ==Konfigurasi Database== | ||
+ | Set password 'poweruser' untuk akses ke database powerdns. | ||
+ | Buat semua tabel & index yang dibutuhkan. | ||
+ | mysql -u root -p123456 | ||
− | + | Lakukan | |
+ | CREATE DATABASE powerdns; | ||
+ | GRANT ALL ON powerdns.* TO 'poweruser'@'localhost' IDENTIFIED BY 'ubuntu'; | ||
+ | |||
+ | FLUSH PRIVILEGES; | ||
+ | |||
+ | 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(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) | ||
+ | ); | ||
+ | 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) | ||
+ | ); | ||
+ | |||
+ | 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) | ||
+ | ); | ||
+ | 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) | ||
+ | ); | ||
+ | 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) | ||
+ | ); | ||
+ | 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) | ||
+ | ); | ||
+ | CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm); | ||
− | + | Jika sudah selesai keluar | |
− | + | quit; | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | ==Konfigurasi powerdns== | |
3.Powerdns configuration | 3.Powerdns configuration | ||
− | Edit /etc/powerdns/pdns.d/pdns.local | + | Edit /etc/powerdns/pdns.d/pdns.local.gmysql.conf |
− | + | sudo vi /etc/powerdns/pdns.d/pdns.local.gmysql.conf | |
− | gmysql | ||
− | |||
− | |||
− | + | isi | |
+ | |||
+ | # MySQL Configuration | ||
+ | # | ||
+ | # Launch gmysql backend | ||
+ | launch=gmysql | ||
+ | |||
+ | # gmysql parameters | ||
+ | gmysql-host=localhost | ||
+ | gmysql-port= | ||
+ | gmysql-dbname=powerdns | ||
+ | gmysql-user=poweruser | ||
+ | gmysql-password=ubuntu | ||
+ | gmysql-dnssec=yes | ||
+ | # gmysql-socket= | ||
+ | |||
+ | Edit /etc/powerdns/pdns.conf | ||
+ | |||
+ | vi /etc/powerdns/pdns.conf | ||
+ | |||
+ | isi | ||
+ | |||
+ | allow-recursion=0.0.0.0/0 | ||
+ | config-dir=/etc/powerdns | ||
+ | daemon=yes | ||
+ | guardian=yes | ||
+ | include-dir=/etc/powerdns/pdns.d | ||
+ | launch= | ||
+ | setgid=pdns | ||
+ | setuid=pdns | ||
+ | version-string=powerdns | ||
+ | local-address=192.168.0.100 | ||
+ | local-port=53 | ||
+ | |||
+ | log-dns-details=yes | ||
+ | log-dns-queries=yes | ||
+ | logging-facility=0 | ||
+ | loglevel=6 | ||
+ | |||
+ | recursor=127.0.0.1:53 | ||
+ | |||
+ | Edit /etc/powerdns/recursor.conf | ||
+ | |||
+ | vi /etc/powerdns/recursor.conf | ||
+ | |||
+ | Isi | ||
+ | |||
+ | allow-from=127.0.0.1 | ||
+ | dont-query= | ||
+ | local-address=127.0.0.1 | ||
+ | local-port=53 | ||
+ | quiet=yes | ||
+ | setgid=pdns | ||
+ | setuid=pdns | ||
+ | |||
+ | |||
+ | ==Restart== | ||
+ | |||
+ | /etc/init.d/pdns restart | ||
+ | /etc/init.d/pdns-recursor restart | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Poweradmin installation | Poweradmin installation | ||
Line 154: | Line 196: | ||
Poweradmin will be installed on powerdns master host, so we need to install necessary packages: | Poweradmin will be installed on powerdns master host, so we need to install necessary packages: | ||
− | apt-get install apache2-mpm-prefork php5-mysql libapache2-mod-php5 php-pear php-mdb2 php-mdb2-driver-mysql | + | apt-get install apache2-mpm-prefork php5-mysql libapache2-mod-php5 php-pear php-mdb2 php-mdb2-driver-mysql |
Then download, unpack and make some preparations before installation process: | Then download, unpack and make some preparations before installation process: | ||
− | cd /var/www | + | cd /var/www |
− | wget --no-check-certificate https://www.poweradmin.org/download/poweradmin-2.1.4.tgz | + | wget --no-check-certificate https://www.poweradmin.org/download/poweradmin-2.1.4.tgz |
− | tar zxvf poweradmin-2.1.4.tgz | + | tar zxvf poweradmin-2.1.4.tgz |
− | ln -s poweradmin-2.1.4 poweradmin | + | ln -s poweradmin-2.1.4 poweradmin |
− | chown www-data.www-data -R poweradmin-2.1.4 | + | chown www-data.www-data -R poweradmin-2.1.4 |
− | cp /var/www/poweradmin/inc/config-me.inc.php /var/www/poweradmin/inc/config.inc.php | + | cp /var/www/poweradmin/inc/config-me.inc.php /var/www/poweradmin/inc/config.inc.php |
With default apache2 configuration, type in web browser address http://192.168.56.3/poweradmin/install and follow steps to finish poweradmin installation | With default apache2 configuration, type in web browser address http://192.168.56.3/poweradmin/install and follow steps to finish poweradmin installation | ||
Line 169: | Line 211: | ||
Instead of what is shown in step 6 use below listed grant for user poweradmin: | Instead of what is shown in step 6 use below listed grant for user poweradmin: | ||
− | GRANT SELECT, INSERT, UPDATE, DELETE ON powerdns.* TO 'poweradmin'@'localhost'; | + | GRANT SELECT, INSERT, UPDATE, DELETE ON powerdns.* TO 'poweradmin'@'localhost'; |
− | FLUSH PRIVILEGES; | + | FLUSH PRIVILEGES; |
After successful installation remove install directory. | After successful installation remove install directory. | ||
− | rm -rf /var/www/poweradmin/install | + | rm -rf /var/www/poweradmin/install |
There is a small bug in latest stable release of poweradmin-2.1.4, which has been explained in ticket https://www.poweradmin.org/trac/ticket/346.To repair that replace line 196 with $retcount++; in inc/templates.inc.php file. | There is a small bug in latest stable release of poweradmin-2.1.4, which has been explained in ticket https://www.poweradmin.org/trac/ticket/346.To repair that replace line 196 with $retcount++; in inc/templates.inc.php file. | ||
+ | |||
Poweradmin usage | Poweradmin usage | ||
Line 185: | Line 228: | ||
Then edit 'default' zone template by adding new records: | Then edit 'default' zone template by adding new records: | ||
− | #examples | + | #examples |
− | [ZONE] SOA ns1.example.com hostmaster.example.com [SERIAL] 10800 3600 604800 600 | + | [ZONE] SOA ns1.example.com hostmaster.example.com [SERIAL] 10800 3600 604800 600 |
− | [ZONE] A 192.168.56.3 86400 | + | [ZONE] A 192.168.56.3 86400 |
− | www.[ZONE] A 192.168.56.3 86400 | + | www.[ZONE] A 192.168.56.3 86400 |
− | mail.[ZONE] A 192.168.56.3 86400 | + | mail.[ZONE] A 192.168.56.3 86400 |
− | [ZONE] NS ns1.example.com 86400 | + | [ZONE] NS ns1.example.com 86400 |
− | [ZONE] NS ns2.example.com 86400 | + | [ZONE] NS ns2.example.com 86400 |
− | [ZONE] MX mail.[ZONE] 10 86400 | + | [ZONE] MX mail.[ZONE] 10 86400 |
Make some tests with adding new domain using created zone template by adding master zone (choose type: master) | Make some tests with adding new domain using created zone template by adding master zone (choose type: master) | ||
Line 201: | Line 244: | ||
use powerdns; | use powerdns; | ||
− | insert into supermasters values ('192.168.56.3', 'ns1.example.com', 'admin'); | + | insert into supermasters values ('192.168.56.3', 'ns1.example.com', 'admin'); |
Migration from bind | Migration from bind | ||
Line 207: | Line 250: | ||
Use zone2sql script to migrate domains from bind to powerdns | Use zone2sql script to migrate domains from bind to powerdns | ||
− | zone2sql --gmysql --named-conf=/etc/bind/named.conf > bind.sql | + | zone2sql --gmysql --named-conf=/etc/bind/named.conf > bind.sql |
If domain type is NATIVE, change it into MASTER using example sed command | If domain type is NATIVE, change it into MASTER using example sed command | ||
− | sed 's/NATIVE/MASTER/g' bind.sql > bind.master.sql | + | sed 's/NATIVE/MASTER/g' bind.sql > bind.master.sql |
Thats all folks. If you have any questions don't hesitate to write ;-) | Thats all folks. If you have any questions don't hesitate to write ;-) | ||
− | |||
− | |||
− | |||
==Referensi== | ==Referensi== | ||
* http://linuxmanage.com/master-slave-powerdns-managed-by-poweradmin.html | * http://linuxmanage.com/master-slave-powerdns-managed-by-poweradmin.html | ||
+ | * http://www.admin-magazine.com/Articles/PowerDNS-The-Other-Open-Source-Name-Server |
Latest revision as of 14:10, 19 February 2019
Dalam tutorial ini akan di coba untuk mengkonfigurasi powerdns agar bisa berjalan sebagai master dan slave di satu mesin.
Disini akan digunakan
- IP address 192.168.0.100 (powerdns server)
- IP address 127.0.01 (recursor)
Instalasi powerdns
apt-get install pdns-server pdns-backend-mysql pdns-recursor mysql-server
Akan ada error / warning karena pdns-server dan pdns-recursor sebetulnya tidak bisa jalan di satu mesin. Kita akan mengakali dari sisi konfigurasi.
Konfigurasi Database
Set password 'poweruser' untuk akses ke database powerdns. Buat semua tabel & index yang dibutuhkan.
mysql -u root -p123456
Lakukan
CREATE DATABASE powerdns; GRANT ALL ON powerdns.* TO 'poweruser'@'localhost' IDENTIFIED BY 'ubuntu'; FLUSH PRIVILEGES; 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(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) ); 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) ); 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) ); 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) ); 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) ); 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) ); CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm);
Jika sudah selesai keluar
quit;
Konfigurasi powerdns
3.Powerdns configuration
Edit /etc/powerdns/pdns.d/pdns.local.gmysql.conf
sudo vi /etc/powerdns/pdns.d/pdns.local.gmysql.conf
isi
# MySQL Configuration # # Launch gmysql backend launch=gmysql # gmysql parameters gmysql-host=localhost gmysql-port= gmysql-dbname=powerdns gmysql-user=poweruser gmysql-password=ubuntu gmysql-dnssec=yes # gmysql-socket=
Edit /etc/powerdns/pdns.conf
vi /etc/powerdns/pdns.conf
isi
allow-recursion=0.0.0.0/0 config-dir=/etc/powerdns daemon=yes guardian=yes include-dir=/etc/powerdns/pdns.d launch= setgid=pdns setuid=pdns version-string=powerdns local-address=192.168.0.100 local-port=53 log-dns-details=yes log-dns-queries=yes logging-facility=0 loglevel=6 recursor=127.0.0.1:53
Edit /etc/powerdns/recursor.conf
vi /etc/powerdns/recursor.conf
Isi
allow-from=127.0.0.1 dont-query= local-address=127.0.0.1 local-port=53 quiet=yes setgid=pdns setuid=pdns
Restart
/etc/init.d/pdns restart /etc/init.d/pdns-recursor restart
Poweradmin installation
Poweradmin will be installed on powerdns master host, so we need to install necessary packages:
apt-get install apache2-mpm-prefork php5-mysql libapache2-mod-php5 php-pear php-mdb2 php-mdb2-driver-mysql
Then download, unpack and make some preparations before installation process:
cd /var/www wget --no-check-certificate https://www.poweradmin.org/download/poweradmin-2.1.4.tgz tar zxvf poweradmin-2.1.4.tgz ln -s poweradmin-2.1.4 poweradmin chown www-data.www-data -R poweradmin-2.1.4 cp /var/www/poweradmin/inc/config-me.inc.php /var/www/poweradmin/inc/config.inc.php
With default apache2 configuration, type in web browser address http://192.168.56.3/poweradmin/install and follow steps to finish poweradmin installation
Instead of what is shown in step 6 use below listed grant for user poweradmin:
GRANT SELECT, INSERT, UPDATE, DELETE ON powerdns.* TO 'poweradmin'@'localhost'; FLUSH PRIVILEGES;
After successful installation remove install directory.
rm -rf /var/www/poweradmin/install
There is a small bug in latest stable release of poweradmin-2.1.4, which has been explained in ticket https://www.poweradmin.org/trac/ticket/346.To repair that replace line 196 with $retcount++; in inc/templates.inc.php file.
Poweradmin usage
Type in your web browser http://192.168.56.3/poweradmin and login as admin with password you typed in installation (step 3)
Easiest way to manage domains is to create zone template or templeates. Got to List zone templates > Add zone template > fill Name('default' in that case)
Then edit 'default' zone template by adding new records:
#examples [ZONE] SOA ns1.example.com hostmaster.example.com [SERIAL] 10800 3600 604800 600 [ZONE] A 192.168.56.3 86400 www.[ZONE] A 192.168.56.3 86400 mail.[ZONE] A 192.168.56.3 86400 [ZONE] NS ns1.example.com 86400 [ZONE] NS ns2.example.com 86400 [ZONE] MX mail.[ZONE] 10 86400
Make some tests with adding new domain using created zone template by adding master zone (choose type: master)
Don't forget to add ns1.example.com and ns2.example.com A type records.
Finally add into slave mysql server direction where master powerdns server is located by adding proper ip and master ns domain name.
use powerdns;
insert into supermasters values ('192.168.56.3', 'ns1.example.com', 'admin');
Migration from bind
Use zone2sql script to migrate domains from bind to powerdns
zone2sql --gmysql --named-conf=/etc/bind/named.conf > bind.sql
If domain type is NATIVE, change it into MASTER using example sed command
sed 's/NATIVE/MASTER/g' bind.sql > bind.master.sql
Thats all folks. If you have any questions don't hesitate to write ;-)