Tuesday, August 20, 2019

.::: How to Install PowerDNS and Poweradmin on CentOS 7 :::.

PowerDNS (pdns) is an open source DNS server written in C++ and released under GPL License. It has become a good alternative for the traditional DNS server Bind, designed with better performance and low memory requirements. PowerDNS provides two products, the Authoritative server, and the Recursor. The PowerDNS Authoritative server can be configured through the different backend, including the plain Bind zone files, RDBMS such as MySQL, PostgreSQL, SQLite3 or LDAP.
1. Disable /allow firewall, selinux and add hosts
[root@powerdns-teguht data]# systemctl stop firewalld
[root@powerdns-teguht data]# systemctl disable firewalld
rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'
rm '/etc/systemd/system/basic.target.wants/firewalld.service'
[root@powerdns-teguht data]#

[root@powerdns-teguht data]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted


[root@powerdns-teguht data]#

[root@powerdns-teguht data]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted


[root@powerdns-teguht data]#


2. First you need to enable the EPEL repository for your server simply use:

[root@powerdns-teguht ~]# yum update  -y
[root@powerdns-teguht ~]# yum install epel-release.noarch  -y

3. The next step is to install the MariaDB server. This can be easily done by running the following command:

[root@powerdns-teguht ~]# yum -y install mariadb-server mariadb

4. Next we will configure MySQL/MariaDB to enable and start upon system boot:

[root@powerdns-teguht ~]# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@powerdns-teguht ~]# systemctl start mariadb.service
[root@powerdns-teguht ~]#

[root@powerdns-teguht pdns]# rpm -qa | grep -i maria
mariadb-server-5.5.60-1.el7_5.x86_64
mariadb-libs-5.5.60-1.el7_5.x86_64
mariadb-5.5.60-1.el7_5.x86_64
[root@powerdns-teguht pdns]#

5. Now that the MySQL service is running, we will secure and setup a password for MariaDB by running:

# mysql_secure_installation

[root@powerdns-teguht ~]# mysql_secure_installation

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!
[root@powerdns-teguht ~]#

6. The configuration file for PowerDNS is located in /etc/pdns/pdns, & create a new database called 'powerdns' and grant all the database privileges to a new user named 'pdns' with password 'pdnsteguht'.

create database powerdns;
grant all privileges on powerdns.* to pdns@localhost identified by 'pdnsteguht';
flush privileges;

== optional ==
create database powerdns;
create user pdns
grant all privileges on powerdns.* to pdns@localhost identified by 'pdnsteguht';
flush privileges;

create database powerdns;
create user 'pdns' identified by 'pdnsteguht';
grant all privileges on powerdns.* to 'pdns'@'%' identified by 'pdnsteguht' with grant option;
FLUSH PRIVILEGES;

== optional ==
[root@powerdns-teguht ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database powerdns;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]>  grant all privileges on powerdns.* to pdns@localhost identified by 'pdnsteguht';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]>  flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]>


7. create database and table MariaDB

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)
 ) Engine=InnoDB;

 CREATE UNIQUE INDEX name_index ON domains(name);


 CREATE TABLE records (
   id                    BIGINT 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)
 ) Engine=InnoDB;

 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)
 ) Engine=InnoDB;


 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)
 ) Engine=InnoDB;

 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)
 ) Engine=InnoDB;

 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)
 ) Engine=InnoDB;

 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)
 ) Engine=InnoDB;

 CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm);

 quit;

8. Install PowerDNS & configuring pdns.conf
[root@powerdns-teguht ~]# yum -y install pdns pdns-backend-mysql pdns-recursor bind-utils
[root@powerdns-teguht pdns]# rpm -qa | grep -i pdns
pdns-4.1.11-1.el7.x86_64
pdns-backend-mysql-4.1.11-1.el7.x86_64
[root@powerdns-teguht pdns]#
[root@powerdns-teguht ~]# cd /etc/pdns/
[root@powerdns-teguht pdns]# cat pdns.conf | grep gmysql
launch=gmysql
gmysql-host=localhost
gmysql-user=pdns
gmysql-password=pdnsteguht
gmysql-dbname=powerdns
[root@powerdns-teguht pdns]#

9. Start and enable service pdns
[root@powerdns-teguht pdns]# systemctl start pdns
[root@powerdns-teguht pdns]#  systemctl enable pdns
Created symlink from /etc/systemd/system/multi-user.target.wants/pdns.service to /usr/lib/systemd/system/pdns.service.
[root@powerdns-teguht pdns]#


[root@powerdns-teguht pdns]# netstat -tap | grep pdns
tcp        0      0 0.0.0.0:domain          0.0.0.0:*               LISTEN      10241/pdns_server 
tcp6       0      0 [::]:domain             [::]:*                  LISTEN      10241/pdns_server 
[root@powerdns-teguht pdns]#  netstat -tulpn | grep 53
tcp        0      0 0.0.0.0:53              0.0.0.0:*               LISTEN      10241/pdns_server 
tcp6       0      0 :::53                   :::*                    LISTEN      10241/pdns_server 
udp        0      0 0.0.0.0:53              0.0.0.0:*                           10241/pdns_server 
udp6       0      0 :::53                   :::*                                10241/pdns_server 
[root@powerdns-teguht pdns]#

10. Test dns service
[root@powerdns-teguht pdns]# dig @127.0.0.1

; <<>> DiG 9.9.4-RedHat-9.9.4-74.el7_6.2 <<>> @127.0.0.1
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 9286
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1680
;; QUESTION SECTION:
;.                IN    NS

;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Aug 20 16:49:46 WIB 2019
;; MSG SIZE  rcvd: 28

[root@powerdns-teguht pdns]# 

11. Install Poweradmin as below

No comments:

Post a Comment

Popular Posts