0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# Copyright (C) 2000, 2001, 2004, 2007, 2012, 2016 Internet Systems Consortium, Inc. ("ISC")
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews#
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# file, You can obtain one at http://mozilla.org/MPL/2.0/.
c0003bfcaffdb03cea7da20d47592c37b6a07fa9Brian Wellington
70e5a7403f0e0a3bd292b8287c5fed5772c15270Automatic Updater# $Id: lookup.tcl,v 1.10 2007/06/19 23:47:08 tbox Exp $
ef491b68cd4d65839f09171df243aeaf013247bfAndreas Gustafsson
22aa1c0bc258e6c2c7491e2e330e3c363daa2b80Andreas Gustafsson#
22aa1c0bc258e6c2c7491e2e330e3c363daa2b80Andreas Gustafsson# Sample lookup procedure for tcldb
22aa1c0bc258e6c2c7491e2e330e3c363daa2b80Andreas Gustafsson#
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson# This lookup procedure defines zones with identical SOA, NS, and MX
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson# records at the apex and a single A record that varies from zone to
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson# zone at the name "www".
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson#
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson# Something like this could be used by a web hosting company to serve
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson# a number of domains without needing to create a separate master file
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson# for each domain. Instead, all per-zone data (in this case, a single
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson# IP address) specified in the named.conf file like this:
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson#
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson# zone "a.com." { type master; database "tcl 10.0.0.42"; };
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson# zone "b.com." { type master; database "tcl 10.0.0.99"; };
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson#
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson# Since the tcldb driver doesn't support zone transfers, there should
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson# be at least two identically configured master servers. In the
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson# example below, they are assumed to be called ns1.isp.nil and
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson# ns2.isp.nil.
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson#
22aa1c0bc258e6c2c7491e2e330e3c363daa2b80Andreas Gustafsson
22aa1c0bc258e6c2c7491e2e330e3c363daa2b80Andreas Gustafssonproc lookup {zone name} {
22aa1c0bc258e6c2c7491e2e330e3c363daa2b80Andreas Gustafsson global dbargs
22aa1c0bc258e6c2c7491e2e330e3c363daa2b80Andreas Gustafsson switch -- $name {
22aa1c0bc258e6c2c7491e2e330e3c363daa2b80Andreas Gustafsson @ { return [list \
3c0454fe259ed70a752d49b86a46026fb4f0c733Andreas Gustafsson {SOA 86400 "ns1.isp.nil. hostmaster.isp.nil. \
740af672b43473dce3095aa3f05fd0a820d9d756Andreas Gustafsson 1 3600 1800 1814400 3600"} \
3c0454fe259ed70a752d49b86a46026fb4f0c733Andreas Gustafsson {NS 86400 "ns1.isp.nil."} \
3c0454fe259ed70a752d49b86a46026fb4f0c733Andreas Gustafsson {NS 86400 "ns2.isp.nil."} \
22aa1c0bc258e6c2c7491e2e330e3c363daa2b80Andreas Gustafsson {MX 86400 "10 mail.isp.nil."} ] }
22aa1c0bc258e6c2c7491e2e330e3c363daa2b80Andreas Gustafsson www { return [list [list A 3600 $dbargs($zone)] ] }
22aa1c0bc258e6c2c7491e2e330e3c363daa2b80Andreas Gustafsson }
22aa1c0bc258e6c2c7491e2e330e3c363daa2b80Andreas Gustafsson return NXDOMAIN
22aa1c0bc258e6c2c7491e2e330e3c363daa2b80Andreas Gustafsson}