DNS server PowerDNS – více instancí

DNS server PowerDNS – více instancí

apt-get install -y pdns-server pdns-backend-mysql

Configure database for pdns-backend-mysql with dbconfig-common? Ne

Smazat konfiguraci (vytvoříme novou):

rm -r /etc/powerdns/*

 

mkdir /etc/powerdns/internal && mkdir /etc/powerdns/external

Oficiální PDNS má conf soubory rozdělené, preferuji mít vše v jednom souboru.

vi /etc/powerdns/internal/pdns.conf

config-dir=/etc/powerdns/internal
daemon=yes
guardian=yes
local-port=53
setgid=pdns
setuid=pdns
log-dns-queries=yes
loglevel=6
launch=gmysql
gmysql-host=10.1.2.3
gmysql-dbname=powerdns_internal
gmysql-user=powerdns
gmysql-password=some_password
recursor=10.255.255.10:53
allow-recursion=10.0.0.0/8

vi /etc/powerdns/external/pdns.conf

config-dir=/etc/powerdns/external
daemon=yes
guardian=yes
local-port=54
setgid=pdns
setuid=pdns
master=yes
slave=no
disable-axfr=no
allow-axfr-ips=217.30.72.224/32 212.80.80.90/32
log-dns-queries=yes
loglevel=6
launch=gmysql
gmysql-host=10.1.2.3
gmysql-dbname=powerdns_external
gmysql-user=powerdns
gmysql-password=some_password
allow-recursion=127.0.0.1/32

 

Upravit init.d pro spouštění obou služeb

cp /etc/init.d/pdns /etc/init.d/pdns-internal
mv /etc/init.d/pdns /etc/init.d/pdns-external
sed -i '0,/^NAME=/s/NAME=.*/NAME=pdns-internal/' /etc/init.d/pdns-internal
sed -i '0,/^NAME=/s/NAME=.*/NAME=pdns-external/' /etc/init.d/pdns-external

sed -i '0,/^# Provides:/s/pdns.*/pdns-internal/' /etc/init.d/pdns-internal
sed -i '0,/^# Provides:/s/pdns.*/pdns-external/' /etc/init.d/pdns-external

cp /lib/systemd/system/pdns.service /lib/systemd/system/pdns-internal.service
mv /lib/systemd/system/pdns.service /lib/systemd/system/pdns-external.service

sed -i '0,/^Description=/s/Description=.*/Description=PowerDNS - Internal view/' /lib/systemd/system/pdns-internal.service
sed -i '0,/^Description=/s/Description=.*/Description=PowerDNS - External view/' /lib/systemd/system/pdns-external.service

sed -i '0,/^ExecStart=/s/ExecStart=.*/ExecStart=\/usr\/sbin\/pdns_server --daemon=no --config-dir=\/etc\/powerdns\/internal --socket-dir=\/var\/run\/pdns-internal/' /lib/systemd/system/pdns-internal.service
sed -i '0,/^ExecStart=/s/ExecStart=.*/ExecStart=\/usr\/sbin\/pdns_server --daemon=no --config-dir=\/etc\/powerdns\/external --socket-dir=\/var\/run\/pdns-external/' /lib/systemd/system/pdns-external.service

sed -i '0,/^ExecStop=/s/ExecStop=.*/ExecStop=\/usr\/bin\/pdns_control --config-dir=\/etc\/powerdns\/internal --socket-dir=\/var\/run\/pdns-internal quit/' /lib/systemd/system/pdns-internal.service
sed -i '0,/^ExecStop=/s/ExecStop=.*/ExecStop=\/usr\/bin\/pdns_control --config-dir=\/etc\/powerdns\/external --socket-dir=\/var\/run\/pdns-external quit/' /lib/systemd/system/pdns-external.service

update-rc.d pdns-internal defaults
update-rc.d pdns-external defaults
systemctl enable pdns-internal.service
systemctl enable pdns-external.service
systemctl disable pdns
Restartovat počítač nebo:
service pdns stop
service pdns-internal start
service pdns-external start