====== FreeBSD 11 PowerDNS and MySQL ======
===== Install PowerDNS Package =====
portsnap fetch
portsnap extract
cd /usr/ports/dns/powerdns
make config # select mysql
export BATCH=yes # otherwise you get prompted for a lot of options
make install # this takes a while
===== Setup MySQL Server =====
==== Find installed MySQL client ====
pkg info | grep mysql | grep client
* In My case I was using client version 5.6
==== Install from Port ====
cd /usr/ports/databases/mysql56-server/
make install
==== Enable MySQL Server ====
echo "mysql_enable=\"YES\"" > /etc/rc.conf
service mysql-server start
==== Set Password ====
mysql_secure_installation # set root password to MYSQLPASSWORD
===== Setup PowerDNS Database =====
==== Create PowerDNS Database ====
mysql -p # enter password you changed from MYSQLPASSWORD
create database powerdns;
quit;
mysql -p powerdns < /usr/local/share/doc/powerdns/schema.mysql.sql # enter password you changed from CHANGEME
===== Set PowerDNS Options =====
* edit /usr/local/etc/pdns/pdns.conf
* The following are the important directives for DNS transfers, MySQL, and the Web Frontend
allow-axfr-ips=127.0.0.0/8 #add your domain ranges to this list, this is a "," separated list
disable-axfr=no
launch=gmysql
gmysql-host=127.0.0.1
gmysql-user=root
gmysql-password=MYSQLPASSWORD
gmysql-dbname=powerdns
api=yes
api-key=APIPASSWORD
webserver=yes
webserver-address=127.0.0.1
webserver-port=8081
===== Enable PowerDNS Startup =====
* add mysql to the REQUIRE line in /usr/local/etc/rc.d/pdns
...
# REQUIRE: DAEMON SERVERS mysql
...
* Enable and start
echo "pdns_enable=\"YES\"" > /etc/rc.conf
service pdns start
===== Install Apache and PHP =====
pkg install mod_php56 php56 php56-curl php56-json php56-openssl php56-session php56-sqlite3 apache24
* Add/create the following to **/usr/local/etc/apache24/php5.conf**
SetHandler application/x-httpd-php
SetHandler application/x-httpd-php-source
DirectoryIndex index.html index.php
* Enable and start apache
echo "apache24_enable=\"YES\"" > /etc/rc.conf
service apache24 start
===== Install and Configure NSedit =====
* download a copy of NSEDIT from [[https://github.com/tuxis-ie/nsedit]]
* Extract to **/usr/local/www/apache24/data**
* make a directory and give www:www full access to it
mkdir -p /usr/local/etc/pdns/web-db
chown -R www:www /usr/local/etc/pdns/web-db
* Edit ./nsedit/includes/config.inc.php and set the following values
$apipass = 'APIPASSWORD';
$apiip = '127.0.0.1';
$apiport = '8081';
$apiproto = 'http';
$authdb = "/usr/local/etc/pdns/web-db/pdns.users.sqlite3";
==== Login to NSEdit ====
* go to http://localhost/nsedit/index.php
* Login with Username: **admin**, password: **admin**
====== Project PKGs ======
{{:freebsd:pkg_pdns_nsedit.tar.bz2|}}
====== Tips ======
===== Refresh Save Zone =====
pdns_control retrieve