# 127.12.2.0/24   | Basic02 scenarios                                           |
# 127.12.2.21     | ns1.basic02.xa                                              |
# 127.12.2.22     | ns2.basic02.xa                                              |
# 127.12.2.23     | root-ns1.xa                                                 |
# 127.12.2.24     | root-ns1.xa                                                 |
# 127.12.2.25     | ns1.basic02.xa                                              |
# 127.12.2.26     | ns2.basic02.xa                                              |
# 127.12.2.31     | ns1 child zone                                              |
# 127.12.2.32     | ns2 child zone                                              |
# 127.12.2.33     | ns3 child zone                                              |
# 127.12.2.34     | ns4 child zone                                              |
# 127.12.2.53     | resolver with test case local hint                          |


## root
.:53 {
    bind 127.12.2.23               # ns1
    bind fda1:b2:c3:0:127:12:2:23  # ns1
    bind 127.12.2.24               # ns2
    bind fda1:b2:c3:0:127:12:2:24  # ns2
    log
    file Basic-TP/basic02/root-zone.zone .
}

# Resolver using test case local root
. {
    bind 127.12.2.53
    unbound {
       option root-hints Basic-TP/basic02/hintfile.zone
    }
    log
}


basic02.xa:53 {
    bind 127.12.2.21               # ns1
    bind fda1:b2:c3:0:127:12:2:21  # ns1
    bind 127.12.2.22               # ns2
    bind fda1:b2:c3:0:127:12:2:22  # ns2
    log
    file Basic-TP/basic02/basic02.xa.zone basic02.xa
}


basic02.xb:53 { # xb
    bind 127.12.2.25               # ns1
    bind fda1:b2:c3:0:127:12:2:25  # ns1
    bind 127.12.2.26               # ns2
    bind fda1:b2:c3:0:127:12:2:26  # ns2
    log
    file Basic-TP/basic02/basic02.xb.zone basic02.xb
}

### Child zones


good-1.basic02.xa:53 {
    bind 127.12.2.31               # ns1
    bind fda1:b2:c3:0:127:12:2:31  # ns1
    bind 127.12.2.32               # ns2
    bind fda1:b2:c3:0:127:12:2:32  # ns2
    log
    file Basic-TP/basic02/CHILD-ns1-ns2-IB.basic02.xa.zone good-1.basic02.xa
}


good-2.basic02.xa:53 {
    bind 127.12.2.31               # ns1.good-2.basic02.xb.
    bind fda1:b2:c3:0:127:12:2:31  # ns1.good-2.basic02.xb.
    bind 127.12.2.32               # ns2.good-2.basic02.xb.
    bind fda1:b2:c3:0:127:12:2:32  # ns2.good-2.basic02.xb.
    log
    file Basic-TP/basic02/good-2.basic02.xa.zone good-2.basic02.xa
}


good-undel-1.basic02.xa:53 {
    # Undelegated
    bind 127.12.2.31               # ns1
    bind fda1:b2:c3:0:127:12:2:31  # ns1
    bind 127.12.2.32               # ns2
    bind fda1:b2:c3:0:127:12:2:32  # ns2
    log
    file Basic-TP/basic02/CHILD-ns1-ns2-IB.basic02.xa.zone good-undel-1.basic02.xa
}


good-undel-2.basic02.xa:53 {
    # Undelegated
    bind 127.12.2.31               # ns1.good-undel-2.basic02.xb.
    bind fda1:b2:c3:0:127:12:2:31  # ns1.good-undel-2.basic02.xb.
    bind 127.12.2.32               # ns2.good-undel-2.basic02.xb.
    bind fda1:b2:c3:0:127:12:2:32  # ns2.good-undel-2.basic02.xb.
    log
    file Basic-TP/basic02/good-undel-2.basic02.xa.zone good-undel-2.basic02.xa
}


good-undel-3.basic02.xa:53 {
    # Delegated
    bind 127.12.2.31               # ns1
    bind fda1:b2:c3:0:127:12:2:31  # ns1
    bind 127.12.2.32               # ns2
    bind fda1:b2:c3:0:127:12:2:32  # ns2
    log
    acl good-undel-3.basic02.xa {
        drop
    }
}
good-undel-3.basic02.xa:53 {
    # Undelegated
    bind 127.12.2.33               # ns3.good-undel-3.basic02.xb.
    bind fda1:b2:c3:0:127:12:2:33  # ns3.good-undel-3.basic02.xb.
    bind 127.12.2.34               # ns4.good-undel-3.basic02.xb.
    bind fda1:b2:c3:0:127:12:2:34  # ns4.good-undel-3.basic02.xb.
    log
    file Basic-TP/basic02/good-undel-3.basic02.xa.zone good-undel-3.basic02.xa
}


