How To Install PowerDNS DNS Server on Ubuntu
#howto ,#tutorial #VPS – How To Install PowerDNS DNS Server on Ubuntu – This tutorial explains step by step guide (with pics) about How To Install PowerDNS DNS Server on Ubuntu
PowerDNS is a free DNS server which runs on most Linux systems. It supports different type of backend to store the zone files, from BIND-style text files to relational databases such as MySQL. It also separates authoritative DNS server functions, for hosting domain names, and recursive query functions into two different processes. The article below contains step-by-step instructions on how to install PowerDNS as an authoritative DNS server on servers running Ubuntu operating system, using MySQL database as the backend.
What We Need To Prepare
You will need a physical server or a virtual machine running Ubuntu operating systems. It’s advisable to use the most recent LTS (Long Term Support) versions of Ubuntu, such as Ubuntu 16.04 LTS or Ubuntu 14.04 LTS. Below instructions are based on a virtual machine running Ubuntu 14.04 LTS operating system hosted in SimplerCloud. Since root account was being used, sudo command was omitted on most of the steps. If you are using a non-root user with sudo access on an Ubuntu environment, please append sudo in front of each command (e.g. sudo apt-get update instead of apt-get update).
Patching the Operating System
First step, let’s ensure that the latest Ubuntu operating system’s kernel and patches are installed on the server.
apt-get update apt-get dist-upgrade -y
Reboot the system once done, and run another apt-get dist-upgrade -y command to ensure that there are no more patches need to be installed.
Once we have confirmed that the latest kernel version and patches have been installed, we can then move on to the next step.
Installation of MySQL
PowerDNS require database to store the zone files, although you can also use text files similar to BIND. On this tutorial, we will be using MySQL database as the backend. Before we install PowerDNS, we need to install MySQL server first. Let’s install MySQL by using below command:
apt-get install mysql-server
Type “y” to continue. During the MySQL Server installation, you will be prompted for the MySQL root password. Key in the preferred root password and save the password in a safe place for future use.
Key in the root password again for confirmation.
After MySQL Server is installed, we need to modify the settings to make MySQL listen on all IP addresses and interfaces, rather than just localhost. Use your favourite Linux-based text editor such as vi or nano to open the MySQL configuration file: /etc/mysql/my.cnf.
Look for these lines below:
# Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address = 127.0.0.1
and comment out the “bind-address” line so it will become like this:
# Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. #bind-address = 127.0.0.1
Save the file, and then restart MySQL service for the changes to take effect.
service mysql restart
Installation of PowerDNS
After MySQL is installed, then we can install PowerDNS. There are two packages we need to install: the PowerDNS package itself (pdns-server) and the MySQL backend for PowerDNS (pdns-backend-mysql).
apt-get install pdns-server pdns-backend-mysql
Press “y” to continue. During the installation process, you will be prompted to configure database for pdns-backend-mysql with dbconfig-common. Select “Yes”.
Key in the root password — the one you set on the earlier steps — on the next prompt.
On the next step, you will need to key in a new password, which will be used for pdns-backend-mysql to register with the database server. This can be different from the root password you have set above. Please ensure that you save the password you set in a safe place.
Key in the password again.
Wait until the PowerDNS installation is completed.
Voila! The PowerDNS has been installed.
Creation of PowerDNS Database, User and Tables
Once PowerDNS has been installed, we need to create the database, user and tables required for PowerDNS to run. We need to invoke the MySQL client on the server by running below command:
mysql -u root -p
Key in the MySQL root password you have set on the earlier section of this tutorial.
Next, let us prepare the MySQL commands we will be using to create the PowerDNS database, user, tables and all the necessary privileges. Here are the commands:
CREATE DATABASE powerdns; GRANT ALL ON powerdns.* TO 'powerdnsuser'@'localhost' IDENTIFIED BY 'powerdns-password'; FLUSH PRIVILEGES; USE powerdns; 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) ); CREATE UNIQUE INDEX name_index ON domains(name); 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) ); 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 );
Note that powerdns is the name of the database we will be using. powerdnsuser is the MySQL username we will be using for PowerDNS, while powerdns-password is the password. For security reason, please change the password to a much stronger password.
What you can do is to copy and paste all the above lines into the mysql> prompt. Let us copy and paste per section rather than everything as a whole. Let’s start.
Once after all the tables and indexes have been created, type q to quit the MySQL prompt and go back to the Linux / Ubuntu prompt.
Next, we need to configure PowerDNS to use the MySQL database which we have prepared. Go to /etc/powerdns/pdns.d folder and remove all the existing configuration files we have there. Alternatively, we can move the files to another safe place for backup.
cd /etc/powerdns/pdns.d #go to the /etc/powerdns/pdns.d folder ls -la #check what's inside the folder rm /etc/powerdns/pdns.d/* #remove the existing files on the folder ls -la #verify that the files have been removed
Use your favourite text editor (nano or vi) to create a new /etc/powerdns/pdns.d/pdns.local.gmysql.conf with following content:
# MySQL Configuration # # Launch gmysql backend launch=gmysql # gmysql parameters gmysql-host=localhost gmysql-dbname=powerdns gmysql-user=powerdnsuser gmysql-password=powerdns-password
Save the file, and restart pdns service.
service pdns restart
To verify that the pdns service is running:
service pdns status
And to verify that the PowerDNS DNS server is indeed running on the server, we can use the dig command:
That’s it, PowerDNS DNS server is already running and ready to use.
To use PowerDNS and manage the zone records to be hosted on the DNS server, it’s recommended to use the PowerAdmin web-based control panel for PowerDNS. We shall cover the step-by-step instructions on how to install PowerAdmin on a separate tutorial article.
Disclaimer : This is another great guest post article by Indra Pramana from SimplerCloud.com, a cloud servers provider from Singapore with solutions built from the ground up to provide truly real-time, scalable and easily managed cloud infrastructure for start-ups, developers and business throughout Asia.
This post How To Install PowerDNS DNS Server on Ubuntu is part of ServerMom.