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. β¨-pport β listens to the specified port.-fnum β forks this number of additional instances that serve the same ports and the same datafile. They do not exit. What gets printed isforked 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.-lIP address β bind to the specified IPv4 or IPv6 address.-aIP address β the IPv4 or IPv6 address to answer from, with theADJUST change_addressdirective (see below). This can only be used in combination with the-loption, 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: thatHEX_ANSWER_BEGINblock literally replaces whatever answer packet theSECTIONkeywords built (onlySECTION QUERYis used to match queries), and if the data cannot be parsed, theADJUSTrules 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 Β©οΈ
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
- arch rolling: ldns 1.9.2-1 Β· custom:BSD
- fedora 43: ldns-utils 1.9.2-1.fc43 Β· BSD-3-Clause
- fedora 44: ldns-utils 1.9.2-1.fc44 Β· BSD-3-Clause
- nixos 26.05: ldns 1.9.2
- nixpkgs unstable: ldns 1.9.2
- ubuntu stonking: ldnsutils 1.9.2-1ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms