본문으로 바로가기

PowerDNS 설치 [ 여기를 참고 ]

□ PowerDNS 3.X  [ 버전의 내용입니다. 이하 버전은 설정이 다를수 있습니다. ]


PowerDNS 4.X ↑ [ 설명 추가 ]


■ Logging [ PowerDNS 3.X ] 경우


PowerDNS 설치후 기본적으로 로그가 쌓이지 않게 되어있습니다. 로그설정을 위해 유닉스(리눅스) syslog 를 이용합니다.

CentOS 를 설치하였다면 기본적으로 경로 [ /etc/rsyslog.conf 또는 /etc/syslog.conf ] 에 설정파일이 존재합니다. 

만약 설치되어있지 않다면 다음과 같이 설치를 진행합니다.

BASH

[root@localhost ~]# yum install rsyslog

.

Package rsyslog-7.4.7-16.el7.x86_64 already installed and latest version

Nothing to do (이미 설치되어있을경우 PASS)


PowerDNS 로깅을 위해 먼저 다음과 같이 설정 [ logging-facility=0 ]

BASH

[root@localhost ~]# vi /etc/pdns/pdns.conf


################################# # logging-facility Log under a specific facility # logging-facility=0


################################# # experimental-logfile Filename of the log file for JSON parser # experimental-logfile=/var/log/pdns.log


:wq (저장)


Syslog 설정 

local0.info 일반적인 로그 및 질의등을 확인할수 있으며, 

local0.err 는 pdns 관련 중요한 메시지를 저장하기 때문에 꼭 아래 두개를 같이 등록합니다.

BASH

[root@localhost ~]# vi /etc/rsyslog.conf


#### RULES ####

.

.


(추가)

# PowerDNS log local0.info /var/log/pdns.info local0.err /var/log/pdns.err



:wq (저장)


적용을 위해 Pdns / Syslog 서비스 재시작

BASH

[root@localhost ~]# service pdns restart

Redirecting to /bin/systemctl restart pdns.service


[root@localhost ~]# service rsyslog restart

Redirecting to /bin/systemctl restart rsyslog.service


로그파일 생성 확인 [ /var/log ]

BASH

[root@localhost ~]# ls -al /var/log | grep pdns

-rw------- 1 root root 430 4??30 12:52 pdns.err -rw------- 1 root root 2436 4??30 12:52 pdns.info


□ Logging 확인

BASH

[root@localhost ~]# tail -f /var/log/pdns.info


( Pdns 데몬 구동했을시 로그 )

Apr 30 12:52:22 localhost pdns[26234]: This is a standalone pdns Apr 30 12:52:22 localhost pdns[26234]: Listening on controlsocket in '/var/run/pdns.controlsocket' Apr 30 12:52:22 localhost pdns[26234]: UDP server bound to 0.0.0.0:53 Apr 30 12:52:22 localhost pdns[26234]: TCP server bound to 0.0.0.0:53 Apr 30 12:52:22 localhost pdns[26234]: PowerDNS Authoritative Server 3.4.11 (jenkins@autotest.powerdns.com) (C) 2001-2016 PowerDNS.COM BV Apr 30 12:52:22 localhost pdns[26234]: Using 64-bits mode. Built on 20170116223245 by mockbuild@buildhw-05.phx2.fedoraproject.org, gcc 4.8.5 20150623 (Red Hat 4.8.5-11). Apr 30 12:52:22 localhost pdns[26234]: PowerDNS comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it according to the terms of the GPL version 2. Apr 30 12:52:22 localhost pdns[26234]: Creating backend connection for TCP Apr 30 12:52:22 localhost pdns[26234]: About to create 3 backend threads for UDP Apr 30 12:52:23 localhost pdns[26234]: Done launching threads, ready to distribute questions


[root@localhost ~]# tail -f /var/log/pdns.err

