deployment:network:powerdns:install-postgres

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
deployment:network:powerdns:install-postgres [2026/02/26 14:49] – created ilyasadeployment:network:powerdns:install-postgres [2026/02/27 01:28] (current) – [Konfigurasi PowerDNS Database Conection] ilyasa
Line 1: Line 1:
 +{{indexmenu_n>001}}
 ====== PowerDNS : Installasi dengan posgresSQL Backend (Debian 12/13) ====== ====== PowerDNS : Installasi dengan posgresSQL Backend (Debian 12/13) ======
  
-==== Install  ====+==== Install Paket ==== 
 + 
 +=== Update repository: === 
 +<code bash> 
 +apt update 
 +</code> 
 + 
 +=== Install PowerDNS Authoritative + PostgreSQL: === 
 +<code bash> 
 +apt install pdns-server pdns-backend-pgsql postgresql 
 +</code> 
 + 
 +=== Pastikan service PostgreSQL berjalan: === 
 +<code bash> 
 +systemctl status postgresql 
 +</code> 
 + 
 +==== Buat Database & User PostgreSQL ==== 
 + 
 +=== Buat database dan user: === 
 +<code sql> 
 +sudo -u postgres psql <<EOF 
 +CREATE DATABASE powerdns; 
 +CREATE USER pdns WITH PASSWORD 'passwordku'; 
 +ALTER DATABASE powerdns OWNER TO pdns; 
 +GRANT ALL PRIVILEGES ON DATABASE powerdns TO pdns; 
 +EOF 
 +</code> 
 + 
 +=== Import schema bawaan PowerDNS: === 
 +<code bash> 
 +sudo -u postgres psql powerdns < /usr/share/pdns-backend-pgsql/schema/schema.pgsql.sql 
 +</code> 
 + 
 + 
 +=== Grant Permission to user pdns: === 
 +<code sql> 
 +sudo -u postgres psql powerdns <<EOF 
 +GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO pdns; 
 +GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO pdns; 
 +GRANT ALL PRIVILEGES ON SCHEMA public TO pdns; 
 +ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON TABLES TO pdns; 
 +ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON SEQUENCES TO pdns; 
 +EOF 
 +</code> 
 + 
 +=== Cek tabel sudah dibuat: === 
 +<code bash> 
 +sudo -u postgres psql powerdns -c "\dt" 
 +</code> 
 + 
 + 
 +==== Konfigurasi PowerDNS conflict port dengan ''systemd-resolved'' ==== 
 +Sometimes server linux terutama cloud images, menggunakan ''systemd-resolved'' yang menggunakan port 53 secara default. Kita ingin mendisable hal berikut untuk dapat digunakan PowerDNS Nanti. 
 + 
 +=== Disable systemd-resolved === 
 +<code> 
 +sudo systemctl disable systemd-resolved --now 
 +</code> 
 + 
 +hapus stub resolv.conf: 
 +<code> 
 +sudo rm /etc/resolv.conf 
 +</code> 
 + 
 +buat manual resolv.conf: 
 +<code> 
 +sudo nano /etc/resolv.conf 
 +</code> 
 +Sesuaikan dengan dns server kalian: 
 +Contoh: 
 +<code bash> 
 +nameserver 8.8.8.8 
 +nameserver 1.1.1.1 
 +</code> 
 +==== Konfigurasi PowerDNS Database Conection ==== 
 + 
 + 
 +=== Hapus bind.conf dikarenakan kita menggunakan psql sebagai our backend === 
 +<code bash> 
 +rm /etc/powerdns/pdns.d/bind.conf 
 +</code> 
 + 
 +=== Buat konfigurasi powerdns database connetion sesuai dengan database kita === 
 +<code bash> 
 +nano /etc/powerdns/pdns.d/gpgsql.conf 
 +</code> 
 +<code bash> 
 +launch=gpgsql 
 +gpgsql-host=127.0.0.1 
 +gpgsql-port=5432 
 +gpgsql-dbname=powerdns 
 +gpgsql-user=pdns 
 +gpgsql-password=passwordku 
 +</code> 
 +=== Restart Service === 
 +<code bash> 
 +systemctl restart pdns 
 +systemctl enable pdns 
 +systemctl status pdns 
 +</code> 
 + 
 + 
 +{{indexmenu_n>001}} 
 +====== PowerDNS : Installasi dengan posgresSQL Backend (Debian 12/13) ====== 
 + 
 +==== Install Paket ==== 
 + 
 +=== Update repository: === 
 +<code bash> 
 +apt update 
 +</code> 
 + 
 +=== Install PowerDNS Authoritative + PostgreSQL: === 
 +<code bash> 
 +apt install pdns-server pdns-backend-pgsql postgresql 
 +</code> 
 + 
 +=== Pastikan service PostgreSQL berjalan: === 
 +<code bash> 
 +systemctl status postgresql 
 +</code> 
 + 
 +==== Buat Database & User PostgreSQL ==== 
 + 
 +=== Buat database dan user: === 
 +<code sql> 
 +sudo -u postgres psql <<EOF 
 +CREATE DATABASE powerdns; 
 +CREATE USER pdns WITH PASSWORD 'passwordku'; 
 +ALTER DATABASE powerdns OWNER TO pdns; 
 +GRANT ALL PRIVILEGES ON DATABASE powerdns TO pdns; 
 +EOF 
 +</code> 
 + 
 +=== Import schema bawaan PowerDNS: === 
 +<code bash> 
 +sudo -u postgres psql powerdns < /usr/share/pdns-backend-pgsql/schema/schema.pgsql.sql 
 +</code> 
 + 
 + 
 +=== Grant Permission to user pdns: === 
 +<code sql> 
 +sudo -u postgres psql powerdns <<EOF 
 +GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO pdns; 
 +GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO pdns; 
 +GRANT ALL PRIVILEGES ON SCHEMA public TO pdns; 
 +ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON TABLES TO pdns; 
 +ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON SEQUENCES TO pdns; 
 +EOF 
 +</code> 
 + 
 +=== Cek tabel sudah dibuat: === 
 +<code bash> 
 +sudo -u postgres psql powerdns -c "\dt" 
 +</code> 
 + 
 + 
 +==== Konfigurasi PowerDNS conflict port dengan ''systemd-resolved'' ==== 
 +Sometimes server linux terutama cloud images, menggunakan ''systemd-resolved'' yang menggunakan port 53 secara default. Kita ingin mendisable hal berikut untuk dapat digunakan PowerDNS Nanti. 
 + 
 +=== Disable systemd-resolved === 
 +<code> 
 +sudo systemctl disable systemd-resolved --now 
 +</code> 
 + 
 +hapus stub resolv.conf: 
 +<code> 
 +sudo rm /etc/resolv.conf 
 +</code> 
 + 
 +buat manual resolv.conf: 
 +<code> 
 +sudo nano /etc/resolv.conf 
 +</code> 
 +Sesuaikan dengan dns server kalian: 
 +Contoh: 
 +<code bash> 
 +nameserver 8.8.8.8 
 +nameserver 1.1.1.1 
 +</code> 
 +==== Konfigurasi PowerDNS Database Conection ==== 
 + 
 + 
 +=== Hapus bind.conf dikarenakan kita menggunakan psql sebagai our backend === 
 +<code bash> 
 +rm /etc/powerdns/pdns.d/bind.conf 
 +</code> 
 + 
 +=== Buat konfigurasi powerdns database connetion sesuai dengan database kita === 
 +<code bash> 
 +nano /etc/powerdns/pdns.d/gpgsql.conf 
 +</code> 
 +<code bash> 
 +launch=gpgsql 
 +gpgsql-host=127.0.0.1 
 +gpgsql-port=5432 
 +gpgsql-dbname=powerdns 
 +gpgsql-user=pdns 
 +gpgsql-password=passwordku 
 +</code> 
 +=== Restart Service === 
 +<code bash> 
 +systemctl restart pdns 
 +systemctl enable pdns 
 +systemctl status pdns 
 +</code> 
 + 
 +==== Testing dengan pembuatan domain ==== 
 +=== Install tools === 
 + 
 +<code bash> 
 +apt install pdns-tools dnsutils -y 
 +</code> 
 + 
 +=== Buat Zones dengan pdnsutil === 
 + 
 +<code bash> 
 +sudo pdnsutil create-zone test.local 
 +</code> 
 + 
 +=== Tambahkan Recods === 
 + 
 +<code bash> 
 +# Add SOA record 
 +sudo pdnsutil add-record test.local @ SOA "ns1.test.local. admin.test.local. 1 3600 900 604800 300" 
 + 
 +# Add NS record 
 +sudo pdnsutil add-record test.local @ NS ns1.test.local 
 + 
 +# Add A record for nameserver 
 +sudo pdnsutil add-record test.local ns1 A 192.168.1.1 
 + 
 +# Add A record for test host 
 +sudo pdnsutil add-record test.local www A 192.168.1.10 
 + 
 +</code> 
 +=== Verify Zones === 
 + 
 +<code bash> 
 +sudo pdnsutil list-zone test.local 
 +</code> 
 + 
 +=== Check Zones === 
 + 
 +<code bash> 
 +sudo pdnsutil check-zone test.local 
 +</code> 
 + 
 +=== Test DNS Query === 
 + 
 +<code bash> 
 +# Query your PowerDNS server directly 
 +dig @127.0.0.1 www.test.local A 
 +dig @127.0.0.1 test.local NS 
 +dig @127.0.0.1 test.local SOA 
 +</code> 
 + 
  
  • deployment/network/powerdns/install-postgres.1772092180.txt.gz
  • Last modified: 2026/02/26 14:49
  • by ilyasa