PowerDNS: Instalasi di Ubuntu 18.04 dengan MariaDB

From OnnoWiki
Revision as of 11:09, 20 February 2019 by Onnowpurbo (talk | contribs) (→‎Cek)
Jump to navigation Jump to search

Instalasi PowerDNS di Ubuntu 18.04

Persiapan

Edit

vi /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu bionic main universe multiverse
deb http://archive.ubuntu.com/ubuntu bionic-security main universe multiverse
deb http://archive.ubuntu.com/ubuntu bionic-updates main universe multiverse
deb [arch=amd64] http://repo.powerdns.com/ubuntu bionic-auth-41 main
deb [arch=amd64] http://mirror.zol.co.zw/mariadb/repo/10.3/ubuntu bionic main

Jalankan

sudo curl https://repo.powerdns.com/FD380FBB-pub.asc | sudo apt-key add -
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo apt update

Instalasi MariaDB

sudo su
apt remove --purge mariadb-server
apt -y install software-properties-common
add-apt-repository 'deb [arch=amd64] http://mirror.zol.co.zw/mariadb/repo/10.3/ubuntu bionic main'
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
apt update
apt -y install mariadb-server mariadb-client

Set password root MariaDB, kalau masih dalam proses belajar bisa menggunakan 123456

Siapkan Database

Login ke database

sudo mysql -u root -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 48
Server version: 10.3.12-MariaDB-1:10.3.12+maria~bionic-log mariadb.org binary distribution

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


Siapkan tabel

CREATE DATABASE powerdns;

GRANT ALL ON powerdns.* TO 'powerdns'@'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 UNSIGNED DEFAULT NULL,
  account               VARCHAR(40) CHARACTER SET 'utf8' DEFAULT NULL,
  PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';

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 CHARACTER SET 'latin1';

CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);
CREATE INDEX ordername ON records (ordername);

CREATE TABLE supermasters (
  ip                    VARCHAR(64) NOT NULL,
  nameserver            VARCHAR(255) NOT NULL,
  account               VARCHAR(40) CHARACTER SET 'utf8' NOT NULL,
  PRIMARY KEY (ip, nameserver)
) Engine=InnoDB CHARACTER SET 'latin1';

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) CHARACTER SET 'utf8' DEFAULT NULL,
  comment               TEXT CHARACTER SET 'utf8' NOT NULL,
  PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';

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 CHARACTER SET 'latin1';

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 CHARACTER SET 'latin1';

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 CHARACTER SET 'latin1';

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

QUIT

Install PowerDNS

Disable systemd resolver, karena akan block port 53

sudo systemctl disable systemd-resolved
sudo systemctl stop systemd-resolved
sudo ls -lh /etc/resolv.conf 
sudo rm /etc/resolv.conf
sudo echo "nameserver 8.8.8.8" > /etc/resolv.conf

Siapkan repo official PowerDNS

sudo su
vi /etc/apt/sources.list

isi dengan

deb [arch=amd64] http://repo.powerdns.com/ubuntu bionic-auth-41 main

Lakukan

sudo su
curl https://repo.powerdns.com/FD380FBB-pub.asc | sudo apt-key add -
apt update
apt -y install pdns-server pdns-backend-mysql

Jika ada pertanyaan configure the PowerDNS database with dbconfig-common, jawab No

Setup PowerDNS untuk pakai MySQL

Edit

vi /etc/powerdns/pdns.d/pdns.local.gmysql.conf 

Isi dengan

# MySQL Configuration
# Launch gmysql backend
launch+=gmysql
# gmysql parameters
gmysql-host=localhost
gmysql-port=3306
gmysql-dbname=powerdns
gmysql-user=powerdns
gmysql-password=ubuntu
gmysql-dnssec=yes
# gmysql-socket=

Restart

Restart

sudo systemctl restart pdns

Cek

Cek Status

sudo systemctl status pdns.service

Isinya kira-kira

● pdns.service - PowerDNS Authoritative Server
   Loaded: loaded (/lib/systemd/system/pdns.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2019-02-20 04:08:05 UTC; 9s ago
     Docs: man:pdns_server(1)
           man:pdns_control(1)
           https://doc.powerdns.com
 Main PID: 1393 (pdns_server)
    Tasks: 8 (limit: 4664)
   CGroup: /system.slice/pdns.service
          └─1393 /usr/sbin/pdns_server --guardian=no --daemon=no --disable-syslog --log-timestamp=no --write-pid=no

Feb 20 04:08:05 vm pdns_server[1393]: PowerDNS Authoritative Server 4.1.6 (C) 2001-2018 PowerDNS.COM BV
..
..


Cek

sudo netstat -tap | grep pdns

Pastikan siap untuk IPv6 ( [::]:domain ),

tcp        0      0 0.0.0.0:domain          0.0.0.0:*               LISTEN      6676/pdns_server    
tcp6       0      0 [::]:domain             [::]:*                  LISTEN      6676/pdns_server

Pranala Menarik