ldns-testns(1)

πŸ’– NAME πŸ’–

ldns-testns β€” a simple fake nameserver tool. That's the whole vibe. This is the ldns-testns(1) page and bestie, it's a debugging icon. πŸ‘‘


🌸 SYNOPSIS 🌸

ldns-testns [ OPTION ] datafile

✨ DESCRIPTION ✨

okay so picture this: ldns-testns hands out answers to DNS queries, purely for testing. The answers are premade, and you can tailor them to whatever you're testing. They can be wildly invalid or even straight-up unparsable β€” and honestly? that's the point. πŸ’…

This program is a debugging aid. It is not efficient, especially with a long config file, but it can give any reply to any query. That's the superpower: it helps a developer pre-script replies for queries. 🌈

By default it listens to IP4 UDP and TCP. You can specify a packet RR by RR, with header flags, to return. Every. Single. Detail. πŸŽ€

🚨 real talk bestie: ldns-testns is not meant for production use. Not even a little bit. It's a test toy, periodt.

πŸŽ€ OPTIONS πŸŽ€

  • -r β€” listens to a random port. The port number is printed to stdout, so you can go find it. ✨
  • -p port β€” listens to the specified port.
  • -f num β€” forks this number of additional instances that serve the same ports and the same datafile. They do not exit. What gets printed is forked pid: <num>, and you have to kill them yourself. 😭 not me leaving orphan processes everywhere.
  • -v β€” outputs more debug information. You can give this option multiple times to increase the verbosity level. Stack them up, girl. 🫢
  • -6 β€” bind to an IP6 address instead of IP4. Use together with -p.
  • -l IP address β€” bind to the specified IPv4 or IPv6 address.
  • -a IP address β€” the IPv4 or IPv6 address to answer from, with the ADJUST change_address directive (see below). This can only be used in combination with the -l option, with an address of the same family. no cross-family chaos, iykyk.
  • datafile β€” the data file, and it's read on start up. It contains queries plus the packets that should be sent in answer to those queries. The data file format is explained below. πŸ‘‡

πŸ¦‹ DATA FILE FORMAT πŸ¦‹

The data file format has ; to denote comment. A number of entries are processed first to last, and the first matching entry is the one used to answer the query with. This is a line based format. DNS resource records are entered in zone-file format. πŸ“

You can use $ORIGIN and $TTL directives. Zone file ( and ) to span multiple lines are not allowed. πŸ™ˆ

$ORIGIN origin
$TTL default_ttl

ENTRY_BEGIN

; first give MATCH lines, that say what queries are matched
; by this entry.
; 'opcode' makes the query match the opcode from the reply
; if you leave it out, any opcode matches this entry.
; 'qtype' makes the query match the qtype from the reply
; 'qname' makes the query match the qname from the reply
; 'serial=1023' makes the query match if ixfr serial is 1023.

MATCH [opcode] [qtype] [qname] [serial=<value>]
MATCH [UDP|TCP]
MATCH ...

; Then the REPLY header is specified.

REPLY opcode, rcode or flags.
        (opcode)  QUERY IQUERY STATUS NOTIFY UPDATE
        (rcode)   NOERROR FORMERR SERVFAIL NXDOMAIN NOTIMPL YXDOMAIN
                        YXRRSET NXRRSET NOTAUTH NOTZONE
        (flags)   QR AA TC RD CD RA AD

REPLY ...

; any additional actions to do.

ADJUST copy_id  ; 'copy_id' copies the ID from the query to the answer.

ADJUST change_id ; answer with a different ID than the query had

ADJUST change_port ; answer from a different port than the query was
                   ; sent to. UDP only (silently ignored on TCP)

ADJUST change_address ; answer from a different address than the query
                      ; was sent to. UDP only (silently ignored on TCP)

ADJUST [sleep=<num>] ; sleep before giving any reply
                     ; 'sleep=10' sleeps for 10 seconds before giving
                     ; the answer (TCP is open)

ADJUST [packet_sleep=<num>]  ; sleep before this packet in sequence

SECTION QUESTION <RRs, one per line>    ; the RRcount is determined
                                        ; automatically.

SECTION ANSWER <RRs, one per line>

SECTION AUTHORITY <RRs, one per line>

SECTION ADDITIONAL <RRs, one per line>

HEX_EDNSDATA_BEGIN <Hex data of an EDNS option>
HEX_EDNSDATA_END

EXTRA_PACKET            ; follow with SECTION, REPLY for more packets.
HEX_ANSWER_BEGIN        ; follow with hex data
                        ; this replaces any answer packet constructed
                        ; with the SECTION keywords (only SECTION QUERY
                        ; is used to match queries). If the data cannot
                        ; be parsed, ADJUST rules for the answer packet
                        ; are ignored

HEX_ANSWER_END

ENTRY_END
πŸ’€ tiny heads up: that HEX_ANSWER_BEGIN block literally replaces whatever answer packet the SECTION keywords built (only SECTION QUERY is used to match queries), and if the data cannot be parsed, the ADJUST rules for the answer packet get ignored. so don't be surprised, bestie.

πŸ‘‘ AUTHOR πŸ‘‘

Written by the ldns team as an example for ldns usage, and for testing purposes. iconic behavior, truly. πŸ’œ


πŸ› REPORTING BUGS πŸ›

Report bugs to <dns-team@nlnetlabs.nl>.


Copyright (C) 2006-2008 NLnet Labs. This is free software. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


okay that's the whole ldns-testns(1) page, bestie β€” this version came from the General Commands Manual, dated 14 Dec 2006. go script some absolutely unhinged DNS replies and slay. πŸ§šβœ¨πŸ¦‹

πŸ“¦ where this page comes from