首页 小组 文章 搜索 用户
全部 linux Nginx Apache PHP DNS windows 其它 同步与备份 js 数据库 前端 unix

centos7下编译安装powerdns最新版本及配合mysql使用

天边的云
发表于 2020-10-10 16:36:38

先开启一下防火墙

firewall-cmd --add-port=53/tcp --permanent
firewall-cmd --add-port=53/udp --permanent
firewall-cmd --reload

yum下安装powerdns不是最新版本,所以我们自己安装最新版本

yum update -y
yum -y install wget gcc gcc-c++ bzip2 autoconf automake make lua-devel openssl openssl-devel boost-devel 

安装mysql教程:https://www.osyum.com/article/show/246/,并把root密码设置为osyum123258

安装一下mysql客户端插件,否则powerdns会报错

yum install mysql-devel -y

下载并安装powerdns

wget https://downloads.powerdns.com/releases/pdns-4.3.1.tar.bz2
tar jxf pdns-4.3.1.tar.bz2
cd pdns-4.3.1
chmod +x ./configure
./configure --prefix=/usr/local/powerdns --enable-verbose-logging --enable-static-binaries --enable-pdns_server --enable-nedmalloc --with-mysql=/usr --with-libcurl  --disable-lua-records
make&&make install

配置powerdns配置文件

创建一个pdns的用户和组,指定运行powerdns这样更加安全

groupadd pdns
useradd -m -s /sbin/nologin -g pdns pdns

把pdns.conf-dist重命名pdns.conf

cd /usr/local/powerdns/etc
mv pdns.conf-dist pdns.conf

修改/usr/local/powerdns/etc/pdns.conf里的setgid和setuid,在其下面直接加上

setgid=pdns
setuid=pdns

给pdns目录权限让其能运行

chown -R pdns:pdns /usr/local/powerdns

进入mysql,创建一个pdns的用户名和数据库密码为W123456,并给用记为pdns的用户pdns数据库所有权限。

mysql -uroot -posyum123258
create database pdns;
GRANT ALL PRIVILEGES ON pdns.* TO 'pdns'@'%' IDENTIFIED BY 'W123456';
flush privileges;

给pdns用户数据库写入数据

use pdns;
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 UNSIGNED DEFAULT NULL,
account VARCHAR(40) CHARACTER SET 'utf8' DEFAULT NULL,
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';

CREATE UNIQUE INDEX name_index ON domains(name);


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 CHARACTER SET 'latin1';

CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);
CREATE INDEX ordername ON records (ordername);


CREATE TABLE supermasters (
ip VARCHAR(64) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) CHARACTER SET 'utf8' NOT NULL,
PRIMARY KEY (ip, nameserver)
) Engine=InnoDB CHARACTER SET 'latin1';


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) CHARACTER SET 'utf8' DEFAULT NULL,
comment TEXT CHARACTER SET 'utf8' NOT NULL,
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';

CREATE INDEX comments_name_type_idx ON comments (name, type);
CREATE INDEX comments_order_idx ON comments (domain_id, modified_at);


CREATE TABLE domainmetadata (
id INT AUTO_INCREMENT,
domain_id INT NOT NULL,
kind VARCHAR(32),
content TEXT,
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';

CREATE INDEX domainmetadata_idx ON domainmetadata (domain_id, kind);


CREATE TABLE cryptokeys (
id INT AUTO_INCREMENT,
domain_id INT NOT NULL,
flags INT NOT NULL,
active BOOL,
published BOOL DEFAULT 1,
content TEXT,
PRIMARY KEY(id)
) Engine=InnoDB CHARACTER SET 'latin1';

CREATE INDEX domainidindex ON cryptokeys(domain_id);


CREATE TABLE tsigkeys (
id INT AUTO_INCREMENT,
name VARCHAR(255),
algorithm VARCHAR(50),
secret VARCHAR(255),
PRIMARY KEY (id)
) Engine=InnoDB CHARACTER SET 'latin1';

CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm);
ALTER TABLE records ADD CONSTRAINT `records_domain_id_ibfk` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE comments ADD CONSTRAINT `comments_domain_id_ibfk` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE domainmetadata ADD CONSTRAINT `domainmetadata_domain_id_ibfk` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE cryptokeys ADD CONSTRAINT `cryptokeys_domain_id_ibfk` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

修改/usr/local/powerdns/etc/pdns.conf

在#launch=下添加

launch=gmysql
gmysql-host=127.0.0.1
gmysql-user=pdns
gmysql-password=W123456
gmysql-dbname=pdns


启动方法

/usr/local/powerdns/sbin/pdns_server --config-dir=/usr/local/powerdns/etc


https://github.com/Spacefish/powerdns-webinterface







199 0

评论