powerdns如何进行缓存_【网络】PowerDNS的安装和使用:1.安装

9464ce18ba15f73b6ba56faa46f93755.png

不得不说BIND作为DNS服务器是很稳的,那么,今天我们来倒腾下另外一个PowerDNS,先上个项目地址:

https://github.com/PowerDNS/pdns​github.com

文档地址:

Installing PowerDNS​doc.powerdns.com

安装:

yum install epel-release yum-plugin-priorities &&
curl -o /etc/yum.repos.d/powerdns-auth-44.repo https://repo.powerdns.com/repo-files/centos-auth-44.repo &&
yum install pdns
yum -y install pdns-backend*  #后端全装上

简简单单几步搞定

安装管理工具Poweradmin(看了下工具非常老,最近一次更新应该也是在五年前了,建议pdns 4.2.x 及以上的版本就不要安装了):

http://www.poweradmin.org/​www.poweradmin.org
下载后解压
tar xvf poweradmin-2.1.7.tgz 
cd poweradmin-2.1.7

yum -y install httpd
systemctl enable httpd
systemctl start httpd

cp -a * /var/www/html/
yum -y install httpd php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mhash gettext  
yum install php-pear-DB php-pear-MDB2-Driver-mysql  #必须要装不然连不上数据库
service httpd restart

浏览器访问这台服务器,显示以下内容,表示管理工具安装完成,使用x.x.x.x/install按照提示进行安装即可,这里,不做深入介绍:

98efcb38e0b4a3b6fb3e666b38e69d38.png

接下来继续安装pdns:

安装数据库
yum -y install mariadb mariadb-server
systemctl enable mariadb
systemctl start mariadb

创建数据库pdns,
create database pdns;

参考https://doc.powerdns.com/authoritative/guides/basic-database.html
将https://github.com/PowerDNS/pdns/blob/rel/auth-4.2.x/modules/gmysqlbackend/schema.mysql.sql导入到数据库

授权
grant all privileges on pdns.* to 'admin'@'localhost' identified by 'Abcd1234';


修改/etc/pdns/pdns.conf ,
"# launch Which backends to launch and order to query them in" 这一行下面改成:

launch=gmysql
gmysql-host=127.0.0.1
gmysql-user=admin
gmysql-password=Abcd1234
gmysql-dbname=pdns

最后,启动pdns服务:

systemctl enable pdns
systemctl start pdns
#4.4.x版本可能会有报错,提示无法读取/etc/pdns/pdns.conf,直接修改了pdns权限即可启动

我们按照官方文档进行了下试验,进入mysql pdns数据库,插入以下内容:

INSERT INTO domains (name, type) values ('example.com', 'NATIVE');
INSERT INTO records (domain_id, name, content, type,ttl,prio)
VALUES (1,'example.com','localhost admin.example.com 1 10380 3600 604800 3600','SOA',86400,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
VALUES (1,'example.com','dns-us1.powerdns.net','NS',86400,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
VALUES (1,'example.com','dns-eu1.powerdns.net','NS',86400,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
VALUES (1,'www.example.com','192.0.2.10','A',120,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
VALUES (1,'mail.example.com','192.0.2.12','A',120,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
VALUES (1,'localhost.example.com','127.0.0.1','A',120,NULL);
INSERT INTO records (domain_id, name, content, type,ttl,prio)
VALUES (1,'example.com','mail.example.com','MX',120,25);

插入完成后,尝试dig,dns功能成功。

ae15cfc3c8e171a613587ab1e5fcdf46.png

上面的数据库语句展示了如何通过数据库来新增解析记录,我们还可以通过命令行的方式进行添加,比如添加http://mail1.example.com解析地址为10.10.10.10,命令如下:

pdnsutil add-record example.com mail1 A 600 10.10.10.10
对应的删除可以使用pdnsutil delete-rrset ZONE NAME
添加或删除后即刻生效
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值