]> git.ipfire.org Git - thirdparty/pdns.git/blob - regression-tests.recursor/config.sh
Meson: Separate test files from common files
[thirdparty/pdns.git] / regression-tests.recursor / config.sh
1 #!/bin/bash
2 set -e
3 if [ "${PDNS_DEBUG}" = "YES" ]; then
4 set -x
5 fi
6
7 export PDNS=${PDNS:-${PWD}/../pdns/pdns_server}
8 export PDNSRECURSOR=${PDNSRECURSOR:-${PWD}/../pdns/recursordist/pdns_recursor}
9 export RECCONTROL=${RECCONTROL:-${PWD}/../pdns/recursordist/rec_control}
10
11 . ./vars
12
13 if [ -z "$PREFIX" ]
14 then
15 echo "config not found or PREFIX not set"
16 exit 1
17 fi
18
19 if [ -z "$AUTHRUN" ]
20 then
21 echo "config not found or AUTHRUN not set"
22 exit 1
23 fi
24
25 rm -rf configs/
26 mkdir configs
27
28 cat > run-auth <<EOF
29 #!/bin/sh
30 $AUTHRUN
31 EOF
32 chmod +x run-auth
33
34 if [ \! -x "$PDNSRECURSOR" ]
35 then
36 echo "Could not find an executable pdns_recursor at \"$PDNSRECURSOR\", check PDNSRECURSOR"
37 echo "Continuing with configuration anyhow"
38 fi
39
40 if [ \! -x "$PDNS" ]
41 then
42 echo "Could not find an executable pdns_server at \"$PDNS\", check PDNS"
43 echo "Continuing with configuration anyhow"
44 fi
45
46 cd configs
47
48 for dir in recursor-service recursor-service2 recursor-service3 recursor-service4; do
49 mkdir -p /tmp/$dir
50 mkdir -p $dir
51 cd $dir
52
53 cat > run <<EOF
54 #!/bin/sh
55 $RECRUN
56 EOF
57 chmod +x run
58
59 cat > hintfile << EOF
60 . 3600 IN NS ns.root.
61 ns.root. 3600 IN A $PREFIX.8
62 EOF
63
64 cd ..
65 done
66
67 SOA="ns.example.net. hostmaster.example.net. 1 3600 1800 1209600 300"
68
69 ### fake root zone
70 mkdir $PREFIX.8
71 cat > $PREFIX.8/ROOT.zone <<EOF
72 . 3600 IN SOA $SOA
73 . 3600 IN NS ns.root.
74 ns.root. 3600 IN A $PREFIX.8
75 net. 3600 IN NS ns.example.net.
76 net. 3600 IN NS ns2.example.net.
77 ns.example.net. 3600 IN A $PREFIX.10
78 ns2.example.net. 3600 IN A $PREFIX.11
79 EOF
80
81 ### plain example.net zone
82 mkdir $PREFIX.10
83 cat > $PREFIX.10/example.net.zone <<EOF
84 example.net. 3600 IN SOA $SOA
85 example.net. 3600 IN NS ns.example.net.
86 example.net. 3600 IN NS ns2.example.net.
87 ns.example.net. 3600 IN A $PREFIX.10
88 ns2.example.net. 3600 IN A $PREFIX.11
89 www.example.net. 3600 IN A 192.0.2.1
90 www2.example.net. 3600 IN A 192.0.2.2
91 www3.example.net. 3600 IN A 192.0.2.3
92 www4.example.net. 3600 IN A 192.0.2.4
93 www5.example.net. 3600 IN A 192.0.2.5
94 default.example.net. 3600 IN A 192.0.2.42
95 weirdtxt.example.net. 3600 IN IN TXT "x\014x"
96 arthur.example.net. 3600 IN NS ns.arthur.example.net.
97 arthur.example.net. 3600 IN NS ns2.arthur.example.net.
98 ns.arthur.example.net. 3600 IN A $PREFIX.12
99 ns2.arthur.example.net. 3600 IN A $PREFIX.13
100 prefect.example.net. 3600 IN NS ns.prefect.example.net.
101 ns.prefect.example.net. 3600 IN A $PREFIX.14
102 marvin.example.net. 3600 IN NS ns.marvin.example.net.
103 ns.marvin.example.net. 3600 IN A $PREFIX.15
104 trillian.example.net. 3600 IN NS ns.trillian.example.net.
105 ns.trillian.example.net. 3600 IN A $PREFIX.16
106 ghost.example.net. 3600 IN NS ns.ghost.example.net.
107 ns.ghost.example.net. 3600 IN A $PREFIX.17
108 ford.example.net. 3600 IN NS ns.ford.example.net.
109 ns.ford.example.net. 3600 IN A $PREFIX.12
110 hijackme.example.net. 3600 IN NS ns.hijackme.example.net.
111 ns.hijackme.example.net. 3600 IN A $PREFIX.20
112 hijacker.example.net. 3600 IN NS ns.hijacker.example.net.
113 ns.hijacker.example.net. 3600 IN A $PREFIX.21
114 answer-cname-in-local.example.net. 3600 IN NS ns.answer-cname-in-local.example.net.
115 pfsbox.answer-cname-in-local.example.net. 3600 IN NS ns.answer-cname-in-local.example.net.
116 box.answer-cname-in-local.example.net. 3600 IN NS ns.answer-cname-in-local.example.net.
117 ns.answer-cname-in-local.example.net. 3600 IN A $PREFIX.22
118 not-auth-zone.example.net. 3600 IN NS ns.not-auth-zone.example.net.
119 ns.not-auth-zone.example.net. 3600 IN A $PREFIX.23
120 lowercase-outgoing.example.net. 3600 IN NS ns.lowercase-outgoing.example.net.
121 ns.lowercase-outgoing.example.net. 3600 IN A $PREFIX.24
122 nxdomainme.example.net. 3600 IN A $PREFIX.25
123 EOF
124
125 mkdir $PREFIX.11
126 cp $PREFIX.10/example.net.zone $PREFIX.11/
127
128 ### plain delegated zone, no surprises
129 ### also serves as intentionally NON-authoritative for ford
130 mkdir $PREFIX.12
131 cat > $PREFIX.12/arthur.example.net.zone <<EOF
132 arthur.example.net. 3600 IN SOA $SOA
133 arthur.example.net. 3600 IN NS ns.arthur.example.net.
134 arthur.example.net. 3600 IN NS ns2.arthur.example.net.
135 arthur.example.net. 3600 IN MX 10 mail.arthur.example.net.
136 ns.arthur.example.net. 3600 IN A $PREFIX.12
137 ns2.arthur.example.net. 3600 IN A $PREFIX.13
138 www.arthur.example.net. 3600 IN A 192.0.2.2
139 www2.arthur.example.net. 3600 IN A 192.0.2.6
140 www3.arthur.example.net. 3600 IN A 192.0.2.6
141 mail.arthur.example.net. 3600 IN A 192.0.2.3
142 big.arthur.example.net. 3600 IN TXT "the quick brown fox jumps over the lazy dog"
143 big.arthur.example.net. 3600 IN TXT "The quick brown fox jumps over the lazy dog"
144 big.arthur.example.net. 3600 IN TXT "THe quick brown fox jumps over the lazy dog"
145 big.arthur.example.net. 3600 IN TXT "THE quick brown fox jumps over the lazy dog"
146 big.arthur.example.net. 3600 IN TXT "THE quick brown fox jumps over the lazy dog"
147 big.arthur.example.net. 3600 IN TXT "THE Quick brown fox jumps over the lazy dog"
148 big.arthur.example.net. 3600 IN TXT "THE QUick brown fox jumps over the lazy dog"
149 big.arthur.example.net. 3600 IN TXT "THE QUIck brown fox jumps over the lazy dog"
150 big.arthur.example.net. 3600 IN TXT "THE QUICk brown fox jumps over the lazy dog"
151 big.arthur.example.net. 3600 IN TXT "THE QUICK brown fox jumps over the lazy dog"
152 big.arthur.example.net. 3600 IN TXT "THE QUICK brown fox jumps over the lazy dog"
153 big.arthur.example.net. 3600 IN TXT "THE QUICK Brown fox jumps over the lazy dog"
154 big.arthur.example.net. 3600 IN TXT "THE QUICK BRown fox jumps over the lazy dog"
155 big.arthur.example.net. 3600 IN TXT "THE QUICK BROwn fox jumps over the lazy dog"
156 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWn fox jumps over the lazy dog"
157 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN fox jumps over the lazy dog"
158 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN fox jumps over the lazy dog"
159 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN Fox jumps over the lazy dog"
160 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOx jumps over the lazy dog"
161 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX jumps over the lazy dog"
162 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX jumps over the lazy dog"
163 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX Jumps over the lazy dog"
164 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUmps over the lazy dog"
165 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMps over the lazy dog"
166 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPs over the lazy dog"
167 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS over the lazy dog"
168 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS over the lazy dog"
169 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS Over the lazy dog"
170 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS OVer the lazy dog"
171 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS OVEr the lazy dog"
172 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS OVER the lazy dog"
173 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS OVER the lazy dog"
174 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS OVER The lazy dog"
175 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS OVER THe lazy dog"
176 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS OVER THE lazy dog"
177 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS OVER THE lazy dog"
178 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS OVER THE Lazy dog"
179 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS OVER THE LAzy dog"
180 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS OVER THE LAZy dog"
181 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS OVER THE LAZY dog"
182 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS OVER THE LAZY dog"
183 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS OVER THE LAZY Dog"
184 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOg"
185 big.arthur.example.net. 3600 IN TXT "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG"
186 srv.arthur.example.net. 3600 IN SRV 0 100 389 server2.example.net.
187 rp.arthur.example.net. 3600 IN RP ahu.ds9a.nl. counter
188 type1234.arthur.example.net. 3600 IN TYPE1234 \# 2 4142
189 EOF
190
191 mkdir $PREFIX.13
192 cp $PREFIX.12/arthur.example.net.zone $PREFIX.13
193
194 ### zone with various CNAMEs, valid packets
195 mkdir $PREFIX.14
196 cat > $PREFIX.14/prefect.example.net.zone <<EOF
197 prefect.example.net. 3600 IN SOA $SOA
198 prefect.example.net. 3600 IN NS ns.prefect.example.net.
199 ns.prefect.example.net. 3600 IN A $PREFIX.14
200 www-a.prefect.example.net. 3600 IN CNAME www-a-2.prefect.example.net.
201 ;www-a-2.prefect.example.net. NXDOMAIN
202 www-b.prefect.example.net. 3600 IN CNAME www-b-2.prefect.example.net.
203 www-b-2.prefect.example.net. 3600 IN A 192.0.2.4
204 www-c.prefect.example.net. 3600 IN CNAME www-b-2.prefect.example.net.
205 ;www-c-2.prefect.example.net. NOERROR on A
206 www-c-2.prefect.example.net. 3600 IN AAAA 2001:db8::1
207 www-d.prefect.example.net. 3600 IN CNAME www.arthur.example.net.
208 EOF
209
210 ### zone with valid in-zone CNAME, invalid NXDOMAIN in response
211 mkdir $PREFIX.15
212 cat > $PREFIX.15/marvin.example.net.zone <<EOF
213 marvin.example.net. 3600 IN SOA $SOA
214 marvin.example.net. 3600 IN NS ns.marvin.example.net.
215 ns.marvin.example.net. 3600 IN A $PREFIX.15
216 www.marvin.example.net. 3600 IN CNAME android.marvin.example.net.
217 android.marvin.example.net. 3600 IN A 192.0.2.5
218 EOF
219
220 cat > $PREFIX.15/prequery.lua <<EOF
221 if not newDN then
222 function newDN(x)
223 return x
224 end
225 end
226 function prequery ( dnspacket )
227 qname, qtype = dnspacket:getQuestion()
228 if qtype == pdns.A and qname == "www.marvin.example.net."
229 then
230 dnspacket:setRcode(pdns.NXDOMAIN)
231 ret = {}
232 ret[1] = newDR(newDN(qname), "CNAME", 3600, "android.marvin.example.net", 1)
233 ret[2] = newDR(newDN("marvin.example.net"), "SOA", 3600, "$SOA", 2)
234 dnspacket:addRecords(ret)
235 return true
236 end
237 return false
238 end
239 EOF
240
241 ### zone with working cross-zone CNAME, invalid NXDOMAIN in response
242 mkdir $PREFIX.16
243 cat > $PREFIX.16/trillian.example.net.zone <<EOF
244 trillian.example.net. 3600 IN SOA $SOA
245 trillian.example.net. 3600 IN NS ns.trillian.example.net.
246 ns.trillian.example.net. 3600 IN A $PREFIX.16
247 www.trillian.example.net. 3600 IN CNAME www3.arthur.example.net.
248 EOF
249
250 cat > $PREFIX.16/prequery.lua <<EOF
251 if not newDN then
252 function newDN(x)
253 return x
254 end
255 end
256 function prequery ( dnspacket )
257 qname, qtype = dnspacket:getQuestion()
258 if qtype == pdns.A and qname == "www.trillian.example.net."
259 then
260 dnspacket:setRcode(pdns.NXDOMAIN)
261 ret = {}
262 ret[1] = newDR(newDN(qname), "CNAME", 3600, "www3.arthur.example.net", 1)
263 ret[2] = newDR(newDN(""), "SOA", 3600, "$SOA", 2)
264 dnspacket:addRecords(ret)
265 return true
266 end
267 return false
268 end
269 EOF
270
271 ### parent zone for ghost testing
272 mkdir $PREFIX.17
273 cat > $PREFIX.17/ghost.example.net.zone <<EOF
274 ghost.example.net. 3600 IN SOA $SOA
275 ghost.example.net. 3600 IN NS ns.ghost.example.net.
276 ns.ghost.example.net. 3600 IN A $PREFIX.17
277 1.ghost.example.net. 10 IN NS ns.1.ghost.example.net.
278 ns.1.ghost.example.net. 10 IN A $PREFIX.18
279 2.ghost.example.net. 10 IN NS ns.2.ghost.example.net.
280 ns.2.ghost.example.net. 10 IN A $PREFIX.19
281 EOF
282
283 cat > $PREFIX.17/prequery.lua <<EOF
284 posix = require 'posix'
285
286 if not newDN then
287 function newDN(x)
288 return x
289 end
290 end
291 function prequery ( dnspacket )
292 qname, qtype = dnspacket:getQuestion()
293 if (string.sub(tostring(qname), -20) == "1.ghost.example.net." and posix.stat('drop-1')) or
294 (string.sub(tostring(qname), -20) == "2.ghost.example.net." and posix.stat('drop-2'))
295 then
296 dnspacket:setRcode(pdns.NXDOMAIN)
297 ret = {}
298 ret[1] = newDR(newDN("ghost.example.net"), "SOA", 3600, "$SOA", 2)
299 dnspacket:addRecords(ret)
300 return true
301 end
302 return false
303 end
304 EOF
305
306 ### ghost domain with ever-changing NSset
307 mkdir $PREFIX.18
308 cat > $PREFIX.18/1.ghost.example.net.zone <<EOF
309 1.ghost.example.net. 3600 IN SOA $SOA
310 1.ghost.example.net. 20 IN NS ns.1.ghost.example.net.
311 ns.1.ghost.example.net. 20 IN A $PREFIX.18
312 *.www.1.ghost.example.net. 20 IN A 192.0.2.7
313 EOF
314
315 cat > $PREFIX.18/prequery.lua <<EOF
316 i=0
317
318 if not newDN then
319 function newDN(x)
320 return x
321 end
322 end
323 function prequery ( dnspacket )
324 i = i + 1
325 qname, qtype = dnspacket:getQuestion()
326 if qtype == pdns.A and string.sub(tostring(qname), -24) == "www.1.ghost.example.net."
327 then
328 dnspacket:setRcode(pdns.NOERROR)
329 ret = {}
330 -- www.1.ghost.example.net. 20 IN A 192.0.2.7
331 ret[1] = newDR(newDN(qname), "A", 20, "192.0.2.7", 1)
332 -- 1.ghost.example.net. 20 IN NS ns.1.ghost.example.net.
333 ret[2] = newDR(newDN("1.ghost.example.net"), "NS", 20, "ns"..i..".1.ghost.example.net", 2)
334 -- ns.1.ghost.example.net. 20 IN A $PREFIX.18
335 ret[3] = newDR(newDN("ns"..i..".1.ghost.example.net"), "A", 20, "$PREFIX.18", 3)
336 dnspacket:addRecords(ret)
337 return true
338 end
339 return false
340 end
341 EOF
342
343 ### ghost domain with static NSset
344 mkdir $PREFIX.19
345 cat > $PREFIX.19/2.ghost.example.net.zone <<EOF
346 2.ghost.example.net. 3600 IN SOA $SOA
347 2.ghost.example.net. 20 IN NS ns.2.ghost.example.net.
348 ns.2.ghost.example.net. 20 IN A $PREFIX.19
349 *.www.2.ghost.example.net. 20 IN A 192.0.2.8
350 EOF
351 cat > $PREFIX.19/prequery.lua <<EOF
352 if not newDN then
353 function newDN(x)
354 return x
355 end
356 end
357 function prequery ( dnspacket )
358 qname, qtype = dnspacket:getQuestion()
359 if qtype == pdns.A and string.sub(tostring(qname), -25) == ".www.2.ghost.example.net."
360 then
361 dnspacket:setRcode(pdns.NOERROR)
362 ret = {}
363 ret[1] = newDR(newDN(qname), "A", 20, "192.0.2.8", 1)
364 ret[2] = newDR(newDN("2.ghost.example.net"), "NS", 20, "ns.2.ghost.example.net", 2)
365 ret[3] = newDR(newDN("ns.2.ghost.example.net"), "A", 20, "$PREFIX.19", 3)
366 dnspacket:addRecords(ret)
367 return true
368 end
369 return false
370 end
371 EOF
372
373 ### plain domain as target for hijacking
374 mkdir $PREFIX.20
375 cat > $PREFIX.20/hijackme.example.net.zone <<EOF
376 hijackme.example.net. 3600 IN SOA $SOA
377 hijackme.example.net. 20 IN NS ns.hijackme.example.net.
378 ns.hijackme.example.net. 20 IN A $PREFIX.20
379 www.hijackme.example.net. 20 IN A 192.0.2.20
380 EOF
381
382 ### domain designed to hijack the A of ns.hijackme.example.net
383 mkdir $PREFIX.21
384 cat > $PREFIX.21/hijacker.example.net.zone <<EOF
385 hijacker.example.net. 3600 IN SOA $SOA
386 hijacker.example.net. 20 IN NS ns.hijackme.example.net.
387 ;ns.hijackme.example.net. 20 IN A $PREFIX.21
388
389 EOF
390
391 cat > $PREFIX.21/hijackme.example.net.zone <<EOF
392 hijackme.example.net. 3600 IN SOA $SOA
393 hijackme.example.net. 20 IN NS ns.hijackme.example.net.
394 ns.hijackme.example.net. 20 IN A $PREFIX.21
395 www.hijackme.example.net. 20 IN A 192.0.2.21
396
397 EOF
398
399 ## Several domains where one gets overwritten as a local auth zone
400 mkdir $PREFIX.22
401 cat > $PREFIX.22/box.answer-cname-in-local.example.net.zone <<EOF
402 box.answer-cname-in-local.example.net. 3600 IN SOA $SOA
403 box.answer-cname-in-local.example.net. 20 IN NS ns.answer-cname-in-local.example.net.
404
405 global.box.answer-cname-in-local.example.net. 20 IN NS ns.answer-cname-in-local.example.net.
406 service.box.answer-cname-in-local.example.net. 20 IN CNAME pfs.global.box.answer-cname-in-local.example.net.
407
408 EOF
409
410 cat > $PREFIX.22/global.box.answer-cname-in-local.example.net.zone <<EOF
411 global.box.answer-cname-in-local.example.net. 3600 IN SOA $SOA
412 global.box.answer-cname-in-local.example.net. 20 IN NS ns.answer-cname-in-local.example.net.
413
414 pfs.global.box.answer-cname-in-local.example.net. 20 IN CNAME vip-metropole.pfsbox.answer-cname-in-local.example.net.
415
416 EOF
417
418 cat > $PREFIX.22/pfsbox.answer-cname-in-local.example.net.zone <<EOF
419 pfsbox.answer-cname-in-local.example.net. 3600 IN SOA $SOA
420 pfsbox.answer-cname-in-local.example.net. 20 IN NS ns.answer-cname-in-local.example.net.
421
422 vip-metropole.pfsbox.answer-cname-in-local.example.net. 20 IN A 10.0.0.1
423 vip-reunion.pfsbox.answer-cname-in-local.example.net. 20 IN A 10.1.1.1
424
425 EOF
426
427 # Used for the auth-zones test, to test a CNAME inside an auth-zone to a name
428 # outside of and auth-zone
429 mkdir $PREFIX.23
430 cat > $PREFIX.23/not-auth-zone.example.net.zone <<EOF
431 not-auth-zone.example.net. 3600 IN SOA $SOA
432 not-auth-zone.example.net. 20 IN NS ns.not-auth-zone.example.net.
433
434 ns.not-auth-zone.example.net. 20 IN A $PREFIX.23
435 host1.not-auth-zone.example.net. 20 IN A 127.0.0.57
436 EOF
437
438 cat > $PREFIX.23/france.auth-zone.example.net.zone <<EOF
439 france.auth-zone.example.net. 3600 IN SOA $SOA
440 france.auth-zone.example.net. 3600 IN NS ns1.auth-zone.example.net
441 www.france.auth-zone.example.net. 3600 IN A 192.0.2.23
442 france.auth-zone.example.net. 3600 IN A 192.0.2.223
443 EOF
444
445 # And for the recursor
446 cat > recursor-service/global.box.answer-cname-in-local.example.net.zone <<EOF
447 global.box.answer-cname-in-local.example.net. 3600 IN SOA $SOA
448 global.box.answer-cname-in-local.example.net. 20 IN NS ns.answer-cname-in-local.example.net.
449
450 pfs.global.box.answer-cname-in-local.example.net. 20 IN CNAME vip-reunion.pfsbox.answer-cname-in-local.example.net.
451
452 EOF
453
454 # For the auth-zones test
455 cat > recursor-service/auth-zone.example.net.zone <<EOF
456 auth-zone.example.net. 3600 IN SOA $SOA
457 auth-zone.example.net. 20 IN NS localhost.example.net.
458
459 host1.auth-zone.example.net. 20 IN A 127.0.0.55
460 host1.auth-zone.example.net. 20 IN AAAA 2001:DB8::1:45BA
461
462 host2.auth-zone.example.net. 20 IN CNAME host1.another-auth-zone.example.net.
463
464 host3.auth-zone.example.net. 20 IN CNAME host1.not-auth-zone.example.net.
465 *.wild.auth-zone.example.net. 3600 IN TXT "Hi there!"
466 france.auth-zone.example.net. 20 IN NS ns1.auth-zone.example.net.
467 ns1.auth-zone.example.net. 20 IN A $PREFIX.23
468 *.something.auth-zone.example.net. 20 IN CNAME host1.auth-zone.example.net.
469 EOF
470
471 mkdir $PREFIX.24
472 cat > $PREFIX.24/lowercase-outgoing.example.net.zone <<EOF
473 lowercase-outgoing.example.net. 3600 IN SOA $SOA
474 lowercase-outgoing.example.net. 20 IN NS ns.lowercase-outgoing.example.net.
475
476 ns.lowercase-outgoing.example.net. 20 IN A $PREFIX.24
477 host.lowercase-outgoing.example.net. 20 IN A 127.0.0.57
478 EOF
479
480 cat > $PREFIX.24/prequery.lua <<EOF
481 filename = "questions.txt"
482
483 --- Truncate file
484 file = io.open(filename, "w")
485 file:close()
486
487 if not newDN then
488 function newDN(x)
489 return x
490 end
491 end
492 function prequery ( dnspacket )
493 qname, qtype = dnspacket:getQuestion()
494 file = io.open('questions.txt', "a")
495 file:write(tostring(qname) .. "\n")
496 file:close()
497
498 return false
499 end
500 EOF
501
502 cat > recursor-service/another-auth-zone.example.net.zone <<EOF
503 another-auth-zone.example.net. 3600 IN SOA $SOA
504 another-auth-zone.example.net. 20 IN NS localhost.example.net.
505
506 host1.another-auth-zone.example.net. 20 IN A 127.0.0.56
507 EOF
508
509 for dir in $PREFIX.*
510 do
511 cat > $dir/pdns.conf <<EOF
512 module-dir=../../../regression-tests/modules
513 launch=bind
514 daemon=no
515 local-address=$dir
516 bind-config=named.conf
517 no-shuffle
518 socket-dir=.
519 cache-ttl=0
520 negquery-cache-ttl=0
521 query-cache-ttl=0
522 distributor-threads=1
523
524 EOF
525 if [ -e $dir/prequery.lua ]
526 then
527 echo 'lua-prequery-script=prequery.lua' >> $dir/pdns.conf
528 fi
529
530 cat > $dir/named.conf <<EOF
531 options {
532 directory "./";
533 };
534 EOF
535 for zone in $(ls $dir | grep '\.zone$' | sed 's/\.zone$//')
536 do
537 realzone=$zone
538 if [ $realzone = ROOT ]
539 then
540 realzone='.'
541 fi
542 cat >> $dir/named.conf <<EOF
543 zone "$realzone"{
544 type master;
545 file "./$zone.zone";
546 };
547 EOF
548 done
549 ln -s ../../run-auth $dir/run
550 done
551
552 cat > recursor-service/forward-zones-file << EOF
553 # Some comment that should be ignored
554 forward-zones-test.non-existing.powerdns.com=8.8.8.8
555 forward-zones-test2.non-existing.powerdns.com=8.8.8.8# This comment should be ignored as well
556 EOF
557
558 cat > recursor-service/recursor.conf <<EOF
559 webserver=yes
560 api-key=secret
561 forward-zones-file=$(pwd)/recursor-service/forward-zones-file
562
563 socket-dir=/tmp/recursor-service
564 auth-zones=global.box.answer-cname-in-local.example.net=$(pwd)/recursor-service/global.box.answer-cname-in-local.example.net.zone,auth-zone.example.net=$(pwd)/recursor-service/auth-zone.example.net.zone,another-auth-zone.example.net=$(pwd)/recursor-service/another-auth-zone.example.net.zone
565 loglevel=9
566
567 EOF
568
569 cat > recursor-service2/recursor.conf <<EOF
570 local-port=5300
571 socket-dir=/tmp/recursor-service2
572 lowercase-outgoing=yes
573
574 EOF
575
576 cat > recursor-service3/recursor.conf << EOF
577 local-port=5301
578 socket-dir=/tmp/recursor-service3
579 lua-config-file=$(pwd)/recursor-service3/config.lua
580 lua-dns-script=$(pwd)/recursor-service3/script.lua
581 security-poll-suffix=
582
583 EOF
584
585 cat > recursor-service3/config.lua <<EOF
586 rpzFile("$(pwd)/recursor-service3/rpz.zone", {policyName="myRPZ"})
587 rpzFile("$(pwd)/recursor-service3/rpz2.zone", {policyName="mySecondRPZ"})
588 rpzFile("$(pwd)/recursor-service3/rpz3.zone", {policyName="cappedTTLRPZ", maxTTL=5})
589 rpzFile("$(pwd)/recursor-service3/rpz4.zone", {policyName="defPolicyTTL", defpol=Policy.Custom, defcontent="default.example.net", defttl=10, maxTTL=20})
590 rpzFile("$(pwd)/recursor-service3/rpz5.zone", {policyName="defPolicyCappedTTL", defpol=Policy.Custom, defcontent="default.example.net", defttl=50, maxTTL=20})
591 rpzFile("$(pwd)/recursor-service3/rpz6.zone", {policyName="defPolicyWithoutTTL", defpol=Policy.Custom, defcontent="default.example.net"})
592 rpzFile("$(pwd)/recursor-service3/rpz7.zone", {policyName="defPolicyWithoutTTLCapped", defpol=Policy.Custom, defcontent="default.example.net", maxTTL=50})
593 EOF
594
595 IFS=. read REV_PREFIX1 REV_PREFIX2 REV_PREFIX3 <<< $(echo $PREFIX) # This will bite us in the ass if we ever test on IPv6
596
597 cat > recursor-service3/rpz.zone <<EOF
598 \$TTL 2h;
599 \$ORIGIN domain.example.
600 @ SOA $SOA
601 @ NS ns.example.net.
602
603 arthur.example.net CNAME . ; NXDOMAIN on apex
604 *.arthur.example.net CNAME *. ; NODATA for everything below the apex
605 www3.arthur.example.net CNAME rpz-passthru. ; Allow this name through (so that the CNAME from www.trillian.example.net is not blocked)
606 srv.arthur.example.net CNAME rpz-passthru. ; Allow this name through
607 www.example.net CNAME www2.example.net. ; Local-Data Action
608 www3.example.net CNAME www4.example.net. ; Local-Data Action (to be changed in preresolve)
609 www5.example.net A 192.0.2.15 ; Override www5.example.net.
610 trillian.example.net CNAME . ; NXDOMAIN on apex, allows all sub-names (#4086)
611 *.wildcard-target.example.net CNAME *.walled-garden.example.net. ; Special form of Local Data: a CNAME RR with a wildcarded target name
612
613 32.4.2.0.192.rpz-ip CNAME rpz-drop. ; www4.example.net resolves to 192.0.2.4, drop A responses with that IP
614
615 ns.hijackme.example.net.rpz-nsdname CNAME . ; NXDOMAIN for anything hosted on ns.hijackme.example.net
616 ns.marvin.example.net.rpz-nsdname CNAME . ; NXDOMAIN for anything hosted on ns.marvin.example.net (we disable RPZ in preresolve though)
617 32.24.$REV_PREFIX3.$REV_PREFIX2.$REV_PREFIX1.rpz-nsip CNAME . ; The IP for ns.lowercase-outgoing.example.net, should yield NXDOMAIN
618
619 EOF
620
621 cat > recursor-service3/rpz2.zone <<EOF
622 \$TTL 2h;
623 \$ORIGIN domain.example.
624 @ SOA $SOA
625 @ NS ns.example.net.
626
627 www5.example.net A 192.0.2.25 ; Override www5.example.net.
628
629 EOF
630
631 cat > recursor-service3/rpz3.zone <<EOF
632 \$TTL 2h;
633 \$ORIGIN domain.example.
634 @ SOA $SOA
635 @ NS ns.example.net.
636
637 capped-ttl.example.net 50 IN A 192.0.2.35 ; exceeds the maxTTL setting
638 unsupported.example.net 50 IN CNAME rpz-unsupported. ; unsupported target
639 unsupported2.example.net 50 IN CNAME 32.3.2.0.192.rpz-unsupported. ; also unsupported target
640 not-rpz.example.net 50 IN CNAME rpz-not.com. ; this one is not a special RPZ target
641
642 EOF
643
644 cat > recursor-service3/rpz4.zone <<EOF
645 \$TTL 2h;
646 \$ORIGIN domain.example.
647 @ SOA $SOA
648 @ NS ns.example.net.
649
650 defpol-with-ttl.example.net 50 IN A 192.0.2.35 ; will be overridden by the default policy and the default TTL
651
652 EOF
653
654 cat > recursor-service3/rpz5.zone <<EOF
655 \$TTL 2h;
656 \$ORIGIN domain.example.
657 @ SOA $SOA
658 @ NS ns.example.net.
659
660 defpol-with-ttl-capped.example.net 100 IN A 192.0.2.35 ; will be overridden by the default policy and the default TTL (but capped by maxTTL)
661
662 EOF
663
664 cat > recursor-service3/rpz6.zone <<EOF
665 \$TTL 2h;
666 \$ORIGIN domain.example.
667 @ SOA $SOA
668 @ NS ns.example.net.
669
670 defpol-without-ttl.example.net A 192.0.2.35 ; will be overridden by the default policy, but with the zone's TTL
671
672 EOF
673
674 cat > recursor-service3/rpz7.zone <<EOF
675 \$TTL 2h;
676 \$ORIGIN domain.example.
677 @ SOA $SOA
678 @ NS ns.example.net.
679
680 defpol-without-ttl-capped.example.net A 192.0.2.35 ; will be overridden by the default policy, but with the zone's TTL capped by maxTTL
681
682 EOF
683
684 cat > recursor-service3/script.lua <<EOF
685 function prerpz(dq)
686 if dq.qname:equal('www5.example.net') then
687 dq:discardPolicy('myRPZ')
688 end
689 return true
690 end
691
692 function preresolve(dq)
693 if dq.qname:equal("nxdomainme.example.net") then
694 dq.rcode = pdns.NXDOMAIN
695 return true
696 end
697 if dq.qname:equal("android.marvin.example.net") then
698 dq.wantsRPZ = false -- disable RPZ
699 end
700 return false
701 end
702
703 function policyEventFilter(event)
704 if event.appliedPolicy.policyKind == pdns.policykinds.Custom then
705 if event.qname:equal("www3.example.net") then
706 event.appliedPolicy.policyCustom = "www2.example.net"
707 return false
708 end
709 end
710 return false
711 end
712 EOF
713
714 cat > recursor-service4/recursor.conf <<EOF
715 local-port=5302
716 socket-dir=/tmp/recursor-service4
717 packetcache-ttl=0
718 forward-zones=net.=$PREFIX.10;$PREFIX.11
719
720 EOF