# good-undel-4.basic02.xa, delegated IB without glue
#
good-undel-4.basic02.xa:53 {
    # Undelegated
    bind 127.12.2.31               # ns1.good-undel-4.basic02.xb.
    bind fda1:b2:c3:0:127:12:2:31  # ns1.good-undel-4.basic02.xb.
    bind 127.12.2.32               # ns2.good-undel-4.basic02.xb.
    bind fda1:b2:c3:0:127:12:2:32  # ns2.good-undel-4.basic02.xb.
    log
    file Basic-TP/basic02/good-undel-4.basic02.xa.zone good-undel-4.basic02.xa
}


# good-undel-5.basic02.xa, delegated IB without glue
#
good-undel-5.basic02.xa:53 {
    # Undelegated
    bind 127.12.2.31               # ns1
    bind fda1:b2:c3:0:127:12:2:31  # ns1
    bind 127.12.2.32               # ns2
    bind fda1:b2:c3:0:127:12:2:32  # ns2
    log
    file Basic-TP/basic02/CHILD-ns1-ns2-IB.basic02.xa.zone good-undel-5.basic02.xa
}


good-undel-6.basic02.xa:53 {
    # Delegated
    bind 127.12.2.31               # ns1.good-undel-6.basic02.xb.
    bind fda1:b2:c3:0:127:12:2:31  # ns1.good-undel-6.basic02.xb.
    bind 127.12.2.32               # ns2.good-undel-6.basic02.xb.
    bind fda1:b2:c3:0:127:12:2:32  # ns2.good-undel-6.basic02.xb.
    log
    acl good-undel-6.basic02.xa {
        drop
    }
}
good-undel-6.basic02.xa:53 {
    # Undelegated
    bind 127.12.2.33               # ns3
    bind fda1:b2:c3:0:127:12:2:33  # ns3
    bind 127.12.2.34               # ns4
    bind fda1:b2:c3:0:127:12:2:34  # ns4
    log
    file Basic-TP/basic02/CHILD-ns3-ns4-IB.basic02.xa.zone good-undel-6.basic02.xa
}


# good-undel-7.basic02.xa, delegated OOB with no address records
#
good-undel-7.basic02.xa:53 {
    # Undelegated
    bind 127.12.2.33               # ns3.good-undel-7.basic02.xb
    bind fda1:b2:c3:0:127:12:2:33  # ns3.good-undel-7.basic02.xb
    bind 127.12.2.34               # ns4.good-undel-7.basic02.xb
    bind fda1:b2:c3:0:127:12:2:34  # ns4.good-undel-7.basic02.xb
    log
    file Basic-TP/basic02/good-undel-7.basic02.xa.zone good-undel-7.basic02.xa
}


good-undel-8.basic02.xa:53 {
    # Delegated
    bind 127.12.2.31               # dns1, IP of ns1
    bind fda1:b2:c3:0:127:12:2:31  # dns1, IP of ns1
    bind 127.12.2.32               # dns2, IP of ns2
    bind fda1:b2:c3:0:127:12:2:32  # dns2, IP of ns2
    log
    acl good-undel-8.basic02.xa {
        drop
    }
}
good-undel-8.basic02.xa:53 {
    # Undelegated
    bind 127.12.2.33               # dns1, IP of ns3
    bind fda1:b2:c3:0:127:12:2:33  # dns1, IP of ns3
    bind 127.12.2.34               # dns2, IP of ns4
    bind fda1:b2:c3:0:127:12:2:34  # dns2, IP of ns4
    log
    file Basic-TP/basic02/good-undel-8.basic02.xa.zone good-undel-8.basic02.xa
}

