Package: pdns-protobuf-receiver
PowerDNS protobuf receiverThepdns_protobuf_receiveris a daemon in Python 3 that acts a protobuf server for PowerDNS's products. You can use it to collect DNS queries and responses and to log to syslog or a json remote tcp collector.Table of contentsInstallationExecute receiverStartup optionsOutput JSON formatPowerDNS configurationAboutInstallationPyPIFrom pypi, deploy thepdns_protobuf_receiverwith the pip command.
Only Python3 is supported.pipinstallpdns-protobuf-receiverAfter installation, you will havepdns_protobuf_receiverbinary availableDocker HubPull the pdns-protobuf-receiver image from Docker Hub.dockerpulldmachard/pdns-protobuf-receiver:latestDeploy the containerdockerrun-d-p50001:50001--name=pdns-pb01dmachard/pdns-protobuf-receiverFollow containers logsdockerlogspdns-pb01-fExecute receiverThe receiver is listening by default on the 0.0.0.0 interface and 50001 tcp portIf you want to print DNS queries and responses to stdout in JSON format, then execute thepdns_protobufreceiver as below:# pdns_protobuf_receiver -v
2020-05-29 18:39:08,579 Start pdns protobuf receiver...
2020-05-29 18:39:08,580 Using selector: EpollSelectorIf you want to resend protobuf message to your remote tcp collector
Start the pdns_protobuf receiver as below:# pdns_protobuf_receiver -j 10.0.0.235:6000 -v
2020-05-29 18:39:08,579 Start pdns protobuf receiver...
2020-05-29 18:39:08,580 Using selector: EpollSelector
2020-05-29 18:39:08,580 Connecting to 10.0.0.235 6000
2020-05-29 18:39:08,585 Connected to 10.0.0.235 6000Startup optionsCommand line options are:usage: -c [-h] [-l L] [-j J] [-v]

optional arguments:
  -h, --help  show this help message and exit
  -l L        listen protobuf dns message on tcp/ip address <ip:port>
  -j J        write JSON payload to tcp/ip address <ip:port>
  -v          verbose modeJSON log formatEach events generated by thepdns_protbufreceiver will have the following format:{"dns_message":"AUTH_QUERY","socket_family":"IPv6","socket protocol":"UDP","from_address":"0.0.0.0","to_address":"184.26.161.130","query_time":"2020-05-29 13:46:23.322","response_time":"1970-01-01 01:00:00.000","latency":0,"query_type":"A","query_name":"a13-130.akagtm.org.","return_code":"NOERROR","bytes":4}Keys description:dns_message: PDNS message type (CLIENT_QUERY, CLIENT_RESPONSE, ...)socket_family: IP protocol used (IPv4 or IPv6)socket_protocol: transport protocol used (UDP or TCP)from_address: the querier IP addressto_address: the destination IP addressquery_time: time of query receptionresponse_time: time of response receptionlatency: difference between query and response timequery_type: the query type (A, AAAA, NS, ...)query_name: the query namereturn_code: the response code sent back to the client (NXDOMAIN, NOERROR, ...)bytes: size in bytes of the query or responsePowerDNS configurationYou need to configure dnsdist or pdns-recursor to active remote logging.dnsdistConfigure the dnsdist/etc/dnsdist/dnsdist.confand add the following lines
Set the newRemoteLogger function with the address of your pdns_protobuf_receiver
instance.rl = newRemoteLogger("10.0.0.97:50001")
addAction(AllRule(),RemoteLogAction(rl))
addResponseAction(AllRule(),RemoteLogResponseAction(rl))Restart dnsdist.pdns-recursorConfigure the powerdns recursor/etc/pdns-recursor/recursor.confand add the following linelua-config-file=/etc/pdns-recursor/recursor.luaCreate the LUA file/etc/pdns-recursor/recursor.luaSet the protobufServer or outgoingProtobufServer functions with the address of your pdns_protobuf receiver instance.protobufServer("10.0.0.97:50001", {logQueries=true,
                                   logResponses=true,
                                   exportTypes={'A', 'AAAA',
                                                'CNAME', 'MX', 
                                                'PTR', 'NS',
                                                'SPF', 'SRV',
                                                'TXT'}} )
outgoingProtobufServer("10.0.0.97:50001",  {logQueries=true,
                                            logResponses=true,
                                            exportTypes={'A', 'AAAA',
                                                         'CNAME', 'MX',
                                                         'PTR', 'NS',
                                                         'SPF', 'SRV',
                                                         'TXT'}})Restart the recursor.AboutAuthorDenis Machardd.machard@gmail.comPyPIhttps://pypi.org/project/pdns-protobuf-receiver/Githubhttps://github.com/dmachard/pdns-protobuf-receiverDockerHubhttps://hub.docker.com/r/dmachard/pdns-protobuf-receiver