} else
strlcpy(zonebuf, zonetxt, DNS_NAME_FORMATSIZE);
if (zonename != NULL)
- strlcpy(zonename, zonetxt, DNS_NAME_FORMATSIZE);
+ strlcpy(zonename, redirect ? "." : zonetxt,
+ DNS_NAME_FORMATSIZE);
dns_fixedname_init(&fname);
name = dns_fixedname_name(&fname);
dns_zone_detach(&raw);
}
type = dns_zone_gettype(zone);
- if (type == dns_zone_slave || type == dns_zone_stub)
+ if (type == dns_zone_slave || type == dns_zone_stub ||
+ (type == dns_zone_redirect &&
+ dns_zone_getredirecttype(zone) == dns_zone_slave))
dns_zone_forcereload(zone);
else
result = ISC_R_NOTFOUND;
static const cfg_obj_t *
find_name_in_list_from_map(const cfg_obj_t *config,
const char *map_key_for_list,
- const char *name)
+ const char *name, isc_boolean_t redirect)
{
const cfg_obj_t *list = NULL;
const cfg_listelt_t *element;
if (name1 != NULL) {
result = dns_name_fromstring(name2, vname, 0, NULL);
if (result == ISC_R_SUCCESS &&
- dns_name_equal(name1, name2))
- break;
+ dns_name_equal(name1, name2)) {
+ const cfg_obj_t *zoptions;
+ const cfg_obj_t *typeobj = NULL;
+ zoptions = cfg_tuple_get(obj, "options");
+
+ if (zoptions != NULL)
+ cfg_map_get(zoptions, "type", &typeobj);
+ if (redirect && typeobj != NULL &&
+ strcasecmp(cfg_obj_asstring(typeobj),
+ "redirect") == 0)
+ break;
+ else if (!redirect)
+ break;
+ }
} else if (strcasecmp(vname, name) == 0)
break;
#ifdef HAVE_LMDB
cfg_obj_t *nzconfig = NULL;
#endif /* HAVE_LMDB */
+ isc_boolean_t added, redirect;
/* Parse parameters */
CHECK(zone_from_args(server, lex, NULL, &zone, zonename,
goto cleanup;
}
+ redirect = dns_zone_gettype(zone) == dns_zone_redirect;
+ added = dns_zone_getadded(zone);
view = dns_zone_getview(zone);
dns_zone_detach(&zone);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
exclusive = ISC_TRUE;
- /* Find the view statement */
- vconfig = find_name_in_list_from_map(cfg->config, "view", view->name);
+ if (!added) {
+ /* Find the view statement */
+ vconfig = find_name_in_list_from_map(cfg->config, "view",
+ view->name, ISC_FALSE);
- /* Find the zone statement */
- if (vconfig != NULL)
- map = cfg_tuple_get(vconfig, "options");
- else
- map = cfg->config;
+ /* Find the zone statement */
+ if (vconfig != NULL)
+ map = cfg_tuple_get(vconfig, "options");
+ else
+ map = cfg->config;
- zconfig = find_name_in_list_from_map(map, "zone", zonename);
+ zconfig = find_name_in_list_from_map(map, "zone", zonename,
+ redirect);
+ }
#ifndef HAVE_LMDB
if (zconfig == NULL && cfg->nzf_config != NULL)
rm -f dig.out.*
rm -f rndc.out*
+rm -f showzone.out*
+rm -f zonestatus.out*
rm -f ns2/named.conf
rm -f */named.memstats
+rm -f ns1/*.nzf
+rm -f ns1/*.nzf~
+rm -f ns1/*.nzd ns1/*.nzd-lock
rm -f ns2/*.nzf
rm -f ns2/*.nzf~
rm -f ns2/*.nzd ns2/*.nzd-lock
rm -f ns*/named.lock
rm -f ns*/named.run
rm -f ns2/nzf-*
+rm -f ns1/redirect.db
+rm -f ns2/redirect.db
+rm -f ns2/redirect.bk
+rm -f ns3/redirect.db
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-/* $Id: named1.conf,v 1.2 2010/08/11 18:14:19 each Exp $ */
+key rndc_key {
+ secret "1234abcd8765";
+ algorithm hmac-sha256;
+};
-controls { /* empty */ };
+controls {
+ inet 10.53.0.1 port 9953 allow { any; } keys { rndc_key; };
+};
options {
port 5300;
listen-on { 10.53.0.1; };
listen-on-v6 { none; };
allow-query { any; };
+ allow-new-zones yes;
recursion no;
};
type master;
file "inlineslave.db";
};
+
+zone "." {
+ type redirect;
+ file "redirect.db";
+};
--- /dev/null
+; Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+;
+; This Source Code Form is subject to the terms of the Mozilla Public
+; License, v. 2.0. If a copy of the MPL was not distributed with this
+; file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+@ 0 SOA . . 1 0 0 0 0
+@ 0 NS .
--- /dev/null
+; Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+;
+; This Source Code Form is subject to the terms of the Mozilla Public
+; License, v. 2.0. If a copy of the MPL was not distributed with this
+; file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+@ 0 SOA . . 0 0 0 0 0
+@ 0 NS .
--- /dev/null
+; Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+;
+; This Source Code Form is subject to the terms of the Mozilla Public
+; License, v. 2.0. If a copy of the MPL was not distributed with this
+; file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+@ 0 SOA . . 1 0 0 0 0
+@ 0 NS .
--- /dev/null
+/*
+ * Copyright (C) 2013, 2016 Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+key rndc_key {
+ secret "1234abcd8765";
+ algorithm hmac-sha256;
+};
+
+controls {
+ inet 10.53.0.3 port 9953 allow { any; } keys { rndc_key; };
+};
+
+options {
+ port 5300;
+ pid-file "named.pid";
+ listen-on { 10.53.0.3; };
+ listen-on-v6 { none; };
+ recursion no;
+};
+
+zone "." {
+ type master;
+ file "redirect.db";
+};
--- /dev/null
+; Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+;
+; This Source Code Form is subject to the terms of the Mozilla Public
+; License, v. 2.0. If a copy of the MPL was not distributed with this
+; file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+@ 0 SOA . . 0 0 0 0 0
+@ 0 NS .
+@ 0 A 127.0.0.1
--- /dev/null
+; Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+;
+; This Source Code Form is subject to the terms of the Mozilla Public
+; License, v. 2.0. If a copy of the MPL was not distributed with this
+; file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+@ 0 SOA . . 1 0 0 0 0
+@ 0 NS .
+@ 0 A 127.0.0.1
$SHELL clean.sh
+cp -f ns1/redirect.db.1 ns1/redirect.db
+cp -f ns2/redirect.db.1 ns2/redirect.db
+cp -f ns3/redirect.db.1 ns3/redirect.db
cp -f ns2/named1.conf ns2/named.conf
cp -f ns2/default.nzf.in ns2/3bf305731dd26307.nzf
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
+echo "I:checking rndc showzone with a normally-loaded redirect zone ($n)"
+ret=0
+$RNDC -c ../common/rndc.conf -s 10.53.0.1 -p 9953 showzone -redirect > rndc.out.ns1.$n
+expected='zone "." { type redirect; file "redirect.db"; };'
+[ "`cat rndc.out.ns1.$n`" = "$expected" ] || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+echo "I:checking rndc zonestatus with a normally-loaded redirect zone ($n)"
+ret=0
+$RNDC -c ../common/rndc.conf -s 10.53.0.1 -p 9953 zonestatus -redirect > rndc.out.ns1.$n
+grep "type: redirect" rndc.out.ns1.$n > /dev/null || ret=1
+grep "serial: 0" rndc.out.ns1.$n > /dev/null || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+echo "I:checking rndc reload with a normally-loaded redirect zone ($n)"
+ret=0
+sleep 1
+cp -f ns1/redirect.db.2 ns1/redirect.db
+$RNDC -c ../common/rndc.conf -s 10.53.0.1 -p 9953 reload -redirect > rndc.out.ns1.$n
+$RNDC -c ../common/rndc.conf -s 10.53.0.1 -p 9953 zonestatus -redirect > zonestatus.out.ns1.$n
+grep "type: redirect" zonestatus.out.ns1.$n > /dev/null || ret=1
+grep "serial: 1" zonestatus.out.ns1.$n > /dev/null || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
echo "I:delete a normally-loaded zone ($n)"
ret=0
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone normal.example > rndc.out.ns2.$n 2>&1
echo "I:check that adding a 'master redirect' zone works ($n)"
ret=0
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone '"." { type redirect; file "redirect.db"; };' > rndc.out.ns2.$n 2>&1 || ret=1
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 showzone -redirect > showzone.out.ns2.$n 2>&1 || ret=1
+grep "type redirect;" showzone.out.ns2.$n > /dev/null || ret=1
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 zonestatus -redirect > zonestatus.out.ns2.$n 2>&1 || ret=1
+grep "type: redirect" zonestatus.out.ns2.$n > /dev/null || ret=1
+grep "serial: 0" zonestatus.out.ns2.$n > /dev/null || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+
+echo "I:check that reloading a added 'master redirect' zone works ($n)"
+ret=0
+sleep 1
+cp -f ns2/redirect.db.2 ns2/redirect.db
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reload -redirect > rndc.out.ns2.$n
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 zonestatus -redirect > zonestatus.out.ns2.$n 2>&1 || ret=1
+grep "type: redirect" zonestatus.out.ns2.$n > /dev/null || ret=1
+grep "serial: 1" zonestatus.out.ns2.$n > /dev/null || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+
+echo "I:check that retransfer of a added 'master redirect' zone fails ($n)"
+ret=0
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 retransfer -redirect > rndc.out.ns2.$n 2>&1 && ret=1
n=`expr $n + 1`
if [ $ret != 0 ]; then echo "I:failed"; fi
-status=`expr $status + $ret`
echo "I:check that deleting a 'master redirect' zone works ($n)"
ret=0
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone -redirect > rndc.out.ns2.$n 2>&1 || ret=1
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 showzone -redirect > showzone.out.ns2.$n 2>&1
+grep 'not found' showzone.out.ns2.$n > /dev/null || ret=1
n=`expr $n + 1`
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:check that adding a 'slave redirect' zone works ($n)"
ret=0
-$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone '"." { type redirect; masters { 1.2.3.4; }; file "redirect.bk"; };' > rndc.out.ns2.$n 2>&1 || ret=1
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone '"." { type redirect; masters { 10.53.0.3;}; file "redirect.bk"; };' > rndc.out.ns2.$n 2>&1 || ret=1
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 showzone -redirect > showzone.out.ns2.$n 2>&1 || ret=1
+grep "type redirect;" showzone.out.ns2.$n > /dev/null || ret=1
+sleep 1
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 zonestatus -redirect > zonestatus.out.ns2.$n 2>&1 || ret=1
+grep "type: redirect" zonestatus.out.ns2.$n > /dev/null || ret=1
+grep "serial: 0" zonestatus.out.ns2.$n > /dev/null || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+echo "I:check that retransfering a added 'slave redirect' zone works ($n)"
+ret=0
+cp -f ns3/redirect.db.2 ns3/redirect.db
+$RNDC -c ../common/rndc.conf -s 10.53.0.3 -p 9953 reload . > showzone.out.ns3.$n 2>&1 || ret=1
+sleep 1
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 retransfer -redirect > rndc.out.ns2.$n 2>&1 || ret=1
+sleep 1
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 zonestatus -redirect > zonestatus.out.ns2.$n 2>&1 || ret=1
+grep "type: redirect" zonestatus.out.ns2.$n > /dev/null || ret=1
+grep "serial: 1" zonestatus.out.ns2.$n > /dev/null || ret=1
n=`expr $n + 1`
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:check that deleting a 'slave redirect' zone works ($n)"
ret=0
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone -redirect > rndc.out.ns2.$n 2>&1 || ret=1
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 showzone -redirect > showzone.out.ns2.$n 2>&1
+grep 'not found' showzone.out.ns2.$n > /dev/null || ret=1
n=`expr $n + 1`
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
<command>zone</command> <replaceable>"."</replaceable> [ <replaceable>class</replaceable> ] <command>{</command>
<command>type</command> redirect;
- <command>file</command> <replaceable>string</replaceable> ;
+ [ <command>file</command> <replaceable>string</replaceable> ; ]
+ [ <command>masters</command> [ <command>port</command> <replaceable>ip_port</replaceable> ] [ <command>dscp</command> <replaceable>ip_dscp</replaceable> ] <command>{</command>
+ ( <replaceable>masters_list</replaceable> | <replaceable>ip_addr</replaceable> [ <command>port</command> <replaceable>ip_port</replaceable> ] ) [ <command>key</command> <replaceable>key_name</replaceable> ] ;
+ ...
+ <command>}</command> ; ]
[ <command>masterfile-format</command> ( <option>text</option> | <option>raw</option> | <option>map</option> ) ; ]
[ <command>allow-query</command> <command>{</command> <replaceable>address_match_list</replaceable> <command>}</command> ; ]
[ <command>max-zone-ttl</command> <replaceable>number</replaceable> ; ]
possible types; it is not limited to A and
AAAA records.
</para>
+ <para>
+ If a redirect zone is configured with a
+ <option>masters</option> option, then it is
+ transfered in as if it were a slave zone.
+ Otherwise, it is loaded from a file as if it
+ were a master zone.
+ </para>
<para>
Because redirect zones are not referenced
directly by name, they are not kept in the
zone lookup table with normal master and slave
- zones. Consequently, it is not currently possible
- to use
- <command>rndc reload
- <replaceable>zonename</replaceable></command>
- to reload a redirect zone. However, when using
- <command>rndc reload</command> without specifying
- a zone name, redirect zones will be reloaded along
- with other zones.
+ zones. To reload a redirect zone, use
+ <command>rndc reload -redirect</command>,
+ and to retransfer a redirect zone configured
+ as slave, use
+ <command>rndc retransfer -redirect</command>.
+ When using <command>rndc reload</command>
+ without specifying a zone name, redirect zones
+ will be reloaded along with other zones.
</para>
</entry>
</row>
*\li 'zone' to be valid initialised zone.
*/
+dns_zonetype_t
+dns_zone_getredirecttype(dns_zone_t *zone);
+/*%<
+ * Returns whether the redirect zone is configured as a master or a
+ * slave zone.
+ *
+ * Requires:
+ *\li 'zone' to be valid initialised zone.
+ *\li 'zone' to be a redirect zone.
+ *
+ * Returns:
+ *\li 'dns_zone_master'
+ *\li 'dns_zone_slave'
+ */
+
void
dns_zone_settask(dns_zone_t *zone, isc_task_t *task);
/*%<
dns_zone_getqueryonacl
dns_zone_getraw
dns_zone_getrcvquerystats
+dns_zone_getredirecttype
dns_zone_getrefreshkeytime
dns_zone_getrefreshtime
dns_zone_getrequestexpire
return (zone->type);
}
+dns_zonetype_t
+dns_zone_getredirecttype(dns_zone_t *zone) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+ REQUIRE(zone->type == dns_zone_redirect);
+
+ return (zone->masters == NULL ? dns_zone_master : dns_zone_slave);
+}
+
dns_name_t *
dns_zone_getorigin(dns_zone_t *zone) {
REQUIRE(DNS_ZONE_VALID(zone));