Cara Menginstal dan Mengonfigurasi 'PowerDNS' (dengan MariaDB) dan 'PowerAdmin' di RHEL/CentOS 7


PowerDNS adalah server DNS yang berjalan pada banyak turunan Linux/Unix. Ini dapat dikonfigurasi dengan backend yang berbeda termasuk file zona gaya BIND, database relasional, atau algoritma penyeimbangan beban/failover. Itu juga dapat diatur sebagai rekursor DNS yang berjalan sebagai proses terpisah di server.

Versi terbaru server PowerDNS Authoritative adalah 3.4.4, namun yang tersedia di repositori EPEL saat ini adalah 3.4.3. Saya akan merekomendasikan menginstal versi ini untuk repositori EPEL karena versi ini telah diuji di CentOS dan Fedora. Dengan begitu Anda juga dapat dengan mudah memperbarui PowerDNS di masa mendatang.

Artikel ini bermaksud menunjukkan kepada Anda cara memasang dan menyiapkan server PowerDNS master dengan backend MariaDB dan PowerAdmin – alat pengelola antarmuka web yang mudah digunakan untuk KekuatanDNS.

Untuk tujuan artikel ini saya akan menggunakan server dengan:

Hostname: centos7.localhost 
IP Address 192.168.0.102

Langkah 1: Menginstal PowerDNS dengan MariaDB Backend

1. Pertama, Anda perlu mengaktifkan repositori EPEL untuk server Anda cukup gunakan:

yum install epel-release.noarch 

2. Langkah selanjutnya adalah menginstal server MariaDB. Ini dapat dilakukan dengan mudah dengan menjalankan perintah berikut:

yum -y install mariadb-server mariadb

3. Selanjutnya kita akan mengkonfigurasi MySQL untuk mengaktifkan dan memulai saat sistem boot:

systemctl enable mariadb.service
systemctl start mariadb.service

4. Sekarang setelah layanan MySQL berjalan, kita akan mengamankan dan menyiapkan kata sandi untuk MariaDB dengan menjalankan:

mysql_secure_installation
Ikuti Instruksi
/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):  Press ENTER
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y     
New password:  ← Set New Password
Re-enter new password:  ← Repeat Above Password
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y ← Choose “y” to disable that user
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n ← Choose “n” for no
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y ← Choose “y” for yes
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y ← Choose “y” for yes
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

5. Setelah konfigurasi MariaDB berhasil dilakukan, kita dapat melanjutkan lebih jauh dengan instalasi PowerDNS. Ini mudah diselesaikan dengan menjalankan:

yum -y install pdns pdns-backend-mysql

6. File konfigurasi untuk PowerDNS terletak di /etc/pdns/pdns, namun sebelum mengeditnya, kita akan menyiapkan database MySQL untuk layanan PowerDNS. Pertama kita akan terhubung ke server MySQL dan membuat database dengan nama powerdns:

mysql -u root -p
MariaDB [(none)]> CREATE DATABASE powerdns;

7. Selanjutnya, kita akan membuat pengguna database bernama powerdns:

MariaDB [(none)]> GRANT ALL ON powerdns.* TO 'powerdns'@'localhost' IDENTIFIED BY 'tecmint123';
MariaDB [(none)]> GRANT ALL ON powerdns.* TO 'powerdns'@'centos7.localdomain' IDENTIFIED BY 'tecmint123';
MariaDB [(none)]> FLUSH PRIVILEGES;

Catatan: Ganti “tecmint123 ” dengan sandi sebenarnya yang ingin Anda gunakan untuk penyiapan Anda.

8. Kita melanjutkan dengan membuat tabel database yang digunakan oleh PowerDNS. Jalankan blok demi blok:

MariaDB [(none)]> USE powerdns;
MariaDB [(none)]> 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)
);

MariaDB [(none)]> CREATE UNIQUE INDEX name_index ON domains(name);
MariaDB [(none)]> 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)
);

MariaDB [(none)]> CREATE INDEX rec_name_index ON records(name);
MariaDB [(none)]> CREATE INDEX nametype_index ON records(name,type);
MariaDB [(none)]> CREATE INDEX domain_id ON records(domain_id);

MariaDB [(none)]> CREATE TABLE supermasters (
ip VARCHAR(25) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) DEFAULT NULL
);

Anda sekarang dapat keluar dari konsol MySQL dengan mengetik:

MariaDB [(none)]> quit;

9. Terakhir, kita dapat melanjutkan dengan mengonfigurasi PowerDNS sedemikian rupa sehingga menggunakan MySQL sebagai backend. Untuk itu buka file konfigurasi PowerDNS yang terletak di:

vim /etc/pdns/pdns.conf 

Di file itu cari baris seperti ini:

#################################
launch        Which backends to launch and order to query them in
#
launch=

Baru setelah itu masukkan kode berikut:

launch=gmysql
gmysql-host=localhost
gmysql-user=powerdns
gmysql-password=user-pass
gmysql-dbname=powerdns

Ubah “user-pass ” dengan kata sandi sebenarnya yang Anda tetapkan sebelumnya. Berikut tampilan konfigurasi saya:

Simpan kembalian Anda dan keluar dari.

10. Sekarang kita akan memulai dan menambahkan PowerDNS ke daftar layanan yang dimulai saat boot sistem:

systemctl enable pdns.service 
systemctl start pdns.service 

Pada titik ini server PowerDNS Anda sudah aktif dan berjalan. Untuk informasi lebih lanjut tentang PowerDNS Anda dapat merujuk ke manual yang tersedia di http://downloads.powerdns.com/documentation/html/index.html