Apr 30 12:49:52 localhost pdns[26192]: UDP server bound to 0.0.0.0:53 Apr 30 12:49:52 localhost pdns[26192]: TCP server bound to 0.0.0.0:53 Apr 30 12:49:52 localhost pdns[26192]: Creating backend connection for TCP



■ Logging [ PowerDNS 4.X ] 경우

PowerDNS 4.X 경우는 위와 같이 해도 syslog 전달이 되지않아 로그파일이 생성되지 않는데요... 

다음과 같이 데몬 구동을 확인해보면 그 이유를 알수 있습니다.

BASH

[root@localhost ~]# ps -ef |grep pdns

pdns 2459 1 0 16:01 ? 00:00:00 /usr/sbin/pdns_server --guardian=no --daemon=no --disable-syslog --write-pid=no root 2474 2078 0 16:03 pts/1 00:00:00 grep --color=auto pdns

처음 데몬을 구동할때 [ --disable-syslog ] 작동안되도록 기본 옵션으로 들어가있습니다.

구동될때 해당 옵션이 들어가지 않도록 systemctl 등록되어있는 pdns 서비스 파일을 수정할 필요가 있습니다.


→ 다음과 같이 진행

BASH

[root@localhost ~]# vi /usr/lib/systemd/system/pdns.service


[Unit] Description=PowerDNS Authoritative Server Documentation=man:pdns_server(1) man:pdns_control(1) Documentation=https://doc.powerdns.com Wants=network-online.target After=network-online.target mysqld.service postgresql.service slapd.service mariadb.service [Service] Type=notify ExecStart=/usr/sbin/pdns_server --guardian=no --daemon=no --disable-syslog(삭제) --write-pid=no

(이렇게 설정 : ExecStart=/usr/sbin/pdns_server --guardian=no --daemon=no --write-pid=no ) Restart=on-failure RestartSec=1 StartLimitInterval=0 PrivateTmp=true PrivateDevices=true CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_SETGID CAP_SETUID CAP_CHOWN CAP_SYS_CHROOT NoNewPrivileges=true # ProtectSystem=full will disallow write access to /etc and /usr, possibly # not being able to write slaved-zones into sqlite3 or zonefiles. ProtectSystem=full ProtectHome=true RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 [Install] WantedBy=multi-user.target


:wq (저장)


적용을 위해 systemctl 리로드 후에 pdns 데몬 재시작

BASH

[root@localhost ~]# systemctl daemon-reload


[root@localhost ~]# service pdns restart

[root@localhost ~]# ps -ef |grep pdns

pdns 2516 1 0 16:09 ? 00:00:00 /usr/sbin/pdns_server --guardian=no --daemon=no --write-pid=no root 2530 2078 0 16:10 pts/1 00:00:00 grep --color=auto pdns


--disable-syslog (옵션이 빠진걸 확인할수 있습니다)

이후부터 정상적으로 LOCAL SYSLOG 전달을 하게 됩니다.


나머지는 동일

BASH

[root@localhost ~]# vi /etc/pdns/pdns.conf


################################# # logging-facility Log under a specific facility # logging-facility=0


:wq (저장)

BASH

[root@localhost ~]# vi /etc/rsyslog.conf


#### RULES ####

.

.


(추가)

# PowerDNS log local0.info /var/log/pdns.info local0.err /var/log/pdns.err



:wq (저장)

BASH

[root@localhost ~]# service pdns restart

Redirecting to /bin/systemctl restart pdns.service


[root@localhost ~]# service rsyslog restart

Redirecting to /bin/systemctl restart rsyslog.service

BASH

[root@localhost ~]# ls -al /var/log | grep pdns

-rw------- 1 root root 430 4??30 12:52 pdns.err -rw------- 1 root root 2436 4??30 12:52 pdns.info


□ Logging 확인

BASH

[root@localhost ~]# tail -f /var/log/pdns.info


( Pdns 데몬 구동했을시 로그 )

