Domain name server (DNS) is a machine that hold information about domains and its address. It maintain IP address information of domain and can be translate to hostname. PowerDNS is a freely available high performance DNS server program runs on Linux machine. It read information from backend database and support Bind. In this tutorial we are going to process of installing PowerDNS using MariaDB as a database backend and Power admin to manage DNS server under linux ubuntu 14.04.
The architecture of DNS server we plan to install can be draw below. PowerDNS is use database (MariaDB) to store domain information and power admin as a interface for administrator to manage domain record information.
Prepare Ubuntu Machine
We are need root access for the rest of installation process or at least sudo-er privilege. It is always a good step to update the linux system to the latest release before install any software.
- apt-get update && apt-get upgrade -y
Wait until update process is complete.
So, Why is MariaDB ? Well, it is free. Why is not MySQL ? Many people concern about the plan to keep MySQL alive. MariaDB in other hand is a fork of MySQL, developed by MySQL developer and some other advantages are not cover in this article. Checking properties common
- sudo apt-get install software-properties-common
Property Common checking
- sudo apt-key adv –recv-keys –keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
Adding MariaDB to repository
- sudo add-apt-repository ‘deb [arch=amd64,i386,ppc64el] http://mirror.lstn.net/mariadb/repo/5.5/ubuntu trusty main’
Reload database package. Install MariaDB with apt-get.
sudo apt-get update
sudo apt-get install mariadb-server
Hardening and Configure MariaDB Installation
Some security concern came with initial install. We need to close these holes with following steps, but first we want to create directory structure and start MariaDB.
sudo service mysql start
Run wizard to hardening MariaDB installation.
Disallow root login remotely? Yes
Remove test database and access to it? Yes
Reload privilege tables now? Yes
Add PowerDNS User in MariaDB
PowerDNS use database to store domain information. All domain record, ip addresses, hostname and such will be store in database and refer when request. Access newly install MariaDB database.
mysql -u root -p
enter MariaDB root password
- CREATE DATABASE powerdns;
Create a new database user for powerdns database call ‘powerdnsusr’ with password ‘userpass’. Please choose your own password by replace ‘userpass’ with your own choice.
- GRANT ALL ON powerdns.* TO ‘powerdnsusr’@‘localhost’ IDENTIFIED BY ‘userpass’;
Update user setting
- FLUSH PRIVILEGES;
Create a table call ‘domains’
- CREATE TABLE domains ( id INT auto_increment, name VARCHAR(255) NOT NULL, master VARCHAR(128) DEFAULT NULL, last_check INT DEFAULT NULL, type VARCHAR(6) NOT NULL, notified_serial INT DEFAULT NULL, account VARCHAR(40) DEFAULT NULL, primary key (id) );
Set table domain ‘name’ as a index.
- CREATE UNIQUE INDEX name_index ON domains(name);
** Next Step, Create another table call ‘record’ **
- CREATE TABLE records ( id INT auto_increment, domain_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, type VARCHAR(6) DEFAULT NULL, content VARCHAR(255) DEFAULT NULL, ttl INT DEFAULT NULL, prio INT DEFAULT NULL, change_date INT DEFAULT NULL, primary key(id) );
Set indexes on table record.
- CREATE INDEX rec_name_index ON records(name); CREATE INDEX nametype_index ON records(name,type); CREATE INDEX domain_id ON records(domain_id);
- CREATE TABLE supermasters ( ip VARCHAR(25) NOT NULL, nameserver VARCHAR(255) NOT NULL, account VARCHAR(40) DEFAULT NULL );
This is the last table. Now, we can exit database and back to linux prompt.
Since we have dabatase and tables created, we continue to install PowerDNS. Run following command to install powerdns.
- sudo apt-get install pdns-server pdns-backend-mysql
Set PowerDNS Configuration
Before we use powerDNS, We need to set some configuration. Browse to PowerDNS configuration location.
- $cd /etc/powerdns/pdns.d
- $ls -al
- $rm *
Next step, We would like to connect PowerDNS with database by editing configuration file pdns.local.gmysql.conf.
- $cd /etc/powerdns/pdns.d/
- $sudo nano pdns.local.gmysql.conf
A new file will be created. Insert line below, save and exit.
### MySQL Configuration file - launch=gmysql - gmysql-host=localhost - gmysql-port=3306 - gmysql-dbname=powerdns - gmysql-user=powerdnsusr - gmysql-password=userpass
Testing powerDNS listening from terminal.
- netstat -tap
You should see something like …LISTEN ….. pdns_server-in.