good-undel-9.basic02.xa:53 {
    # Delegated
    bind 127.12.2.31               # dns1.good-undel-9.basic02.xb, IP of ns1
    bind fda1:b2:c3:0:127:12:2:31  # dns1.good-undel-9.basic02.xb, IP of ns1
    bind 127.12.2.32               # dns2.good-undel-9.basic02.xb, IP of ns2
    bind fda1:b2:c3:0:127:12:2:32  # dns2.good-undel-9.basic02.xb, IP of ns2
    log
    acl good-undel-9.basic02.xa {
        drop
    }
}
good-undel-9.basic02.xa:53 {
    # Undelegated
    bind 127.12.2.33               # dns1.good-undel-9.basic02.xb, IP of ns3
    bind fda1:b2:c3:0:127:12:2:33  # dns1.good-undel-9.basic02.xb, IP of ns3
    bind 127.12.2.34               # dns2.good-undel-9.basic02.xb, IP of ns4
    bind fda1:b2:c3:0:127:12:2:34  # dns2.good-undel-9.basic02.xb, IP of ns4
    log
    file Basic-TP/basic02/good-undel-9.basic02.xa.zone good-undel-9.basic02.xa
}

# no-delegation.basic02.xa, not delegated and no zone exists


good-undel-10.basic02.xa:53 {
    # Delegated
    bind 127.12.2.31               # ns1.good-undel-10.basic02.xb.
    bind fda1:b2:c3:0:127:12:2:31  # ns1.good-undel-10.basic02.xb.
    log
    template IN ANY good-undel-10.basic02.xa {
        rcode SERVFAIL
    }
}
good-undel-10.basic02.xa:53 {
    # Delegated
    bind 127.12.2.32               # ns2.good-undel-10.basic02.xb.
    bind fda1:b2:c3:0:127:12:2:32  # ns2.good-undel-10.basic02.xb.
    log
    template IN ANY good-undel-10.basic02.xa {
        rcode REFUSED
    }
    header {
        response clear aa
    }
}
good-undel-10.basic02.xa:53 {
    # Undelegated
    bind 127.12.2.33               # ns3.good-undel-10.basic02.xb
    bind fda1:b2:c3:0:127:12:2:33  # ns3.good-undel-10.basic02.xb
    bind 127.12.2.34               # ns4.good-undel-10.basic02.xb
    bind fda1:b2:c3:0:127:12:2:34  # ns4.good-undel-10.basic02.xb
    log
    file Basic-TP/basic02/good-undel-10.basic02.xa.zone good-undel-10.basic02.xa
}

# good-undel-11.basic02.xa, delegated, cannot be reached.
delegated.good-undel-11.basic02.xb:53 {
    # Zone to "hide" the resolution of the NS for the delegated zone
    bind 127.12.2.31               # dns1
    bind fda1:b2:c3:0:127:12:2:31  # dns1
    bind 127.12.2.32               # dns2
    bind fda1:b2:c3:0:127:12:2:32  # dns2
    log
    acl delegated.good-undel-11.basic02.xb {
        drop
    }
}
good-undel-11.basic02.xa:53 {
    # Undelegated
    bind 127.12.2.33               # ns3.good-undel-11.basic02.xb
    bind fda1:b2:c3:0:127:12:2:33  # ns3.good-undel-11.basic02.xb
    bind 127.12.2.34               # ns4.good-undel-11.basic02.xb
    bind fda1:b2:c3:0:127:12:2:34  # ns4.good-undel-11.basic02.xb
    log
    file Basic-TP/basic02/good-undel-11.basic02.xa.zone good-undel-11.basic02.xa
}


mixed-1.basic02.xa:53 {
    bind 127.12.2.31               # ns1
    bind fda1:b2:c3:0:127:12:2:31  # ns1
    log
    file Basic-TP/basic02/mixed-1.basic02.xa.zone mixed-1.basic02.xa
}
mixed-1.basic02.xa:53 {
    bind 127.12.2.32               # ns2
    bind fda1:b2:c3:0:127:12:2:32  # ns2
    log
    acl mixed-1..basic02.xb {
        drop
    }
}
mixed-1.basic02.xa:53 {
    bind 127.12.2.33               # ns3
    bind fda1:b2:c3:0:127:12:2:33  # ns3
    log
    template IN ANY mixed-1.basic02.xb {
        rcode SERVFAIL
    }
}
mixed-1.basic02.xa:53 {
    bind 127.12.2.34               # ns4
    bind fda1:b2:c3:0:127:12:2:34  # ns4
    log
    file Basic-TP/basic02/mixed-1.basic02.xa.zone mixed-1.basic02.xa
    header {
        response clear aa
    }
}


