2016年5月17日 星期二

在 CentOS7/RHEL7 上安裝設定 Power DNS(一)

  • 事先準備事項:
    • MariaDB 服務設定,請參考這一篇的設定!
    • Httpd 服務設定,請參考這一篇的設定!
    • EPEL 服務設定,請參考這一篇的設定!
快速設定流程:
  1. 安裝相關套件:
    #yum -y install pdns pdns-backend-mysql
    
  2. 設定 MariaDB 內容:
    # mysql -u root -p
    MariaDB [(none)]> CREATE DATABASE powerdns;
    MariaDB [(none)]> GRANT ALL ON powerdns.* TO 'powerdns'@'localhost' IDENTIFIED BY 'powerdns123';
    MariaDB [(none)]> FLUSH PRIVILEGES;
    
    MariaDB [(none)]> USE powerdns;
    MariaDB [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)
                     -> )ENGINE = INNODB, CHARSET=utf8;
    MariaDB [powerdns]> CREATE UNIQUE INDEX name_index ON domains(name);
    
    MariaDB [powerdns]> 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,
                     -> disabled TINYINT(1) DEFAULT 0,
                     -> ordername VARCHAR(255) BINARY DEFAULT NULL,
                     -> auth TINYINT(1) DEFAULT 1,
                     -> primary key(id)
                     -> )ENGINE = INNODB, CHARSET=utf8;
    MariaDB [powerdns]> CREATE INDEX rec_name_index ON records(name);
    MariaDB [powerdns]> CREATE INDEX nametype_index ON records(name,type);
    MariaDB [powerdns]> CREATE INDEX domain_id ON records(domain_id);
    
    MariaDB [powerdns]> CREATE TABLE supermasters (
                     -> ip VARCHAR(25) NOT NULL,
                     -> nameserver VARCHAR(255) NOT NULL,
                     -> account VARCHAR(40) DEFAULT NULL
                     -> )ENGINE = INNODB, CHARSET=utf8;
    
    MariaDB [powerdns]> quit;
    
  3. 編修相關設定檔內容:
    #vim /etc/pdns/pdns.conf
    launch=gmysql
    gmysql-host=localhost
    gmysql-user=powerdns
    gmysql-password=user-pass
    gmysql-dbname=powerdns
    
  4. 開啟防火牆設定:
    #firewall-cmd --permanent --add-service=dns
    #firewall-cmd --permanent --add-service=mysql
    #firewall-cmd --reload
    
  5. 啟動服務:
    # systemctl enable pdns.service 
    # systemctl start pdns.service 
    
  6. 安裝 poweradmin 套件:
    # cd /var/www/html/
    # wget http://downloads.sourceforge.net/project/poweradmin/poweradmin-2.1.7.tgz 
    # tar xfv poweradmin-2.1.7.tgz
    # mv poweradmin-2.1.7 pdns
    
  7. 設定 SELinux 設定:
    #restorecon -R /var/www/html/
    
  8. 開啟設定網頁:
    #firefox http://localhost/pdns/install/