操作系统 / 系统运维

PowerDNS安装部署和使用实践

浅时光 · 10月4日 · 2020年 · · 8614次已读

一、PowerDNS简介

PowerDNS 成立于1990年代后期,是开源DNS软件,服务和支持的主要供应商。2015成为了Open-Xchange的一部分,它可以作为权威与递归DN文章来源(Source):https://www.dqzboy.comS。PowerDNS同时有Win32和Linux/Unix的版本。 PowerDNS在Win32下使用 Access的mdb文件记录DNS信息,而在Linux/Unix下则使用MySQL来记录DNS信息。有强大的web管理端,方便进行DNS配置解析。

二、数据库安装配置

1、安装数据库

[[email protected] ~]# yum install -y mariadb-server
[[email protected] ~]# vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

symbolic-links=0
#更改字符集和禁止主机名解析
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip_name_resolve=on

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
!includedir /etc/my.cnf.d

2、创建数据库

[[email protected] ~]# mysql
MariaDB [(none)]> CREATE DATABASE powerdns;

MariaDB [(none)]> GRANT ALL ON powerdns.* TO 'powerdns'@'localhost' IDENTIFIED BY 'dqz12345678';

MariaDB [(none)]> FLUSH PRIVILEGES;

3、创建数据表

MariaDB [(none)]> use powerdns;
MariaDB [(none)]> 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;

MariaDB [powerdns]> CREATE UNIQUE INDEX name_index ON domains(name);

MariaDB [powerdns]> CREATE TABLE records (
  id                    BIGINT AUTO_INCREMENT,
  domain_id             INT DEFAULT NULL,
  name                  VARCHAR(255) DEFAULT NULL,
  type                  VARCHAR(10) DEFAULT NULL,
  content               VARCHAR(64000) 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;

MariaDB [powerdns]> CREATE INDEX nametype_index ON records(name,type);
MariaDB [powerdns]> CREATE INDEX domain_id ON records(domain_id);
MariaDB [powerdns]> CREATE INDEX recordorder ON records (domain_id, ordername);

MariaDB [powerdns]> CREATE TABLE supermasters (
  ip                    VARCHAR(64) NOT NULL,
  nameserver            VARCHAR(255) NOT NULL,
  account               VARCHAR(40) NOT NULL,
  PRIMARY KEY (ip, nameserver)
) Engine=InnoDB;

MariaDB [powerdns]> CREATE TABLE comments (
  id                    INT AUTO_INCREMENT,
  domain_id             INT NOT NULL,
  name                  VARCHAR(255) NOT NULL,
  type                  VARCHAR(10) NOT NULL,
  modified_at           INT NOT NULL,
  account               VARCHAR(40) NOT NULL,
  comment               VARCHAR(64000) NOT NULL,
  PRIMARY KEY (id)
) Engine=InnoDB;

MariaDB [powerdns]> CREATE INDEX comments_domain_id_idx ON comments (domain_id);
MariaDB [powerdns]> CREATE INDEX comments_name_type_idx ON comments (name, type);
MariaDB [powerdns]> CREATE INDEX comments_order_idx ON comments (domain_id, modified_at);

MariaDB [powerdns]> CREATE TABLE domainmetadata (
  id                    INT AUTO_INCREMENT,
  domain_id             INT NOT NULL,
  kind                  VARCHAR(32),
  content               TEXT,
  PRIMARY KEY (id)
) Engine=InnoDB;

MariaDB [powerdns]> CREATE INDEX domainmetadata_idx ON domainmetadata (domain_id, kind);

MariaDB [powerdns]> CREATE TABLE cryptokeys (
  id                    INT AUTO_INCREMENT,
  domain_id             INT NOT NULL,
  flags                 INT NOT NULL,
  active                BOOL,
  content               TEXT,
  PRIMARY KEY(id)
) Engine=InnoDB;

MariaDB [powerdns]> CREATE INDEX domainidindex ON cryptokeys(domain_id);

MariaDB [powerdns]> CREATE TABLE tsigkeys (
  id                    INT AUTO_INCREMENT,
  name                  VARCHAR(255),
  algorithm             VARCHAR(50),
  secret                VARCHAR(255),
  PRIMARY KEY (id)
) Engine=InnoDB;

MariaDB [powerdns]> CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm);

MariaDB [powerdns]> flush privileges;

#检查所有的表是否创建成功
MariaDB [powerdns]> show tables;
+--------------------+
| Tables_in_powerdns |
+--------------------+
| comments           |
| cryptokeys         |
| domainmetadata     |
| domains            |
| records            |
| supermasters       |
| tsigkeys           |
+--------------------+

#检查是否可以通过powerdns用户登入数据库
[[email protected] ~]# mysql -upowerdns -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 90
Server version: 5.5.65-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
  • 也可以通过下面的方式导入数据表(注意,此方法是你已经先安装了psdb服务)
  • 导入PowerDns所需的表,表文件存储在/usr/share/doc/pdns-bac文章来源(Source):https://www.dqzboy.comkend-mysql-4文章来源(Source):https://www.dqzboy.com.1.11/目录下
