2022-05-20 21:18:17 +02:00
|
|
|
---
|
|
|
|
title: PowerDNS
|
2022-11-19 15:25:20 +01:00
|
|
|
visible: true
|
2022-06-28 14:33:35 +02:00
|
|
|
media_order: powerdns-admin-api-settings.png
|
2022-05-20 21:18:17 +02:00
|
|
|
---
|
|
|
|
|
2022-06-06 18:36:33 +02:00
|
|
|
[toc]
|
2023-02-23 14:48:51 +01:00
|
|
|
|
2022-05-20 21:18:17 +02:00
|
|
|
## Installation
|
2023-02-23 14:48:51 +01:00
|
|
|
|
2023-05-26 16:07:27 +02:00
|
|
|
### Debian
|
|
|
|
|
2022-05-20 21:18:17 +02:00
|
|
|
For the autoriative server install this package
|
|
|
|
`# apt install pdns-server`
|
|
|
|
This is the PowerDNS resolver package
|
2023-02-23 14:48:51 +01:00
|
|
|
`# apt install pdns-recursor`
|
2022-05-20 21:18:17 +02:00
|
|
|
|
2023-05-26 16:07:27 +02:00
|
|
|
PowerDNS offers different backends, which are packaged separately on Debian.
|
|
|
|
|
|
|
|
**Mysql Backend**
|
|
|
|
|
|
|
|
```sh
|
2023-05-26 18:22:29 +02:00
|
|
|
sudo apt install pdns-backend-mysql mariadb-server
|
2023-05-26 16:07:27 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
**PostgreSQL Backend**
|
|
|
|
|
|
|
|
```sh
|
|
|
|
sudo apt install pdns-backend-pgsql postgresql
|
|
|
|
```
|
|
|
|
|
|
|
|
## Authoritative Server
|
|
|
|
|
|
|
|
> [List of all available backends](https://doc.powerdns.com/authoritative/backends/index.html)
|
|
|
|
|
|
|
|
### PostgreSQL Backend
|
|
|
|
|
|
|
|
Edit the configuration file in `/etc/powerdns/pdns.conf`
|
|
|
|
|
|
|
|
```
|
|
|
|
...
|
|
|
|
launch=gpgsql
|
|
|
|
...
|
|
|
|
gpgsql-host=127.0.0.1
|
|
|
|
gpgsql-port=5432
|
|
|
|
gpgsql-dbname=pdns
|
|
|
|
gpgsql-user=<user>
|
|
|
|
gpgsql-password=<password>
|
|
|
|
gpgsql-dnssec=yes
|
|
|
|
```
|
|
|
|
|
|
|
|
Prepare database
|
|
|
|
|
|
|
|
```sh
|
|
|
|
sudo -u postgres psql
|
|
|
|
```
|
|
|
|
|
|
|
|
```sql
|
|
|
|
CREATE DATABASE pdns;
|
|
|
|
CREATE USER <user> WITH ENCRYPTED PASSWORD '<password>';
|
|
|
|
GRANT ALL PRIVILEGES ON DATABASE pdns TO powerdns;
|
|
|
|
```
|
|
|
|
|
|
|
|
Import the schema utilised by PowerDNS. This can be done with the user you just created
|
|
|
|
Do note the `-h` parameter is required unless `pg_hba.conf` has been modified to password based authentication locally as well.
|
2023-02-23 14:48:51 +01:00
|
|
|
|
2023-05-26 16:07:27 +02:00
|
|
|
```sh
|
|
|
|
psql -U <user> -d <database> -h 127.0.0.1 -f /usr/share/pdns-backend-pgsql/schema/schema.pgsql.sql
|
|
|
|
```
|
|
|
|
|
|
|
|
```sh
|
|
|
|
systemctl restart pdns
|
|
|
|
```
|
2022-05-20 21:18:17 +02:00
|
|
|
|
2023-05-26 16:07:27 +02:00
|
|
|
### MySQL Backend
|
2023-02-23 14:48:51 +01:00
|
|
|
|
2022-05-20 21:18:17 +02:00
|
|
|
Set the backend you chose in the `launch=` option of PowerDNS' configuration file.
|
2023-02-23 14:48:51 +01:00
|
|
|
The config can be found under `/etc/powerdns/pdns.conf`
|
2022-05-20 21:18:17 +02:00
|
|
|
|
2023-02-23 14:48:51 +01:00
|
|
|
For MySQL I chose `launch=gmysql`
|
|
|
|
|
|
|
|
> A [list of backends can be found here](https://doc.powerdns.com/authoritative/backends/index.html)
|
|
|
|
|
|
|
|
Add the following parameters below `launch=gmysql`
|
2022-05-20 21:18:17 +02:00
|
|
|
|
|
|
|
```
|
|
|
|
gmysql-host=127.0.0.1
|
|
|
|
gmysql-socket=/run/mysqld/mysqld.sock
|
|
|
|
gmysql-user=(user)
|
|
|
|
gmysql-password=(password)
|
|
|
|
gmysql-dbname=pdns
|
|
|
|
# Add this for dnssec support
|
|
|
|
gmysql-dnssec=yes
|
|
|
|
```
|
|
|
|
|
2023-02-23 14:48:51 +01:00
|
|
|
Prepare database
|
2022-05-20 21:18:17 +02:00
|
|
|
|
2023-02-23 14:48:51 +01:00
|
|
|
```sh
|
|
|
|
mariadb -u root -p
|
|
|
|
```
|
2022-05-20 21:18:17 +02:00
|
|
|
|
2023-02-23 14:48:51 +01:00
|
|
|
```sql
|
|
|
|
CREATE DATABASE pdns;
|
|
|
|
GRANT ALL ON pdns.* TO 'pdns'@'localhost' IDENTIFIED BY '<password>';
|
|
|
|
```
|
2022-05-20 21:18:17 +02:00
|
|
|
|
2023-02-23 14:48:51 +01:00
|
|
|
Import the schema utilised by PowerDNS. This can be done with the user you just created
|
2022-05-20 21:18:17 +02:00
|
|
|
|
2023-02-23 14:48:51 +01:00
|
|
|
```sh
|
|
|
|
mysql -u pdns -p pdns < /usr/share/doc/pdns-backend-mysql/schema.mysql.sql
|
|
|
|
```
|
|
|
|
|
|
|
|
```sh
|
|
|
|
systemctl restart pdns
|
|
|
|
```
|
2022-05-20 21:18:17 +02:00
|
|
|
|
2023-05-26 16:07:27 +02:00
|
|
|
## PowerDNS CLI
|
2023-02-23 14:48:51 +01:00
|
|
|
|
2022-05-20 21:18:17 +02:00
|
|
|
Create Zone and add a name server
|
2023-02-23 14:48:51 +01:00
|
|
|
`# pdnsutil create-zone (domain) ns1.(domain)`
|
2022-05-20 21:18:17 +02:00
|
|
|
|
|
|
|
Add "A"-Record. **Mind the (.) after the domain**
|
|
|
|
"Name" is the hostname you wish to assign.
|
2023-02-23 14:48:51 +01:00
|
|
|
`# pdnsutil add-record (domain). (name) A (ip address)`
|
2022-05-20 21:18:17 +02:00
|
|
|
|
2023-05-26 16:07:27 +02:00
|
|
|
## Dynamic DNS
|
2023-02-23 14:48:51 +01:00
|
|
|
|
|
|
|
`# apt install bind9utils`
|
2022-05-20 21:18:17 +02:00
|
|
|
|
|
|
|
Generate key
|
2023-02-23 14:48:51 +01:00
|
|
|
`# dnssec-keygen -a hmac-md5 -b 128 -n USER (keyname)`
|
2022-05-20 21:18:17 +02:00
|
|
|
|
2023-02-23 14:48:51 +01:00
|
|
|
Edit the configuration file and change `dnsupdate=no` to `dnsupdate=yes` and set `allow-dnsupdate-from=` to empty.
|
2022-05-20 21:18:17 +02:00
|
|
|
|
|
|
|
Allow updates from your DHCP server
|
|
|
|
`# pdnsutil set-meta (domain) ALLOW-DNSUPDATE-FROM (dhcp server ip)`
|
|
|
|
If you set up a reverse-zone, also allow that
|
2023-02-23 14:48:51 +01:00
|
|
|
`# pdnsutil set-meta (reverse ip).in-addr.arpa ALLOW-DNSUPDATE-FROM (dhcp server ip)`
|
2022-05-20 21:18:17 +02:00
|
|
|
|
|
|
|
Import the key
|
|
|
|
`# pdnsutil import-tsig-key (keyname) hmac-md5 (key)`
|
|
|
|
Enable for domain
|
|
|
|
`# pdnsutil set-meta (domain) TSIG-ALLOW-DNSUPDATE (keyname)`
|
|
|
|
And for reverse-zone
|
2023-02-23 14:48:51 +01:00
|
|
|
`# pdnsutil set-meta (reverse ip).in-addr.arpa TSIG-ALLOW-DNSUPDATE (keyname)`
|
2022-05-20 21:18:17 +02:00
|
|
|
|
2023-02-23 14:48:51 +01:00
|
|
|
You also have to configure the DHCP server to provide updates, see [the DHCP article](https://wiki.realstickman.net/en/linux/services/dhcp-server)
|
2022-05-20 21:18:17 +02:00
|
|
|
|
2023-05-26 16:07:27 +02:00
|
|
|
### Testing with nsupdate
|
2023-02-23 14:48:51 +01:00
|
|
|
|
|
|
|
`# nsupdate -k Kdhcpdupdate.+157+12673.key`
|
|
|
|
|
2022-05-20 21:18:17 +02:00
|
|
|
```
|
|
|
|
> server 127.0.0.1 5300
|
|
|
|
> zone testpdns
|
|
|
|
> update add test.testpdns 3600 A 192.168.7.10
|
|
|
|
> send
|
|
|
|
```
|
|
|
|
|
|
|
|
## Configuration Recursive Resolver
|
2023-02-23 14:48:51 +01:00
|
|
|
|
2022-05-20 21:18:17 +02:00
|
|
|
The config file can be found under `/etc/powerdns/recursor.conf`
|
2023-02-23 14:48:51 +01:00
|
|
|
In `/etc/powerdns/pdns.conf` set `local-address=127.0.0.1` and `local-port=5300` to allow the recursor to run on port 53
|
2022-05-20 21:18:17 +02:00
|
|
|
In `/etc/powerdns/recursor.conf` set `forward-zones=(domain)=127.0.0.1:5300` to forward queries for that domain to the authoritative DNS
|
|
|
|
Also set `local-address` and `allow-from`
|
2023-02-23 14:48:51 +01:00
|
|
|
To bind to all interfaces, use `local-address=::,0.0.0.0`
|
2022-05-20 21:18:17 +02:00
|
|
|
|
|
|
|
### Wipe Cache
|
2023-02-23 14:48:51 +01:00
|
|
|
|
|
|
|
`# rec_control wipe-cache $`
|
2022-05-20 21:18:17 +02:00
|
|
|
|
|
|
|
## DNSSEC
|
2023-02-23 14:48:51 +01:00
|
|
|
|
2022-05-20 21:18:17 +02:00
|
|
|
### Authoritative Server
|
|
|
|
|
2023-02-23 14:48:51 +01:00
|
|
|
> https://doc.powerdns.com/authoritative/dnssec/index.html
|
2022-05-20 21:18:17 +02:00
|
|
|
|
|
|
|
### Recursor Server
|
2023-02-23 14:48:51 +01:00
|
|
|
|
|
|
|
To fully enable DNSSEC, set `dnssec=process-no-validate` to `dnssec=validate`
|
2022-05-20 21:18:17 +02:00
|
|
|
|
|
|
|
To allow a domain without DNSSEC, modify `/etc/powerdns/recursor.lua`
|
2023-02-23 14:48:51 +01:00
|
|
|
Add `addNTA('(domain)')` to disable DNSSEC for the selected domain.
|
2022-05-20 21:18:17 +02:00
|
|
|
|
|
|
|
Show domains with disabled DNSSEC
|
2023-02-23 14:48:51 +01:00
|
|
|
`# rec_control get-ntas`
|
2022-05-20 21:18:17 +02:00
|
|
|
|
|
|
|
> [DNSSEC Testing](https://wiki.debian.org/DNSSEC#Test_DNSSEC)
|
|
|
|
|
|
|
|
## WebGUI
|
2023-02-23 14:48:51 +01:00
|
|
|
|
2022-05-20 21:18:17 +02:00
|
|
|
### PowerDNS-Admin
|
2023-02-23 14:48:51 +01:00
|
|
|
|
|
|
|
```sh
|
2023-05-26 16:07:27 +02:00
|
|
|
sudo mkdir /etc/powerdns-admin
|
2022-05-20 21:18:17 +02:00
|
|
|
```
|
2023-02-23 14:48:51 +01:00
|
|
|
|
|
|
|
```sh
|
2023-05-26 16:07:27 +02:00
|
|
|
sudo podman run -d \
|
2022-05-20 21:18:17 +02:00
|
|
|
--name powerdns-admin \
|
2023-05-26 16:07:27 +02:00
|
|
|
-e SECRET_KEY='<key>' \
|
|
|
|
-v /etc/powerdns-admin:/data \
|
|
|
|
-p 9191:80 \
|
|
|
|
docker.io/powerdnsadmin/pda-legacy:latest
|
2022-05-20 21:18:17 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
#### Enabling API
|
2023-02-23 14:48:51 +01:00
|
|
|
|
|
|
|
A few settings in `/etc/powerdns/pdns.conf` need to be changed.
|
|
|
|
|
|
|
|
```
|
2022-05-20 21:18:17 +02:00
|
|
|
api=yes
|
2023-05-26 16:07:27 +02:00
|
|
|
api-key=<key>
|
2022-05-20 21:18:17 +02:00
|
|
|
webserver=yes
|
|
|
|
```
|
|
|
|
|
|
|
|
Following this, the API access can be configured in the webgui
|
2023-02-23 14:48:51 +01:00
|
|
|
![Configuration options in PowerDNS Admin](powerdns-admin-api-settings.png)
|
2022-05-20 21:18:17 +02:00
|
|
|
|
2023-02-23 14:48:51 +01:00
|
|
|
Now you should see all your configured Domains and be able to modify records
|