PowerDNS: Instalasi di Ubuntu 18.04 dengan MySQL

From OnnoWiki
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

Jalankan

sudo curl https://repo.powerdns.com/FD380FBB-pub.asc | sudo apt-key add -
sudo apt update

Instalasi MySQL

sudo su
apt update
apt -y install mysql-server

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

Siapkan Database

sudo mysql -u root -p123456


mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.25-0ubuntu0.18.04.2 (Ubuntu)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> 


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 02:11:35 UTC; 10s ago
     Docs: man:pdns_server(1)
           man:pdns_control(1)
           https://doc.powerdns.com
 Main PID: 6676 (pdns_server)
    Tasks: 8 (limit: 4664)
   CGroup: /system.slice/pdns.service
           └─6676 /usr/sbin/pdns_server --guardian=no --daemon=no --disable-syslog --log-timestamp=no --write-pid=no

Feb 20 02:11:34 vm pdns_server[6676]: 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