dnscache Log File FormatThese notes are incomplete.
dnscacheis part of thedjbdnspackage, written by Daniel J. Bernstein, aka djb. I couldn't find any documentation on its log file format, other than this explanation of one field of thestatslog entry. This file contains my notes on what the log entries mean. If there are any errors here, they are mine and not djb's.
dnscachelogs IP addresses as 8 digit hexadecimal strings. For example, 127.0.0.1 is logged as 7f000001.
dnscachelogs UDP ports and query IDs as 4 digit hexadecimal strings.
dnscachelogs all time intervals (including TTLs) as decimal strings, in units of seconds.
dnscachelogs record types numerically. For a list of record types, see RFC 1700, page 79. The common ones are 1 = A, 12 = PTR, and 15 = MX.RFC 1035 specifies the implementation of DNS.
You can find some programs for analyzing
dnscachelogs at http://www.fibrespeed.net/~mbabcock/code/.Log entry types:
cached type namecached cname name cnamecached ns control servercached nxdomain namedrop serial errorlame serverip name controlnodata serverip ttl type namenxdomain serverip ttl namequery serial clientip:clientport:id type namerr serverip ttl type name datarr serverip ttl cname name cnamerr serverip ttl mx name preference exchangerrr serverip ttl ns name serverrr serverip ttl ptr name pnamerr serverip ttl soa server email serial refresh retry expire minimumsent serial lengthservfail name errorstartingstats query-count cache-motion udp-active tcp-activetcpopen clientip:clientporttcpclose clientip:clientport errortx gluelessness type name control serverips...
dnscacheneeds some records and found them in the cache. It may have needed the records because the client requested them, or it may have needed the addresses of a name server in order to look up some other records.The actual cached data is not recorded with this log entry. The cached data may include several records, but
dnscachemakes only one log entry.
Field Meaning typeThe type of records needed. nameThe domain name for which records were needed.
dnscachefound the answer to a client query in its cache, and the answer was a CNAME record. In this case,dnscachestarts over, looking for the same record type but with the "canonical name".
Field Meaning nameThe domain name for which the client wants records. cnameThe "canonical name" for name. meaning thatnameshould be treated as an alias forcname.
dnscacheneeded to know the authoritative nameservers for some domain, and found a set of nameservers for the domain, or some ancestor of it, in the cache.dnscachecreates one log entry for each nameserver in the set. The actual name for whichdnscacheneeded to find nameservers is on thequerylog entry preceding the set ofcached nslog entries.For example:
query 673 7f000001:09b6:7c48 1 www.windows.com. cached ns com. a.root-servers.net. cached ns com. e.gtld-servers.net. cached ns com. f.gtld-servers.net. cached ns com. j.gtld-servers.net. cached ns com. k.gtld-servers.net. cached ns com. a.gtld-servers.net. cached ns com. m.gtld-servers.net. cached ns com. g.gtld-servers.net. cached ns com. c.gtld-servers.net. cached ns com. i.gtld-servers.net. cached ns com. b.gtld-servers.net. cached ns com. d.gtld-servers.net.
dnscacheneeded to know the authoritative nameservers forwww.windows.com, and the nearest set of nameservers in its cache was the set of nameservers that are authoritative forcom.
Field Meaning controlThe domain name for which serveris authoritative.serverThe name of a server that is authoritative for control.
dnscacheneeded to find records fornameand found a cachednxdomainentry in the cache.
Field Meaning nameThe domain name for which records were requested.
dnscachedecided not to try to respond to a client query.
Field Meaning serialThe serial number of the client request. See queryfor an explanation of client request serial numbers.errorThe reason dnscachedropped the request:
timed outdnscachehad MAXUDP (200) active UDP queries and received another UDP query. It dropped the oldest active query.permission denieddnscachereceived an AXFR request.permission denieddnscachereceived an AXFR request.out of memorydnscachecould not allocate memory for parsing a query packet or building a response.- XXX more errors...
dnscachefound a lame delegation. This means that the server is supposed to be authoritative for some domain, but isn't.
Field Meaning serveripThe IP address of the lame server. nameThe domain name for which records were requested. controlThe domain for which the server is supposed to be authoritative, but isn't.
dnscachereceived a "no data" response. This means that the server has records for the requested name, but no records of the requested type.
Field Meaning serveripThe IP address of the responding server. ttlThe time-to-live of the SOA record in the response. This is how long dnscacheis allowed to cache the negative response.dnscachewill not cache a negative response for more than one hour in any case.typeThe requested record type. nameThe domain name for which records were requested.
dnscachereceived a "Name Error" response. This means that the server has no records of any type for the requested name.
Field Meaning serveripThe IP address of the responding server. ttlThe time-to-live of the SOA record in the response. This is how long dnscacheis allowed to cache the negative response.dnscachewill not cache a negative response for more than one hour in any case.nameThe domain name for which records were requested.
query serial clientip:clientport:id type name
dnscachereceived a packet containing a query and intends to try to answer it.
Field Meaning serialThe number of queries dnscachereceived prior to this query since starting, plus one. In other words, serial number 1 is assigned to the first query received, serial number 2 is assigned to the second query received, and so on. The counter is stored using 64 bits, so chances of it wrapping are unlikely.clientipThe source IP address of the packet. Presumably this is the IP address from which the packet was sent, though it could have been spoofed. clientportThe source UDP port of the packet. idThe id from the packet. The id is chosen by the client, and the server will include it in the response. typeThe type of records the client wants. nameThe domain name for which the client wants records.
dnscachefinished constructing a response to a query. If the query came over UDP, thendnscachealso sent the response. If the query came over TCP, thendnscachedid not send the response before making this log entry. (Sending over TCP may block sodnscachetrickles the data out as part of its main loop.)
Field Meaning serialThe serial number of the client request to which dnscacheresponded. Seequeryfor an explanation of client request serial numbers.lengthThe number of bytes in the response.
dnscachesent a packet with rcode 2, "Server failure", because it encountered an error.Some of the errors that can make dnscache do this:
- failure to allocate storage for a received DNS packet
- failure to create a UDP socket
- failure to set the O_NONBLOCK flag on the UDP socket
- failure to bind the UDP socket to a port
- failure to transmit a packet to any of up to 16 nameservers and receive a response packet with an rcode of 0 (no error) or 3 (NXDOMAIN), with four attempts per nameserver
- failure to create a TCP socket
- failure to set the O_NONBLOCK flag on the TCP socket
- failure to bind the TCP socket to a port
- failure to connect the TCP socket to any of up to 16 nameservers (one attempt per nameserver), transmit a query to the nameserver, and receive a response packet with an rcode of 0 (no error) or 3 (NXDOMAIN)
There may be other ways for dnscache to log/send servfail, but these are all the ones I have found from inspecting the source code.
Field Meaning nameThe domain name for which the dnscache was trying to find records. errorAs of djbdnsversion 1.05, the error message will always be "input/output error", because the only call tolog_servfailis indoitinquery.c, like this:errno = error_io; if (state == 1) goto HAVEPACKET; if (state == -1) { log_servfail(z->name[z->level]); goto SERVFAIL; }
dnscachelogs this entry when it starts up.
stats query-count cache-motion udp-active tcp-active
- This entry contains statistics about
dnscache's behavior, both since startup and at the moment the entry was logged.
Field Meaning query-countThe total number of queries received by dnscachesince startup.cache-motionThe total number of bytes dnscachehas stored in its cache since startup. This says nothing about the maximum size of the cache or how much data has been evicted from the cache. See djb's explanation of cache motion for more information.udp-activeThe number of queries that dnscachehas received via UDP but not yet responded to or dropped.tcp-activeThe number of queries that dnscachehas received via TCP but not yet responded to or dropped.
tx gluelessness type name control serverips...
- This line indicates that dnscache transmitted a query.
Field Meaning gluelessnessThe amount of gluelessness that generated this query. Read djb's explanation of gluelessness.
For the case of www.monty.de, the queries
dnscachesent for www.monty.de have gluelessness 0. The query sent for ns.norplex.net has gluelessness 1. The query for vserver.neptun11.de has gluelessness 2. The query sent for ns.germany.net has gluelessness 3. And so on.typeThe requested record type. nameThe domain name for which records are being requested. controldnscachesends a query to a server because it has been told that the server is authoritative for the domain in question, or some ancestor thereof. Thecontrolfield shows the domain for whichdnscachethinks the server is authoritative.For example, suppose the cache is empty, and you ask
dnscachefor the A records for example.com. First,dnscachewill send a query to a root server, because the root server is authoritative for the root domain (written "."). So thetxline for the query will have "." in thecontrolfield.The root server will give
dnscachea list of servers that are authoritative for thecomdomain.dnscachewill ask one of thecomservers for the A records forexample.com, and the log entry will havecom.in thecontrolfield.Suppose the
comserver says thatns.example.netis authoritative forexample.com. Then whendnscacheasksns.example.netfor A records forexample.com, the log entry will haveexample.comin thecontrolfield.serveripsThe IP addresses of all the authoritative servers for the controldomain, in random order.dnscachetransmits the query to the first server in the list. If the server doesn't respond,dnscachemoves on to the next server in the list.
tx
named anchor to appear at the top of your window.)