1ldns-testns(1) General Commands Manual ldns-testns(1)
2
3
4
6 ldns-testns - simple fake nameserver tool
7
9 ldns-testns [ OPTION ] datafile
10
11
13 ldns-testns can be used to provide answers to DNS queries for testing.
14 The answers are premade, and can be tailored to testing needs. The an‐
15 swers can be wildly invalid or unparsable.
16
17 This program is a debugging aid. It is not efficient, especially with a
18 long config file, but it can give any reply to any query. This can
19 help the developer pre-script replies for queries.
20
21 It listens to IP4 UDP and TCP by default. You can specify a packet RR
22 by RR with header flags to return.
23
24 ldns-testns is not meant for production use.
25
26
28 -r Listens to a random port. The port number is printed to stdout.
29
30
31 -p port
32 Listens to the specified port.
33
34
35 -f num Forks this number of additional instances that serve the same
36 ports and same datafile. They do not exit; printed is 'forked
37 pid: <num>' and you have to kill them yourself.
38
39
40 -v Outputs more debug information. It is possible to give this op‐
41 tion multiple times to increase verbosity level.
42
43
44 -6 Bind to IP6 address instead of IP4. Use together with -p.
45
46
47 datafile
48 The data file is read on start up. It contains queries and the
49 packets that should be sent in answer to those queries. The data
50 file format is explained below.
51
52
54 The data file format has ';' to denote comment. A number of entries are
55 processed first to last. The first matching entry is used to answer the
56 query with. This is a line based format. DNS resource records are en‐
57 tered in zone-file format.
58
59 You can use $ORIGIN and $TTL directives. Zone file '(' and ')' to span
60 multiple lines are not allowed.
61
62 $ORIGIN origin $TTL default_ttl
63
64 ENTRY_BEGIN
65
66 ; first give MATCH lines, that say what queries are matched ; by this
67 entry. ; 'opcode' makes the query match the opcode from the reply ; if
68 you leave it out, any opcode matches this entry. ; 'qtype' makes the
69 query match the qtype from the reply ; 'qname' makes the query match
70 the qname from the reply ; 'serial=1023' makes the query match if ixfr
71 serial is 1023.
72
73 MATCH [opcode] [qtype] [qname] [serial=<value>] MATCH [UDP|TCP] MATCH
74 ...
75
76 ; Then the REPLY header is specified.
77
78 REPLY opcode, rcode or flags.
79 (opcode) QUERY IQUERY STATUS NOTIFY UPDATE
80 (rcode) NOERROR FORMERR SERVFAIL NXDOMAIN NOTIMPL YXDOMAIN
81 YXRRSET NXRRSET NOTAUTH NOTZONE
82 (flags) QR AA TC RD CD RA AD
83
84 REPLY ...
85
86 ; any additional actions to do.
87
88 ADJUST copy_id ; 'copy_id' copies the ID from the query to the answer.
89
90 ; 'sleep=10' sleeps for 10 seconds before giving the answer (TCP is
91 open)
92
93 ADJUST [sleep=<num>] ; sleep before giving any reply ADJUST
94 [packet_sleep=<num>] ; sleep before this packet in sequence
95
96 SECTION QUESTION <RRs, one per line> ; the RRcount is determined au‐
97 tomatically.
98
99 SECTION ANSWER <RRs, one per line>
100
101 SECTION AUTHORITY <RRs, one per line>
102
103 SECTION ADDITIONAL <RRs, one per line>
104
105 EXTRA_PACKET ; follow with SECTION, REPLY for more packets.
106 HEX_ANSWER_BEGIN ; follow with hex data
107 ; this replaces any answer packet constructed
108 ; with the SECTION keywords (only SECTION QUERY
109 ; is used to match queries). If the data cannot
110 ; be parsed, ADJUST rules for the answer packet
111 ; are ignored
112
113 HEX_ANSWER_END
114
115 ENTRY_END
116
117
119 Written by the ldns team as an example for ldns usage, and for testing
120 purposes.
121
123 Report bugs to <ldns-team@nlnetlabs.nl>.
124
126 Copyright (C) 2006-2008 NLnet Labs. This is free software. There is NO
127 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR‐
128 POSE.
129
130
131
132 14 Dec 2006 ldns-testns(1)