Kako instalirati i konfigurirati 'PowerDNS' (sa MariaDB-om) i 'PowerAdmin' u RHEL/CentOS 7


PowerDNS je DNS server koji radi na mnogim Linux/Unix derivatima. Može se konfigurirati s različitim backendovima uključujući datoteke zona u BIND stilu, relacijske baze podataka ili algoritme za balansiranje opterećenja/failover. Takođe se može postaviti kao DNS rekurzor koji radi kao poseban proces na serveru.

Najnovija verzija PowerDNS autoritativnog servera je 3.4.4, ali trenutno dostupna u EPEL spremištu je 3.4.3. Preporučio bih instaliranje onog za EPEL spremište zbog činjenice da je ova verzija testirana u CentOS-u i Fedori. Na taj način ćete također moći lako ažurirati PowerDNS u budućnosti.

Ovaj članak ima za cilj da vam pokaže kako da instalirate i postavite glavni PowerDNS server sa MariaDB pozadinom i PowerAdmin – prijateljski alat za upravljanje web interfejsom za PowerDNS.

Za potrebe ovog članka koristit ću server sa:

Hostname: centos7.localhost 
IP Address 192.168.0.102

Korak 1: Instaliranje PowerDNS-a sa MariaDB Backend-om

1. Prvo morate omogućiti EPEL spremište za vaš server jednostavno koristite:

yum install epel-release.noarch 

2. Sljedeći korak je instaliranje MariaDB servera. Ovo se lako može učiniti pokretanjem sljedeće naredbe:

yum -y install mariadb-server mariadb

3. Zatim ćemo konfigurirati MySQL da omogući i pokrene nakon pokretanja sistema:

systemctl enable mariadb.service
systemctl start mariadb.service

4. Sada kada je MySQL servis pokrenut, osigurat ćemo i postaviti lozinku za MariaDB tako što ćemo pokrenuti:

mysql_secure_installation
Pratite uputstva
/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. Kada se MariaDB konfiguracija uspješno završi, možemo nastaviti s instalacijom PowerDNS-a. Ovo se lako završava pokretanjem:

yum -y install pdns pdns-backend-mysql

6. Konfiguracijska datoteka za PowerDNS se nalazi u /etc/pdns/pdns, ali prije nego što je uredimo, mi ćemo postaviti MySQL bazu podataka za PowerDNS usluga. Prvo ćemo se povezati na MySQL server i kreirati bazu podataka sa imenom powerdns:

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

7. Zatim ćemo kreirati korisnika baze podataka pod nazivom 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;

Napomena: Zamijenite “tecmint123 ” stvarnom lozinkom koju želite koristiti za svoje postavljanje.

8. Nastavljamo kreiranjem tabela baze podataka koje koristi PowerDNS. Izvršite te blok po 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
);

Sada možete izaći iz MySQL konzole upisivanjem:

MariaDB [(none)]> quit;

9. Konačno možemo nastaviti s konfiguracijom našeg PowerDNS-a na način da će koristiti MySQL kao pozadinu. U tu svrhu otvorite PowerDNS konfiguracijski fajl koji se nalazi na:

vim /etc/pdns/pdns.conf 

U tom fajlu potražite linije koje izgledaju ovako:

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

Odmah nakon toga stavite sljedeći kod:

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

Promijenite “user-pass” sa stvarnom lozinkom koju ste ranije postavili. Evo kako izgleda moja konfiguracija:

Sačuvajte promjenu i izađite iz.

10. Sada ćemo pokrenuti i dodati PowerDNS na listu usluga počevši od pokretanja sistema:

systemctl enable pdns.service 
systemctl start pdns.service 

U ovom trenutku vaš PowerDNS server je pokrenut i radi. Za više informacija o PowerDNS možete pogledati priručnik dostupan na http://downloads.powerdns.com/documentation/html/index.html