Powerdns Install
Jump to navigation
Jump to search
https://www.howtoforge.com/how-to-install-powerdns-admin-on-ubuntu-20-04/
https://doc.powerdns.com/authoritative/guides/basic-database.html
sudo -i -u postgres psql -c "CREATE ROLE pdns WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD 'pdns'" sudo -i -u postgres createdb -O pdns pdns sudo psql -U pdns -W -h 127.0.0.1 pdns < /usr/share/pdns-backend-pgsql/schema/schema.pgsql.sql sudo psql -U pdns -W -h 127.0.0.1 pdns < /root/luadns.sql cp -p /usr/share/doc/pdns-backend-pgsql/examples/pdns.local.gpgsql.conf /etc/powerdns/pdns.d/
/etc/powerdns/pdns.d/pdns.local.gpgsql.conf
# PostgreSQL Configuration # # Launch gpgsql backend launch+=gpgsql # gpgsql parameters gpgsql-host=127.0.0.1 gpgsql-port=5432 gpgsql-dbname=pdns gpgsql-user=pdns gpgsql-password=pdns gpgsql-dnssec=yes
/etc/powerdns/pdns.conf
enable-lua-records=yes
sql
mysql> INSERT INTO domains (name, type) values ('example.com', 'NATIVE'); INSERT INTO records (domain_id, name, content, type,ttl,prio) VALUES (1,'example.com','localhost admin.example.com 1 10380 3600 604800 3600','SOA',86400,NULL); INSERT INTO records (domain_id, name, content, type,ttl,prio) VALUES (1,'example.com','dns-us1.powerdns.net','NS',86400,NULL); INSERT INTO records (domain_id, name, content, type,ttl,prio) VALUES (1,'example.com','dns-eu1.powerdns.net','NS',86400,NULL); INSERT INTO records (domain_id, name, content, type,ttl,prio) VALUES (1,'www.example.com','192.0.2.10','A',120,NULL); INSERT INTO records (domain_id, name, content, type,ttl,prio) VALUES (1,'mail.example.com','192.0.2.12','A',120,NULL); INSERT INTO records (domain_id, name, content, type,ttl,prio) VALUES (1,'localhost.example.com','127.0.0.1','A',120,NULL); INSERT INTO records (domain_id, name, content, type,ttl,prio) VALUES (1,'example.com','mail.example.com','MX',120,25);
lua sql https://doc.powerdns.com/authoritative/lua-records/index.html
INSERT INTO domains (id, name, type) VALUES (1, 'example.com', 'NATIVE'); -- Enable Lua records for the zone (if not enabled globally) INSERT INTO domainmetadata (domain_id, kind, content) VALUES (1, 'ENABLE-LUA-RECORDS', 1); -- Create a pickClosest() Lua A record. -- Double single quotes are used to escape single quotes in both MySQL and PostgreSQL INSERT INTO records (domain_id, name, type, content, ttl) VALUES ( 1, 'pickclosest.example.com', 'LUA', 'A "pickclosest({''192.0.2.1'',''192.0.2.2'',''198.51.100.1''})"', 600 ); INSERT INTO records (domain_id, name, type, content, ttl) VALUES ( 1, 'ifurlup.example.com', 'LUA', 'A "ifurlup(''https://www.uvoo.io/'', {''x.x.x.z'', ''x.x.x.y''})"', 600 );
Fail site in bash
ipaddr=x.x.x.y iptables -I OUTPUT -o eth0 -p tcp --destination-port 443 -d $ipaddr -j DROP curl -k --header "Host: www.uvoo.io" https://$ipaddr/
test
$ dig +short www.example.com @127.0.0.1 192.0.2.10 $ dig +short example.com MX @127.0.0.1 25 mail.example.com
db test
psql -U pdns -h 127.0.0.1 -W pdns