Protocol 35 of 81Layer 7FrameAssembly v3.1.2
llms-full.txt
dnsDomain Name System over UDP or TCP

It’s Always DNS (client <-> resolver dns Over UDP 53 or TCP)

Default Port / Protocol
UDP 53 (or TCP 53 via transport tcp)
Host Endpoint Rule
Dual-Stack IPv4/IPv6
Wireshark Display Filter
dns
Standards & Specs
RFC 1035, RFC 3596, RFC 2782
Wire Stack:Ethernet II[802.1Q / QinQ / MPLS]IPv4 / IPv6UDP 53 (or TCP 53 via transport tcp) (transport tcp|udp)DNS (UDP/TCP)

What It Does on the Wire

Whether you are testing a sinkhole rule, an Active Directory SRV lookup, or switching to transport tcp (which auto-prepends the 2-byte RFC 1035 TCP length prefix!), dns encodes wire labels and compressed answers cleanly.

Domain Name System (dns, RFC 1035 / RFC 3596) resolves domain names into IPv4 (A), IPv6 (AAAA), service (SRV), mail (MX), and policy (TXT) records on port 53. dns defaults to UDP port 53, and adding transport tcp switches to TCP port 53 with the required 2-byte RFC 1035 TCP length prefix.

FrameAssembly formats RFC 1035 domain labels automatically, checks the RFC 63-character label limit and 253-character total hostname limit before building your .pcap, and writes compressed Answer records (A, AAAA, CNAME, TXT, PTR, NS, MX, SRV) on response packets.

DNS Tunneling, DGA & NXDOMAIN SIEM Rule Testing

Create subdomain queries, TXT lookups, and rcode 3 (NXDOMAIN) or rcode 5 (REFUSED) responses to test Suricata alerts, Zeek dns.log pipelines, and DNS sinkholes.

TCP Port 53 Fallback & Zone Transfer (AXFR / SRV) Checks

Pair a 3-way TCP handshake on port 53 with dns ... transport tcp to verify firewall rules for large DNS replies, Active Directory _ldap._tcp SRV queries, and AXFR audits.

Dual-Stack AAAA & Split-Horizon Resolver Captures

Test qtype "AAAA" queries and IPv6 answers over either IPv4 or IPv6 DNS servers using a reusable flow block.

Minimal Quickstart (dns_quickstart.frasm)

Hit Preview Packets to compile in-browser and eyeball timestamps + wire byte lengths, or ship it straight to the Playground.

dns_quickstart.frasm7 lines
Open in Playground
host stub_client { ip 10.10.0.25 }
host dns_resolv { ip 10.10.0.53 }
compile {
stub_client -> dns_resolv dns query txid 0x4a12 qname "api.frameassembly.internal" qtype "A" wait 2ms
stub_client <- dns_resolv dns response txid 0x4a12 qname "api.frameassembly.internal" qtype "A" rdata "10.10.50.80" ansttl 300
}

What the Compiler Calculates So You Don't Have To

  • Encodes dotted qname strings into RFC 1035 length-prefixed labels (\x03api...\x00) and validates RFC label (<= 63B) and total length (<= 253B) limits at compile time.
  • Sets DNS flags (QR=0, RD=1 0x0100 on query; QR=1, RD=1, RA=1 0x8180 | rcode on response) and appends compressed 0xc00c Answer RRs when rdata is provided.
  • Prepends the 2-byte big-endian message length header automatically whenever transport tcp is specified.
Multi-Frame Lab · Ready to Compile

UDP A/AAAA + NXDOMAIN Lookups Followed by Stateful DNS-over-TCP SRV Resolution

Captures standard UDP AAAA and NXDOMAIN (rcode 3) queries, then establishes a TCP 53 session to resolve an Active Directory _kerberos._tcp lookup via transport tcp.

