HOWTO install PowerDNS on CentOS

Discussion in 'Linux Networking' started by Rob, Jul 10, 2013.

  1. Rob

    Rob Administrator Staff Member

    Messages:
    575
    Likes Received:
    233
    Trophy Points:
    43
    PowerDNS Authoritative Server is a great choice for handling DNS for your organization. For a successful install (and for this howto in particular) you'll need a Linux server running CentOS. This HOWTO will show you how to get a working pdns nameserver going along with a great web front-end.

    The most common way to set up PowerDNS (pdns) on multiple servers (ns1, ns2, etc...) is to enable MySQL replication from the master (ns1) and the slave(s) (ns2, ns3). That's going to be part 2 of this HOWTO. Let's just get pdns set up on our master and answering queries for now...

    First, let's make sure mysql is installed:

    Code:
    yum install mysql mysql-server -y
    Let's edit the /etc/my.cnf file and make sure that skip-networking is commented out

    Code:
    #skip-networking
    Now make sure it starts when booting into levels 2, 3, 5 and we can start it up


    Code:
    chkconfig --levels 235 mysqld on
    service mysqld start

    Check via netstat that mysql is listening on all interfaces:


    Code:
    netstat -tap |grep "*:mysql"
    tcp 0 0 *:mysql *:* LISTEN 20319/mysqld

    Set the mysql root password (without it showing up in your bash history!)

    Code:
    /usr/bin/mysql_secure_installation
    (follow the prompts/questions)

    Now we're ready to install powerdns:


    Code:
    yum install pdns pdns-backend-mysql
    Connect to mysql, create the database, set the permissions, add some tables for pdns:

    (make sure to replace 'pdns_admin_pass' with something else!)


    Code:
    mysql -u root -p
    CREATE DATABASE powerdns;

    Modify the following two lines with your own password


    Code:
    GRANT ALL ON powerdns.* TO 'pdns_admin'@'localhost' IDENTIFIED BY 'pdns_admin_pass';
    GRANT ALL ON powerdns.* TO 'pdns_admin'@'localhost.localdomain' IDENTIFIED BY 'pdns_admin_pass';

    Feel free to paste the rest of this in all at once


    Code:
    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
    );

    No issues? Ok, quit out..

    Code:
    quit
    Edit /etc/pdns/pdns.conf and tell it how to connect:


    Code:
    launch=gmysql
    gmysql-host=127.0.0.1
    gmysql-user=pdns_admin
    gmysql-password=pdns_admin_password
    gmysql-dbname=powerdns

    Make sure pdns starts on boot & start it up:


    Code:
    chkconfig --levels 235 pdns on
    service pdns start

    This server should now answer on domains its authoritative for. Other domains, however, it has no idea. Let's tell pdns to look at another server for recursion.

    Edit the /etc/pdns/pdns.conf file and modify your recursion lines:

    Code:
    # allow recursion for our subnet only (default allows recursion for everyone)
    allow-recursion=192.168.0.0/24
    # recursion server
    recursor=192.168.0.1

    Web based frontend:

    There are many web based frontends out there for pdns. We're going to use 'PowerDNS-Webinterface' It's a great looking, simple GUI that uses easy templates so that you can make it your own once you're done. Plus, it has multi-user support - create sub-accounts for your users!

    Let's make sure we have some pre-reqs installed:

    Code:
    yum install httpd php php-mysql gettext -y
    Make sure you're running at least PHP 5.2:


    Code:
     php -v
    PHP 5.3.8 (cli) (built: Oct 31 2011 18:26:52)
    Copyright (c) 1997-2011 The PHP Group

    Download the latest powerdns-webinterface package: http://code.google.com/p/powerdns-webinterface/downloads/list

    Unpack it and install:

    Code:
     tar zxvf powerdns-webinterface-1.4.1.tar.gz
    cd powerdns-webinterface
    mysql -u pdns_admin -p powerdns < install.sql
    mv web/* /var/www/html/
    chmod 777 /var/www/html/tmp/templates_c
    vim /var/www/html/configs/db.php
    (enter your db info)

    Login and test it - user: admin pass: admin

    (change that password once you log in please!)

Share This Page