Apr 30 16:14:07 localhost pdns[2578]: Reading random entropy from '/dev/urandom' Apr 30 16:14:07 localhost pdns[2578]: Loading '/usr/lib64/pdns/libgmysqlbackend.so' Apr 30 16:14:07 localhost pdns[2578]: This is a standalone pdns Apr 30 16:14:07 localhost pdns[2578]: Listening on controlsocket in '/var/run/pdns.controlsocket' Apr 30 16:14:07 localhost pdns[2578]: UDP server bound to 0.0.0.0:53 Apr 30 16:14:07 localhost pdns[2578]: UDPv6 server bound to [::]:53 Apr 30 16:14:07 localhost pdns[2578]: TCP server bound to 0.0.0.0:53 Apr 30 16:14:07 localhost pdns[2578]: TCPv6 server bound to [::]:53 Apr 30 16:14:07 localhost pdns[2578]: PowerDNS Authoritative Server 4.0.3 (C) 2001-2016 PowerDNS.COM BV Apr 30 16:14:07 localhost pdns[2578]: Using 64-bits mode. Built using gcc 4.8.5 20150623 (Red Hat 4.8.5-4) on Jan 17 2017 08:55:46 by buildbot@c17f0608c0cd. Apr 30 16:14:07 localhost pdns[2578]: PowerDNS comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it according to the terms of the GPL version 2. Apr 30 16:14:07 localhost pdns[2578]: Polled security status of version 4.0.3 at startup, no known issues reported: OK Apr 30 16:14:07 localhost pdns[2578]: Creating backend connection for TCP Apr 30 16:14:07 localhost pdns[2578]: About to create 3 backend threads for UDP Apr 30 16:14:08 localhost pdns[2578]: Done launching threads, ready to distribute questions


[root@localhost ~]# tail -f /var/log/pdns.err

Apr 30 16:14:07 localhost pdns[2578]: UDP server bound to 0.0.0.0:53 Apr 30 16:14:07 localhost pdns[2578]: UDPv6 server bound to [::]:53 Apr 30 16:14:07 localhost pdns[2578]: TCP server bound to 0.0.0.0:53 Apr 30 16:14:07 localhost pdns[2578]: TCPv6 server bound to [::]:53 Apr 30 16:14:07 localhost pdns[2578]: Creating backend connection for TCP



■ DNS query (질의) 로그


네임서버 도메인 질의를 했을 때 남는 쿼리 로그는 다음 옵션을 적용합니다.

BASH

[root@localhost ~]# vi /etc/pdns/pdns.conf


################################# # query-logging Hint backends that queries should be logged # query-logging=yes


:wq (저장)


질의해보기

BASH

[root@localhost ~]# dig @localhost test.com


; <<>> DiG 9.9.4-RedHat-9.9.4-38.el7_3.3 <<>> @localhost test.com SOA ; (2 servers found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7023 ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 1680 ;; QUESTION SECTION: ;test.com. IN SOA ;; ANSWER SECTION: test.com. 86400 IN SOA ns1.testdns.com. testdns. 2017043001 28800 7200 604800 86400 ;; Query time: 6 msec ;; SERVER: ::1#53(::1) ;; WHEN: ?? 4??30 17:41:31 KST 2017 ;; MSG SIZE rcvd: 92


쿼리로그

BASH

[root@localhost ~]# tail -f /var/log/pdns.info


Apr 30 17:10:52 localhost pdns[3207]: Query: SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type=? and name=? Apr 30 17:10:52 localhost pdns[3207]: Query: SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and name=? and domain_id=? Apr 30 17:34:23 localhost pdns[3207]: Query: SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type=? and name=? Apr 30 17:34:23 localhost pdns[3207]: Query: SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and name=? and domain_id=?


테스트서버라 로컬에서만 확인을 하다보니 위와같이 ? 나오지만 실서버를 적용하였다면 도메인이나 쿼리 응답정보가 나옵니다.

참고하시기 바랍니다.


댓글을 달아 주세요