dns_udp_and_tcp_lab.frasm17 lines
Open in Playground
host workstation { ip 172.16.10.45 }
host corp_dns { ip 172.16.10.10 }
compile {
// 1. Standard UDP IPv6 AAAA lookup
workstation -> corp_dns dns query txid 0x1001 srcport 53110 qname "git.corp.internal" qtype "AAAA" wait 1ms
workstation <- corp_dns dns response txid 0x1001 qname "git.corp.internal" qtype "AAAA" rdata "2001:db8:10::443" ansttl 120 wait 3ms
// 2. Non-existent domain returning NXDOMAIN (rcode 3)
workstation -> corp_dns dns query txid 0x1002 srcport 53111 qname "missing-svc.corp.internal" qtype "A" wait 1ms
workstation <- corp_dns dns response txid 0x1002 qname "missing-svc.corp.internal" qtype "A" rcode 3 wait 4ms
// 3. RFC 1035 DNS-over-TCP on port 53 (auto-prefixes 2-byte TCP length field)
workstation -> corp_dns tcp syn srcport 54053 dstport 53 win 65535 mss 1460 wait 1ms
workstation <- corp_dns tcp syn ack win 65535 mss 1460 wait 1ms
workstation -> corp_dns tcp ack wait 1ms
workstation -> corp_dns dns query txid 0x2001 qname "dc01.corp.internal" qtype "TXT" transport tcp wait 1ms
workstation <- corp_dns dns response txid 0x2001 qname "dc01.corp.internal" qtype "TXT" rdata "v=spf1 ip4:172.16.0.0/16 -all" ansttl 3600 transport tcp
}
Terminal Commands (FrameAssembly CLI v3.1.2)
# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show dns_udp_and_tcp_lab.frasm

# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly dns_udp_and_tcp_lab.frasm dns_udp_and_tcp_lab.pcap
frameassembly dns_udp_and_tcp_lab.frasm dns_udp_and_tcp_lab.pcapng

# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse dns_udp_and_tcp_lab.pcap dns_udp_and_tcp_lab_edited.frasm

All dns Keywords & Header Options

Every sub-keyword and header option is lowercase [a-z0-9]+ with zero underscores — mix and match them in any order after dns:

src_host -> dst_host dns [query | response] [txid <0..65535>] [qname "<text>"] [qtype "<text>"] [rdata "<text>"] [rcode <0..15>] [ansttl <number>] [transport <udp|tcp>]
Keyword / OptionAccepted ValueDefaultEffect on Packet
query | responseMessage direction keywordquery (QR=0)Toggles the QR bit in the 12-byte DNS header (0 query, 1 response with Answer RRs).
txid <0..65535>Whole number (0..65535)0x1234Sets the 16-bit DNS Transaction ID matching requests to responses.
qname "<text>"Domain string (labels <= 63B, total <= 253B)"example.com"Encodes the Question QNAME wire labels.
qtype "<text>""A" | "AAAA" | "CNAME" | "MX" | "NS" | "PTR" | "SOA" | "SRV" | "TXT" | "AXFR" | "ANY""A"Sets the 16-bit QTYPE (and Answer RR TYPE on responses).
rdata "<text>"IP string, hostname, or text valueOmitted (or 93.184.216.34 on A response)Populates the Answer Resource Record RDATA payload on response frames.
rcode <0..15>4-bit response code0 (NOERROR)Sets the lower 4 bits of DNS Flags (0=NOERROR, 1=FORMERR, 2=SERVFAIL, 3=NXDOMAIN, 5=REFUSED).
ansttl <number>Whole number (seconds)300Sets the 32-bit caching TTL inside the Answer Resource Record (never ans_ttl).
transport <udp|tcp>udp or tcpudpSwitches between UDP 53 and stateful TCP 53 (adding the 2-byte RFC 1035 message length prefix).

Cross-Layer Wrappers Valid with dns

802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol

