decodedns

Decodes DNS messages from Ethernet frames, extracting the query domain, response IP address, status code, and other data.

Command properties

ItemDescription
Command typeProcessing query
Required permissionNone
License usageN/A
Parallel executionSupported
Distributed executionRuns on Data Node (mapper)

Syntax

decodedns

Input fields

FieldTypeRequiredDescription
payloadbinaryRequiredEthernet frame data. If the field is not binary type, the input record is passed through as-is.

Output fields

FieldTypeDescription
txidstringDNS transaction ID (4-digit hexadecimal string)
src_ipipaddrSource IP address
src_portintegerSource port number
dst_ipipaddrDestination IP address
dst_portintegerDestination port number
directionstringCommunication direction. c->s (client to server) or s->c (server to client)
bytesintegerDNS message size in bytes
typestringDNS query type. For example: A, AAAA, CNAME, MX, NS, PTR, SOA, SRV, TXT
domainstringQuery domain name
statusstringDNS response status: NO_ERROR, FORMAT_ERROR, SERVER_FAILURE, NAME_ERROR, NOT_IMPLEMENTED, REFUSED
ipipaddrResponse IP address of the first A record. Returns null if no A record exists.
flagsstringDNS flags string (for example: standard query response (RD RA))
queriesarrayList of DNS query section records. Assigned only when there are 2 or more queries.
answersarrayList of DNS answer section records. Assigned only when there is 1 or more answer.
additionalsarrayList of DNS additional section records. Assigned only when there is 1 or more additional record.
authoritiesarrayList of DNS authority section records. Assigned only when there is 1 or more authority record.

Error codes

Parse errors

N/A

Runtime errors

N/A

Description

The decodedns command reads an Ethernet frame from the payload field of each input record and decodes the DNS protocol message. If the payload field is not binary type, the input record is passed through to the next command unchanged.

From the decoded DNS message, the command extracts the source/destination IP and port, communication direction, query type, domain, response status, and the IP address of the first A record. The query, answer, additional, and authority section records are also provided as arrays.

The queries field is assigned only when there are 2 or more query records. The answers, additionals, and authorities fields are each assigned only when there is at least 1 record.

This command supports parallel execution and runs on the Data Node in a distributed environment.

Examples

  1. Decoding DNS messages from a PCAP file

    pcapfile /opt/logpresso/dns-capture.pcap
    | decodedns
    

    Decodes DNS messages from Ethernet frames read from a PCAP file.

  2. Querying DNS queries for a specific domain

    pcapfile /opt/logpresso/dns-capture.pcap
    | decodedns
    | search domain == "*.example.com"
    | fields txid, src_ip, domain, type, ip, status
    

    Filters DNS queries for subdomains of example.com and retrieves key fields.

  3. Aggregating DNS response status codes

    pcapfile /opt/logpresso/dns-capture.pcap
    | decodedns
    | search direction == "s->c"
    | stats count by status
    

    Aggregates DNS responses sent from server to client by status code.