Home | History | Annotate | Line # | Download | only in staticstub
      1       1.1  christos #!/bin/sh
      2   1.1.1.6  christos 
      3       1.1  christos # Copyright (C) Internet Systems Consortium, Inc. ("ISC")
      4       1.1  christos #
      5   1.1.1.6  christos # SPDX-License-Identifier: MPL-2.0
      6   1.1.1.6  christos #
      7       1.1  christos # This Source Code Form is subject to the terms of the Mozilla Public
      8   1.1.1.6  christos # License, v. 2.0.  If a copy of the MPL was not distributed with this
      9   1.1.1.5  christos # file, you can obtain one at https://mozilla.org/MPL/2.0/.
     10       1.1  christos #
     11       1.1  christos # See the COPYRIGHT file distributed with this work for additional
     12       1.1  christos # information regarding copyright ownership.
     13       1.1  christos 
     14   1.1.1.7  christos set -e
     15   1.1.1.7  christos 
     16   1.1.1.7  christos . ../conf.sh
     17       1.1  christos 
     18       1.1  christos DIGOPTS="-p ${PORT}"
     19   1.1.1.7  christos RNDCCMD="$RNDC -c ../_common/rndc.conf -p ${CONTROLPORT} -s"
     20       1.1  christos 
     21       1.1  christos status=0
     22       1.1  christos n=0
     23       1.1  christos 
     24   1.1.1.7  christos for conf in conf/good*.conf; do
     25   1.1.1.7  christos   n=$((n + 1))
     26   1.1.1.7  christos   echo_i "checking that $conf is accepted ($n)"
     27   1.1.1.7  christos   ret=0
     28   1.1.1.7  christos   $CHECKCONF "$conf" || ret=1
     29   1.1.1.7  christos   if [ $ret != 0 ]; then echo_i "failed"; fi
     30   1.1.1.7  christos   status=$((status + ret))
     31       1.1  christos done
     32       1.1  christos 
     33   1.1.1.7  christos for conf in conf/bad*.conf; do
     34   1.1.1.7  christos   n=$((n + 1))
     35   1.1.1.7  christos   echo_i "checking that $conf is rejected ($n)"
     36   1.1.1.7  christos   ret=0
     37   1.1.1.7  christos   $CHECKCONF "$conf" >/dev/null && ret=1
     38   1.1.1.7  christos   if [ $ret != 0 ]; then echo_i "failed"; fi
     39   1.1.1.7  christos   status=$((status + ret))
     40       1.1  christos done
     41       1.1  christos 
     42   1.1.1.7  christos n=$((n + 1))
     43       1.1  christos echo_i "trying an axfr that should be denied (NOTAUTH) ($n)"
     44       1.1  christos ret=0
     45   1.1.1.7  christos $DIG $DIGOPTS +tcp data.example. @10.53.0.2 axfr >dig.out.ns2.test$n || ret=1
     46   1.1.1.7  christos grep "; Transfer failed." dig.out.ns2.test$n >/dev/null || ret=1
     47       1.1  christos if [ $ret != 0 ]; then echo_i "failed"; fi
     48   1.1.1.7  christos status=$((status + ret))
     49       1.1  christos 
     50   1.1.1.7  christos n=$((n + 1))
     51   1.1.1.9  christos echo_i "non recursive query for a static-stub zone with server address should be rejected ($n)"
     52       1.1  christos ret=0
     53   1.1.1.7  christos $DIG $DIGOPTS +tcp +norec data.example. @10.53.0.2 txt >dig.out.ns2.test$n \
     54   1.1.1.7  christos   || ret=1
     55   1.1.1.7  christos grep "REFUSED" dig.out.ns2.test$n >/dev/null || ret=1
     56       1.1  christos if [ $ret != 0 ]; then echo_i "failed"; fi
     57   1.1.1.7  christos status=$((status + ret))
     58       1.1  christos 
     59   1.1.1.7  christos n=$((n + 1))
     60       1.1  christos echo_i "non recursive query for a static-stub zone with server name should be rejected ($n)"
     61       1.1  christos ret=0
     62   1.1.1.7  christos $DIG $DIGOPTS +tcp +norec data.example.org. @10.53.0.2 txt >dig.out.ns2.test$n \
     63   1.1.1.7  christos   || ret=1
     64   1.1.1.7  christos grep "REFUSED" dig.out.ns2.test$n >/dev/null || ret=1
     65       1.1  christos if [ $ret != 0 ]; then echo_i "failed"; fi
     66   1.1.1.7  christos status=$((status + ret))
     67       1.1  christos 
     68   1.1.1.7  christos n=$((n + 1))
     69       1.1  christos echo_i "allow-query ACL ($n)"
     70       1.1  christos ret=0
     71       1.1  christos $DIG $DIGOPTS +tcp +norec data.example. @10.53.0.2 txt -b 10.53.0.7 \
     72   1.1.1.7  christos   >dig.out.ns2.test$n || ret=1
     73   1.1.1.7  christos grep "REFUSED" dig.out.ns2.test$n >/dev/null || ret=1
     74       1.1  christos if [ $ret != 0 ]; then echo_i "failed"; fi
     75   1.1.1.7  christos status=$((status + ret))
     76       1.1  christos 
     77   1.1.1.7  christos n=$((n + 1))
     78       1.1  christos echo_i "look for static-stub zone data with recursion (should be found) ($n)"
     79       1.1  christos ret=0
     80   1.1.1.7  christos $DIG $DIGOPTS +tcp +noauth data.example. @10.53.0.2 txt >dig.out.ns2.test$n || ret=1
     81       1.1  christos digcomp knowngood.dig.out.rec dig.out.ns2.test$n || ret=1
     82       1.1  christos if [ $ret != 0 ]; then echo_i "failed"; fi
     83   1.1.1.7  christos status=$((status + ret))
     84       1.1  christos 
     85   1.1.1.7  christos n=$((n + 1))
     86       1.1  christos echo_i "checking authoritative NS is ignored for delegation ($n)"
     87       1.1  christos ret=0
     88       1.1  christos # the auth server returns a different (and incorrect) NS for .example.
     89   1.1.1.7  christos $DIG $DIGOPTS +tcp example. @10.53.0.2 ns >dig.out.ns2.test1.$n || ret=1
     90   1.1.1.7  christos grep "ns4.example." dig.out.ns2.test1.$n >/dev/null || ret=1
     91       1.1  christos # but static-stub configuration should still be used
     92   1.1.1.7  christos $DIG $DIGOPTS +tcp data2.example. @10.53.0.2 txt >dig.out.ns2.test2.$n || ret=1
     93   1.1.1.7  christos grep "2nd test data" dig.out.ns2.test2.$n >/dev/null || ret=1
     94       1.1  christos if [ $ret != 0 ]; then echo_i "failed"; fi
     95   1.1.1.7  christos status=$((status + ret))
     96       1.1  christos 
     97   1.1.1.7  christos n=$((n + 1))
     98       1.1  christos echo_i "checking queries for a child zone of the static-stub zone ($n)"
     99       1.1  christos ret=0
    100       1.1  christos # prime the delegation to a child zone of the static-stub zone
    101   1.1.1.7  christos $DIG $DIGOPTS +tcp data1.sub.example. @10.53.0.2 txt >dig.out.ns2.test1.$n || ret=1
    102   1.1.1.7  christos grep "1st sub test data" dig.out.ns2.test1.$n >/dev/null || ret=1
    103       1.1  christos # temporarily disable the the parent zone
    104  1.1.1.10  christos cp ns3/named2.conf ns3/named.conf
    105   1.1.1.2  christos rndc_reload ns3 10.53.0.3
    106       1.1  christos # query the child zone again.  this should directly go to the child and
    107       1.1  christos # succeed.
    108   1.1.1.7  christos for i in 0 1 2 3 4 5 6 7 8 9; do
    109   1.1.1.7  christos   $DIG $DIGOPTS +tcp data2.sub.example. @10.53.0.2 txt >dig.out.ns2.test2.$n || ret=1
    110   1.1.1.7  christos   grep "2nd sub test data" dig.out.ns2.test2.$n >/dev/null && break
    111   1.1.1.7  christos   sleep 1
    112       1.1  christos done
    113   1.1.1.7  christos grep "2nd sub test data" dig.out.ns2.test2.$n >/dev/null || ret=1
    114       1.1  christos # re-enable the parent
    115  1.1.1.10  christos cp ns3/named1.conf ns3/named.conf
    116   1.1.1.2  christos rndc_reload ns3 10.53.0.3
    117       1.1  christos if [ $ret != 0 ]; then echo_i "failed"; fi
    118   1.1.1.7  christos status=$((status + ret))
    119       1.1  christos 
    120   1.1.1.7  christos n=$((n + 1))
    121       1.1  christos echo_i "checking authoritative NS addresses are ignored for delegation ($n)"
    122       1.1  christos ret=0
    123       1.1  christos # the auth server returns a different (and incorrect) A/AAA RR for .example.
    124   1.1.1.7  christos $DIG $DIGOPTS +tcp example. @10.53.0.2 a >dig.out.ns2.test1.$n || ret=1
    125   1.1.1.7  christos grep "10.53.0.4" dig.out.ns2.test1.$n >/dev/null || ret=1
    126   1.1.1.7  christos $DIG $DIGOPTS +tcp example. @10.53.0.2 aaaa >dig.out.ns2.test2.$n || ret=1
    127   1.1.1.7  christos grep "::1" dig.out.ns2.test2.$n >/dev/null || ret=1
    128       1.1  christos # reload the server.  this will flush the ADB.
    129   1.1.1.2  christos rndc_reload ns2 10.53.0.2
    130       1.1  christos # ask another RR that would require delegation.  static-stub configuration
    131       1.1  christos # should still be used instead of the authoritative A/AAAA cached above.
    132   1.1.1.7  christos $DIG $DIGOPTS +tcp data3.example. @10.53.0.2 txt >dig.out.ns2.test3.$n || ret=1
    133   1.1.1.7  christos grep "3rd test data" dig.out.ns2.test3.$n >/dev/null || ret=1
    134       1.1  christos if [ $ret != 0 ]; then echo_i "failed"; fi
    135   1.1.1.7  christos status=$((status + ret))
    136       1.1  christos 
    137       1.1  christos # the authoritative server of the query domain (example.com) is the apex
    138       1.1  christos # name of the static-stub zone (example).  in this case the static-stub
    139       1.1  christos # configuration must be ignored and cached information must be used.
    140   1.1.1.7  christos n=$((n + 1))
    141       1.1  christos echo_i "checking NS of static-stub is ignored when referenced from other domain ($n)"
    142       1.1  christos ret=0
    143   1.1.1.7  christos $DIG $DIGOPTS +tcp data.example.com. @10.53.0.2 txt >dig.out.ns2.test$n || ret=1
    144   1.1.1.7  christos grep "example com data" dig.out.ns2.test$n >/dev/null || ret=1
    145       1.1  christos if [ $ret != 0 ]; then echo_i "failed"; fi
    146   1.1.1.7  christos status=$((status + ret))
    147       1.1  christos 
    148       1.1  christos # check server-names
    149   1.1.1.7  christos n=$((n + 1))
    150       1.1  christos echo_i "checking static-stub with a server-name ($n)"
    151       1.1  christos ret=0
    152   1.1.1.7  christos $DIG $DIGOPTS +tcp data.example.org. @10.53.0.2 txt >dig.out.ns2.test$n || ret=1
    153   1.1.1.7  christos grep "example org data" dig.out.ns2.test$n >/dev/null || ret=1
    154       1.1  christos if [ $ret != 0 ]; then echo_i "failed"; fi
    155   1.1.1.7  christos status=$((status + ret))
    156       1.1  christos 
    157   1.1.1.7  christos n=$((n + 1))
    158       1.1  christos # Note: for a short term workaround we use ::1, assuming it's configured and
    159       1.1  christos # usable for our tests.  We should eventually use the test ULA and available
    160       1.1  christos # checks introduced in change 2916.
    161   1.1.1.7  christos if testsock6 ::1; then
    162   1.1.1.7  christos   echo_i "checking IPv6 static-stub address ($n)"
    163   1.1.1.7  christos   ret=0
    164   1.1.1.7  christos   $DIG $DIGOPTS +tcp data.example.info. @10.53.0.2 txt >dig.out.ns2.test$n || ret=1
    165   1.1.1.7  christos   grep "example info data" dig.out.ns2.test$n >/dev/null || ret=1
    166   1.1.1.7  christos   if [ $ret != 0 ]; then echo_i "failed"; fi
    167   1.1.1.7  christos   status=$((status + ret))
    168       1.1  christos else
    169   1.1.1.7  christos   echo_i "SKIPPED: checking IPv6 static-stub address ($n)"
    170       1.1  christos fi
    171       1.1  christos 
    172   1.1.1.7  christos n=$((n + 1))
    173       1.1  christos echo_i "look for static-stub zone data with DNSSEC validation ($n)"
    174       1.1  christos ret=0
    175   1.1.1.7  christos $DIG $DIGOPTS +tcp +dnssec data4.example. @10.53.0.2 txt >dig.out.ns2.test$n || ret=1
    176   1.1.1.7  christos grep "ad; QUERY" dig.out.ns2.test$n >/dev/null || ret=1
    177   1.1.1.7  christos grep "4th test data" dig.out.ns2.test$n >/dev/null || ret=1
    178       1.1  christos if [ $ret != 0 ]; then echo_i "failed"; fi
    179   1.1.1.7  christos status=$((status + ret))
    180       1.1  christos 
    181   1.1.1.7  christos n=$((n + 1))
    182       1.1  christos echo_i "look for a child of static-stub zone data with DNSSEC validation ($n)"
    183       1.1  christos ret=0
    184   1.1.1.7  christos $DIG $DIGOPTS +tcp +dnssec data3.sub.example. @10.53.0.2 txt >dig.out.ns2.test$n || ret=1
    185   1.1.1.7  christos grep "ad; QUERY" dig.out.ns2.test$n >/dev/null || ret=1
    186   1.1.1.7  christos grep "3rd sub test data" dig.out.ns2.test$n >/dev/null || ret=1
    187       1.1  christos if [ $ret != 0 ]; then echo_i "failed"; fi
    188   1.1.1.7  christos status=$((status + ret))
    189       1.1  christos 
    190   1.1.1.4  christos # reload with a different name server: existing zone shouldn't be reused.
    191   1.1.1.7  christos n=$((n + 1))
    192       1.1  christos echo_i "checking server reload with a different static-stub config ($n)"
    193       1.1  christos ret=0
    194  1.1.1.10  christos cp ns2/named2.conf ns2/named.conf
    195   1.1.1.2  christos rndc_reload ns2 10.53.0.2
    196   1.1.1.7  christos $DIG $DIGOPTS +tcp data2.example.org. @10.53.0.2 txt >dig.out.ns2.test$n || ret=1
    197   1.1.1.7  christos grep "2nd example org data" dig.out.ns2.test$n >/dev/null || ret=1
    198       1.1  christos if [ $ret != 0 ]; then echo_i "failed"; fi
    199   1.1.1.7  christos status=$((status + ret))
    200       1.1  christos 
    201   1.1.1.7  christos n=$((n + 1))
    202       1.1  christos echo_i "checking static-stub of a undelegated tld resolves after DS query ($n)"
    203       1.1  christos ret=0
    204   1.1.1.8  christos $DIG $DIGOPTS undelegated. @10.53.0.2 ds >dig.out.ns2.ds.test$n || ret=1
    205   1.1.1.8  christos $DIG $DIGOPTS undelegated. @10.53.0.2 soa >dig.out.ns2.soa.test$n || ret=1
    206   1.1.1.7  christos grep "status: NXDOMAIN" dig.out.ns2.ds.test$n >/dev/null || ret=1
    207   1.1.1.7  christos grep "status: NOERROR" dig.out.ns2.soa.test$n >/dev/null || ret=1
    208       1.1  christos if [ $ret != 0 ]; then echo_i "failed"; fi
    209   1.1.1.7  christos status=$((status + ret))
    210       1.1  christos 
    211   1.1.1.8  christos n=$((n + 1))
    212   1.1.1.8  christos echo_i "checking static-stub synthesised NS is not returned ($n)"
    213   1.1.1.8  christos ret=0
    214   1.1.1.8  christos $DIG $DIGOPTS unsigned. @10.53.0.2 ns >dig.out.ns2.ns.test$n || ret=1
    215   1.1.1.8  christos sleep 2
    216   1.1.1.8  christos $DIG $DIGOPTS data.unsigned @10.53.0.2 txt >dig.out.ns2.txt1.test$n || ret=1
    217   1.1.1.8  christos sleep 4
    218   1.1.1.8  christos $DIG $DIGOPTS data.unsigned @10.53.0.2 txt >dig.out.ns2.txt2.test$n || ret=1
    219   1.1.1.8  christos grep "status: NOERROR" dig.out.ns2.ns.test$n >/dev/null || ret=1
    220   1.1.1.8  christos grep "status: NOERROR" dig.out.ns2.txt1.test$n >/dev/null || ret=1
    221   1.1.1.8  christos # NS RRset from zone is returned
    222   1.1.1.8  christos grep '^unsigned\..*NS.ns\.unsigned\.$' dig.out.ns2.txt1.test$n >/dev/null || ret=1
    223   1.1.1.8  christos grep '^unsigned\..*NS.unsigned\.$' dig.out.ns2.txt1.test$n >/dev/null && ret=1
    224   1.1.1.8  christos # NS expired and synthesised response is not returned
    225   1.1.1.8  christos grep "status: NOERROR" dig.out.ns2.txt2.test$n >/dev/null || ret=1
    226   1.1.1.8  christos grep '^unsigned\..*NS.ns\.unsigned\.$' dig.out.ns2.txt2.test$n >/dev/null && ret=1
    227   1.1.1.8  christos grep '^unsigned\..*NS.unsigned\.$' dig.out.ns2.txt2.test$n >/dev/null && ret=1
    228   1.1.1.8  christos if [ $ret != 0 ]; then echo_i "failed"; fi
    229   1.1.1.8  christos status=$((status + ret))
    230   1.1.1.8  christos 
    231       1.1  christos echo_i "exit status: $status"
    232       1.1  christos [ $status -eq 0 ] || exit 1
    233