12 options
OptionRange / FormatDefaultEffect on Packet
wait <number><ns|us|ms|s|m>Time gap (ns, us, ms, s, m)10msAdvances the packet timestamp clock after sending this packet and before the next packet (wait 0ns sends back-to-back).
payload "<text>" | hexpayload "<hex>"Quoted text or hex bytes (choose one)OmittedAppends or overrides raw payload bytes ("deadbeef" or "de:ad:be:ef") and updates packet lengths and checksums.
srcmac <mac> | dstmac <mac>Colon, hyphen, or Cisco dot MACHost MAC / RFC multicast MACOverrides the 14-byte Ethernet II source or destination MAC address for this single packet.
vlan <0..4095> [pcp <0..7>] [dei <0|1>]VLAN ID 0..4095, PCP 0..7, DEI 0..1UntaggedWraps the packet in an IEEE 802.1Q VLAN tag (0x8100) with optional 802.1p QoS priority.
qinq <0..4095> [innervlan <0..4095>]Outer S-VLAN 0..4095, Inner C-VLAN 0..4095Untagged (innervlan 1 when qinq is set)Double-tags the packet with outer IEEE 802.1ad S-Tag (0x88a8) plus inner IEEE 802.1Q C-Tag (0x8100).
mpls <0..1048575> [exp|tc <0..7>] [bos <0|1>] [mplsttl <0..255>]Label 0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255Unlabeled (at most 1 mpls tag per packet)Inserts a 32-bit MPLS label header (0x8847) ahead of the Layer 3 header.
ttl <0..255> [dscp <0..63>] [ecn <0..3>]TTL/Hop Limit 0..255, DSCP 0..63, ECN 0..3ttl 64, dscp 0, ecn 0Sets IPv4 TTL or IPv6 Hop Limit plus DiffServ (DSCP) and ECN QoS markings.
ipid <0..65535> [df] [mf] [fragoffset <0..8191>]IPv4 ID, DF/MF flags, fragment offset 0..8191ipid 1, flags 0, fragoffset 0Sets IPv4 Identification, Do-Not-Fragment (df), More-Fragments (mf), and fragment offset (ignored over IPv6).
flowlabel <0..1048575>20-bit IPv6 Flow Label (0..1048575)0Sets the 20-bit IPv6 Flow Label for ECMP routing tests (ignored when running over IPv4 hosts).
srcport <0..65535> | dstport <0..65535>Port number 0..65535srcport 49152 (remembered), UDP 53 (or TCP 53 via transport tcp)Overrides source or destination port and remembers the port pair automatically on <- replies.
transport <tcp|udp>tcp or udp (supported on 9 dual-L4 protocols)transport udpSwitches Layer 4 transport between TCP (psh ack + length framing where required) and UDP.
seq <number> | acknum <number> | win <0..65535> | syn | ack | psh | fin | rstTCP sequence/ack numbers, window size, flags & RFC 7323 optionspsh ack, win 65535, automatic TCP seq/acknumWhen using TCP (transport tcp or default TCP): overrides automatic TCP sequence tracking, flags, or mss/wscale/sackperm/tsval/tsecr.

Gotchas & Quick Fixes

Spell Answer TTL as ansttl (Zero Underscores)

Avoid
stub_client <- dns_resolv dns response rdata "10.0.0.5" ans_ttl 300
Valid v3.1.2 Syntax
stub_client <- dns_resolv dns response rdata "10.0.0.5" ansttl 300

Built-in modifiers never use underscores—use ansttl <number> for the DNS Answer RR TTL so L3 ttl <0..255> remains free to set the IP Hop Limit.

Each Domain Label Must Be 63 Characters or Fewer

Avoid
stub_client -> dns_resolv dns query qname "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.internal"
Valid v3.1.2 Syntax
stub_client -> dns_resolv dns query qname "part1.part2.exfil.internal"

RFC 1035 limits each dot-separated label to 63 bytes and the full domain name to 253 bytes. Split long DNS tunneling test payloads across multiple dots.

Field Guide 04
Encrypted SNMPv3 Traps, Syslog & NetFlow From Your Desk