ns-broken-1.basic02.xa:53 {
    bind 127.12.2.31               # ns1
    bind fda1:b2:c3:0:127:12:2:31  # ns1
    bind 127.12.2.32               # ns2
    bind fda1:b2:c3:0:127:12:2:32  # ns2
    log
    template IN ANY ns-broken-1.basic02.xa {
        authority  "ns-broken-1.basic02.xa.  3600  IN NS ns1.ns-broken-1.basic02.xa."
        authority  "ns-broken-1.basic02.xa.  3600  IN NS ns2.ns-broken-1.basic02.xa."
        additional "ns1.ns-broken-1.basic02.xa 3600 IN A    127.12.2.31"
        additional "ns1.ns-broken-1.basic02.xa 3600 IN AAAA fda1:b2:c3:0:127:12:2:31"
        additional "ns2.ns-broken-1.basic02.xa 3600 IN A    127.12.2.32"
        additional "ns2.ns-broken-1.basic02.xa 3600 IN AAAA fda1:b2:c3:0:127:12:2:32"
    }
    header {
        response set aa
    }
}

ns-not-auth-1.basic02.xa:53 {
    bind 127.12.2.31               # ns1
    bind fda1:b2:c3:0:127:12:2:31  # ns1
    bind 127.12.2.32               # ns2
    bind fda1:b2:c3:0:127:12:2:32  # ns2
    log
    file Basic-TP/basic02/CHILD-ns1-ns2-IB.basic02.xa.zone ns-not-auth-1.basic02.xa
    header {
        response clear aa
    }
}

# ns-no-ip-1.basic02.xa, IB NS, no glue, no zone

# ns-no-ip-2.basic02.xa, OOB NS, no IP for NS, no zone

# ns-no-ip-3.basic02.xa. OOB NS, no NS names, no zone


ns-no-ip-undel-1.basic02.xa:53 {
    # Delegated
    bind 127.12.2.31               # ns1
    bind fda1:b2:c3:0:127:12:2:31  # ns1
    bind 127.12.2.32               # ns2
    bind fda1:b2:c3:0:127:12:2:32  # ns2
    log
    file Basic-TP/basic02/CHILD-ns1-ns2-IB.basic02.xa.zone ns-no-ip-undel-1.basic02.xa
}
# Undelegated IB NS without glue, no zone


ns-no-ip-undel-2.basic02.xa:53 {
    # Delegated
    bind 127.12.2.31               # ns1
    bind fda1:b2:c3:0:127:12:2:31  # ns1
    bind 127.12.2.32               # ns2
    bind fda1:b2:c3:0:127:12:2:32  # ns2
    log
    file Basic-TP/basic02/CHILD-ns1-ns2-IB.basic02.xa.zone ns-no-ip-undel-2.basic02.xa
}
# Undelegated OOB NS without glue, no zone


ns-no-response-1.basic02.xa:53 {
    bind 127.12.2.31               # ns1
    bind fda1:b2:c3:0:127:12:2:31  # ns1
    bind 127.12.2.32               # ns2
    bind fda1:b2:c3:0:127:12:2:32  # ns2
    log
    acl ns-no-response-1.basic02.xa {
        drop
    }
}


unexpected-rcode-1.basic02.xa:53 {
    bind 127.12.2.31               # ns1
    bind fda1:b2:c3:0:127:12:2:31  # ns1
    log
    template IN ANY unexpected-rcode-1.basic02.xa {
        authority  "basic02.xa. SOA ns1.basic.xa. admin. 2025040906 6h 1h 1w 1d"
        rcode NXDOMAIN
    }
}
unexpected-rcode-1.basic02.xa:53 {
    bind 127.12.2.32               # ns2
    bind fda1:b2:c3:0:127:12:2:32  # ns2
    log
    template IN ANY unexpected-rcode-1.basic02.xa {
        rcode REFUSED
    }
    header {
        response clear aa
    }

}
unexpected-rcode-1.basic02.xa:53 {
    bind 127.12.2.33               # ns3
    bind fda1:b2:c3:0:127:12:2:33  # ns3
    log
    template IN ANY unexpected-rcode-1.basic02.xa {
        rcode SERVFAIL
    }
}






