Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| deployment:network:powerdns:install-postgres [2026/02/26 15:08] – ilyasa | deployment:network:powerdns:install-postgres [2026/02/27 20:04] (current) – [Konfigurasi PowerDNS Database Conection] ilyasa | ||
|---|---|---|---|
| Line 21: | Line 21: | ||
| ==== Buat Database & User PostgreSQL ==== | ==== Buat Database & User PostgreSQL ==== | ||
| - | === Masuk sebagai | + | === Buat database dan user: === |
| + | <code sql> | ||
| + | sudo -u postgres | ||
| + | sudo -u postgres psql -c " | ||
| + | </ | ||
| + | |||
| + | === Import schema bawaan PowerDNS: === | ||
| <code bash> | <code bash> | ||
| - | sudo -u postgres psql | + | sudo -u postgres psql -d powerdns -c "SET ROLE pdns;" -f / |
| </ | </ | ||
| - | === Buat database dan user: === | + | |
| + | === Grant Permission to user pdns: === | ||
| <code sql> | <code sql> | ||
| - | CREATE DATABASE | + | sudo -u postgres psql -d powerdns |
| - | CREATE USER pdns WITH PASSWORD ' | + | sudo -u postgres psql -d powerdns -c "GRANT CREATE |
| - | ALTER DATABASE powerdns | + | |
| - | GRANT ALL PRIVILEGES | + | |
| - | \q | + | |
| </ | </ | ||
| + | |||
| + | === Cek tabel sudah dibuat: === | ||
| + | <code bash> | ||
| + | sudo -u postgres psql powerdns -c " | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== Konfigurasi PowerDNS conflict port dengan '' | ||
| + | Sometimes server linux terutama cloud images, menggunakan '' | ||
| + | |||
| + | === Disable systemd-resolved === | ||
| + | < | ||
| + | sudo systemctl disable systemd-resolved --now | ||
| + | </ | ||
| + | |||
| + | hapus stub resolv.conf: | ||
| + | < | ||
| + | sudo rm / | ||
| + | </ | ||
| + | |||
| + | buat manual resolv.conf: | ||
| + | < | ||
| + | sudo nano / | ||
| + | </ | ||
| + | Sesuaikan dengan dns server kalian: | ||
| + | Contoh: | ||
| + | <code bash> | ||
| + | nameserver 8.8.8.8 | ||
| + | nameserver 1.1.1.1 | ||
| + | </ | ||
| + | ==== Konfigurasi PowerDNS Database Conection ==== | ||
| + | |||
| + | |||
| + | === Hapus bind.conf dikarenakan kita menggunakan psql sebagai our backend === | ||
| + | <code bash> | ||
| + | rm / | ||
| + | </ | ||
| + | |||
| + | === Buat konfigurasi powerdns database connetion sesuai dengan database kita === | ||
| + | <code bash> | ||
| + | nano / | ||
| + | </ | ||
| + | <code bash> | ||
| + | launch=gpgsql | ||
| + | gpgsql-host=127.0.0.1 | ||
| + | gpgsql-port=5432 | ||
| + | gpgsql-dbname=powerdns | ||
| + | gpgsql-user=pdns | ||
| + | gpgsql-password=PasswordYangKuat | ||
| + | </ | ||
| + | === Restart Service === | ||
| + | <code bash> | ||
| + | systemctl restart pdns | ||
| + | systemctl enable pdns | ||
| + | systemctl status pdns | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | ==== Testing dengan pembuatan domain ==== | ||
| + | === Install tools === | ||
| + | |||
| + | <code bash> | ||
| + | apt install pdns-tools dnsutils -y | ||
| + | </ | ||
| + | |||
| + | === Buat Zones dengan pdnsutil === | ||
| + | |||
| + | <code bash> | ||
| + | sudo pdnsutil create-zone test.local | ||
| + | </ | ||
| + | |||
| + | === Tambahkan Recods === | ||
| + | |||
| + | <code bash> | ||
| + | # Add SOA record | ||
| + | sudo pdnsutil add-record test.local @ SOA " | ||
| + | |||
| + | # 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 | ||
| + | |||
| + | </ | ||
| + | === Verify Zones === | ||
| + | |||
| + | <code bash> | ||
| + | sudo pdnsutil list-zone test.local | ||
| + | </ | ||
| + | |||
| + | === Check Zones === | ||
| + | |||
| + | <code bash> | ||
| + | sudo pdnsutil check-zone test.local | ||
| + | </ | ||
| + | |||
| + | === 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 | ||
| + | </ | ||
| + | |||