mysql> use poweradmin
Database changed
mysql> source /usr/share/doc/pdns-backend-mysql-4.1.11/schema.mysql.sql
mysql> show tables;
+----------------------+
| Tables_in_poweradmin |
+----------------------+
| comments             |
| cryptokeys           |
| domainmetadata       |
| domains              |
| records              |
| supermasters         |
| tsigkeys             |
+----------------------+
7 rows in set (0.00 sec)

三、安装配置PowerDNS

1、安装PowerDNS

[[email protected] ~]# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

[[email protected] ~]# rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

[[email protected] ~]# yum clean all 
[[email protected] ~]# yum makecache
[[email protected] ~]# yum install -y pdns pdns-backend-mysql

2、修文章来源(Source):https://www.dqzboy.com改配置文件

[[email protected] ~]# vim /etc/pdns/pdns.conf
#配置文件最后添加即可
launch=gmysql
gmysql-host=localhost
gmysql-port=3306
gmysql-dbname=powerdns
gmysql-user=powerdns
gmysql-password=dqz12345678

3、启动PowerDNS

[[email protected] ~]# systemctl enable pdns.service
Created symlink from /etc/systemd/system/multi-user.target.wants/pdns.service to /usr/lib/systemd/system/pdns.service.
[[email protected] ~]# systemctl start pdns.service

四、安装poweradmin

1、安装程序所需包

[[email protected] ~]# yum -y install httpd php php-devel php-gd php-mcrypt php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mhash gettext

2、文章来源(Source):https://www.dqzboy.com启动Apache服务

[[email protected] ~]# systemctl start httpd.service
[[email protected] ~]# systemctl enable httpd.service
[[email protected] ~]# firewall-cmd --permanent --zone=public --add-port=80/tcp
[[email protected] ~]# firewall-cmd --reload

3、下载powerad文章来源(Source):https://www.dqzboy.commin

[[email protected] ~]# cd /var/www/html/
[[email protected] ~]# wget http://downloads.sourceforge.net/project/poweradmin/poweradmin-2.1.7.tgz
[[email protected] html]# tar -xf poweradmin-2.1.7.tar.gz
[[email protected] html]# mv poweradmin-2.1.7 dns

4、安装Poweradmin

PowerDNS安装部署和使用实践-浅时光博客
PowerDNS安装部署和使用实践-浅时光博客
PowerDNS安装部署和使用实践-浅时光博客
PowerDNS安装部署和使用实践-浅时光博客
文章来源(Source):https://www.dqzboy.com
PowerDNS安装部署和使用实践-浅时光博客
  • 注意:用root权限的账号去创建该用户
PowerDNS安装部署和使用实践-浅时光博客
[[email protected] ~]# cd /var/www/html/dns/inc/
[[email protected] inc]# cp config-me.inc.php config.inc.php
[[email protected] inc]# echo "" > config.inc.ph
[[email protected] inc]# vim config.inc.ph
<?php

$db_host                = 'localhost';
$db_user                = 'poweradmin';
$db_pass                = 'dqz12345678';
$db_name                = 'powerdns';
$db_type                = 'mysql';
$db_layer               = 'PDO';

$session_key            = 'D(xeksG{J(r~gQmVnN)lM(ulin32P--WBvJQk1*+cQIKFy';

$iface_lang             = 'en_EN';

$dns_hostmaster         = '';
$dns_ns1                = '192.168.66.113';
$dns_ns2                = '192.168.66.113'
PowerDNS安装部署和使用实践-浅时光博客

5、删除安装目录

[[email protected] ~]# rm -rf /var/www/html/dns/install

五、登入访问和使用

1、登入访问

PowerDNS安装部署和使用实践-浅时光博客
PowerDNS安装部署和使用实践-浅时光博客
PowerDNS安装部署和使用实践-浅时光博客

2、添加主域

PowerDNS安装部署和使用实践-浅时光博客
PowerDNS安装部署和使用实践-浅时光博客
PowerDNS安装部署和使用实践-浅时光博客
PowerDNS安装部署和使用实践-浅时光博客
PowerDNS安装部署和使用实践-浅时光博客

3、验证测试

#安装dig命令,115的机器上配置dns解析地址
[[email protected] ~]# yum install bind-utils

[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens
DNS1=192.168.66.113

[[email protected] ~]# systemctl restart network

[[email protected] ~]# dig abc.dqzboy.cn
  • 自己的PC电脑的网卡也需要添加该DNS服务器地址才能通过浏览器访问文章来源(Source):https://www.dqzboy.com
PowerDNS安装部署和使用实践-浅时光博客
PowerDNS安装部署和使用实践-浅时光博客
0 条回应
    本站已安全运行: | 耗时 0.742 秒 | 查询 112 次 | 内存 20.07 MB