centos:
yum install boost boost-devel cmake lua wget make tar gcc gcc-c++ readline-devel openssl openssl-devel perl perl-devel autoconf bzip2 curl-devel -y
ubuntu/debian:
apt-get install autoconf automake libtool curl make g++ unzip libboost-all-dev -y
安装luaJit:
wget http://luajit.org/download/LuaJIT-2.1.0-beta3.tar.gz
tar -xvf LuaJIT-2.1.0-beta3.tar.gz
cd LuaJIT-2.1.0-beta3/
make && make install
cd ..&&ln -sf luajit-2.1.0-beta3 /usr/local/bin/luajit
下载lua
wget http://www.lua.org/ftp/lua-5.1.4.tar.gz
tar zxvf lua-5.1.4.tar.gz
cd lua-5.1.4
make CFLAGS=-fPIC linux&&make install
cp etc/lua.pc /usr/lib64/pkgconfig/
cp etc/* /usr/include
cd ..
编译安装mysql5.6
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64
安装libmaxminddb
wget https://github.com/maxmind/libmaxminddb/releases/download/1.6.0/libmaxminddb-1.6.0.tar.gz
tar zxf libmaxminddb-1.6.0.tar.gz
cd libmaxminddb-1.6.0
./configure
make -j4&&make install
cd ..
安装cmake3
wget https://github.com/Kitware/CMake/releases/download/v3.22.3/cmake-3.22.3-linux-x86_64.tar.gz
tar zxf cmake-3.22.3-linux-x86_64.tar.gz
mkdir -p /usr/local/cmake
cp -rf cmake-3.22.3-linux-x86_64/* /usr/local/cmake
安装yaml-cpp
wget https://codeload.github.com/jbeder/yaml-cpp/tar.gz/refs/tags/yaml-cpp-0.7.0 -O yaml-cpp-0.7.0.tar.gz
tar zxf yaml-cpp-0.7.0.tar.gz
cd yaml-cpp-yaml-cpp-0.7.0
mkdir -p build
cd build
/usr/local/cmake/bin/cmake -DBUILD_SHARED_LIBS=ON ..
make&&make install
cd ..&&cd ..
ln -s /usr/local/share/cmake/yaml-cpp /usr/lib64/cmake;
ln -s /usr/local/share/pkgconfig/yaml-cpp.pc /usr/lib64/pkgconfig;
ln -s /usr/local/include/yaml-cpp /usr/include;
cp -rf /usr/local/lib64/libyaml-cpp.so.0.7 /usr/lib64;
cp /usr/local/lib64/libyaml-cpp.so.0.7 /usr/local/lib;
创建pdns用户
groupadd pdns
useradd -m -s /sbin/nologin -g pdns pdns
下载编译安装
wget https://downloads.powerdns.com/releases/pdns-4.6.0.tar.bz2
tar jxf pdns-4.6.0.tar.bz2
cd pdns-4.6.0
./configure --prefix=/usr/local/pdns --enable-lua-records --with-modules="bind gmysql geoip" --with-mysql=/usr/local/mysql --enable-verbose-logging
make -j4&&make install
cd ..
mv /usr/local/pdns/etc/pdns.conf-dist /usr/local/pdns/etc/pdns.conf
编辑/usr/local/pdns/etc/pdns.conf文件
配置文件
setuid=pdns
setgid=pdns
local-address=0.0.0.0
local-port=53
tcp-control-port=5300
launch=gmysql,geoip #开启mysql、gepip后端
gmysql-host=localhost
gmysql-port=3306
gmysql-user=pdns
gmysql-password=W123456
gmysql-dbname=pdns
write-pid=yes
zone-cache-refresh-interval=300
zone-metadata-cache-ttl=60
dnssec-key-cache-ttl=30
gmysql-dnssec=yes
daemon=yes
api=yes #开启api
api-key=abdeW225221 #配置api访问密钥
webserver=yes
webserver-address=0.0.0.0
webserver-allow-from=0.0.0.0/0 #api允许访问来源
webserver-port=8081 #api访问端口
config-dir=/usr/local/pdns/etc #指定pdns配置文件目录
enable-lua-records=shared #开启lua-record
geoip-database-files=/etc/geoip/GeoLite2-City.mmdb #指定geoip数据库
创建mysql

mysql -uroot -p123258
create database pdns;
GRANT ALL PRIVILEGES ON pdns.* TO 'pdns'@'localhost' IDENTIFIED BY 'W123456';
flush privileges;
加载mysql数据库进库

mysql -uroot -p123258 pdns < /usr/local/pdns/share/doc/pdns/schema.mysql.sql;
mysql等解释

-- Create the zone example.com
INSERT INTO domains (id, name, type) VALUES (1, 'example.com', 'NATIVE');
INSERT INTO records (domain_id, name, content, type,ttl)
VALUES (1,'example.com','usdns.example.com usdns1.example.com 1 7200 900 1209600 10800','SOA',86400);
INSERT INTO records (domain_id, name, content, type,ttl)
VALUES (1,'example.com','ns1.example.com','NS',86400);
INSERT INTO records (domain_id, name, content, type,ttl)
VALUES (1,'example.com','usdns.example.com','NS',86400);

插入一个A记录
INSERT INTO records (domain_id, name, content, type,ttl)VALUES (1,'www.example.com','1.1.1.1','A',120);
插入一个MX记录
INSERT INTO records VALUES (25, 1, 'example.com', 'MX', 'www.example.com', 3600, 10, 0, NULL, 1);
-- Enable Lua records for the zone (if not enabled globally)
INSERT INTO domainmetadata (domain_id, kind, content)
VALUES (1, 'ENABLE-LUA-RECORDS', 1);
-- Create a pickClosest() Lua A record.
-- Double single quotes are used to escape single quotes in both MySQL and PostgreSQL
INSERT INTO records (domain_id, name, type, content, ttl)
VALUES (
1,
'www.example.com',
'LUA',
'A "pickclosest({''192.0.2.1'',''192.0.2.2'',''198.51.100.1''})"',
600
);
创建域名的DNSSEC
/usr/local/pdns/bin/pdnsutil secure-zone 域名
加入系统启动,创建/lib/systemd/system/pdns.service文件录入以下内容
[Unit]
Description=powerDNS Service
After=syslog.target network.target
[Service]
Type=forking
ExecStart=/usr/local/pdns/sbin/pdns_server --config-dir=/usr/local/pdns/etc
[Install]
WantedBy=multi-user.target
创建软连
ln -s /lib/systemd/system/pdns.service /etc/systemd/system/multi-user.target.wants/pdns
载入启动

systemctl daemon-reload
启动pdns

systemctl start pdns
停止pdns

systemctl stop pdns
加入系统启动

systemctl enable pdns
完成

访问web界面

http://ip:8081

其它:https://doc.powerdns.com/authoritative/lua-records/index.html

分类: powerdns 标签: 暂无标签

评论

暂无评论数据

暂无评论数据

目录