Ricerca nel sito web

Come installare e configurare "PowerDNS" (con MariaDB) e "PowerAdmin" in RHEL/CentOS 7


PowerDNS è un server DNS in esecuzione su molti derivati Linux/Unix. Può essere configurato con diversi backend inclusi file di zona in stile BIND, database relazionali o algoritmi di bilanciamento del carico/failover. Può anche essere configurato come cursore DNS in esecuzione come processo separato sul server.

L'ultima versione del server PowerDNS Authoritative è 3.4.4, ma quella attualmente disponibile nel repository EPEL è 3.4.3. Consiglierei di installare quella per il repository EPEL poiché questa versione è testata in CentOS e Fedora. In questo modo potrai anche aggiornare facilmente PowerDNS in futuro.

Questo articolo intende mostrarti come installare e configurare il server PowerDNS master con un backend MariaDB e PowerAdmin, uno strumento di gestione dell'interfaccia web intuitivo per PowerDNS.

Ai fini di questo articolo utilizzerò il server con:

Hostname: centos7.localhost 
IP Address 192.168.0.102

Passaggio 1: installazione di PowerDNS con il backend MariaDB

1. Per prima cosa devi abilitare il repository EPEL per il tuo server, utilizza semplicemente:

yum install epel-release.noarch 

2. Il passaggio successivo è installare il server MariaDB. Questo può essere fatto facilmente eseguendo il seguente comando:

yum -y install mariadb-server mariadb

3. Successivamente configureremo MySQL per abilitarlo e avviarlo all'avvio del sistema:

systemctl enable mariadb.service
systemctl start mariadb.service

4. Ora che il servizio MySQL è in esecuzione, proteggeremo e configureremo una password per MariaDB eseguendo:

mysql_secure_installation
Segui le istruzioni
/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. Una volta completata con successo la configurazione di MariaDB, possiamo procedere ulteriormente con l'installazione di PowerDNS. Questo può essere facilmente completato eseguendo:

yum -y install pdns pdns-backend-mysql

6. Il file di configurazione per PowerDNS si trova in /etc/pdns/pdns, ma prima di modificarlo, configureremo un database MySQL per Servizio PowerDNS. Per prima cosa ci collegheremo al server MySQL e creeremo un database con il nome powerdns:

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

7. Successivamente, creeremo un utente del database chiamato 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;

Nota: sostituisci "tecmint123" con la password effettiva che desideri utilizzare per la configurazione.

8. Procediamo creando le tabelle del database utilizzate da PowerDNS. Eseguili blocco per blocco:

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
);

Ora puoi uscire dalla console MySQL digitando:

MariaDB [(none)]> quit;

9. Finalmente possiamo procedere con la configurazione del nostro PowerDNS in modo che utilizzi MySQL come backend. A tale scopo, aprire il file di configurazione PowerDNS che si trova in:

vim /etc/pdns/pdns.conf 

In quel file cerca le righe simili a queste:

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

Subito dopo inserisci il seguente codice:

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

Cambia "user-pass" con la password effettiva che hai impostato in precedenza. Ecco come appare la mia configurazione:

Salva la modifica ed esci da.

10. Ora inizieremo e aggiungeremo PowerDNS all'elenco dei servizi che iniziano all'avvio del sistema:

systemctl enable pdns.service 
systemctl start pdns.service 

A questo punto il tuo server PowerDNS è attivo e funzionante. Per ulteriori informazioni su PowerDNS puoi fare riferimento al manuale disponibile all'indirizzo http://downloads.powerdns.com/documentation/html/index.html