diff --git a/named/GNUmakefile.in b/named/GNUmakefile.in new file mode 100644 index 0000000000000000000000000000000000000000..4e1f299fd8e548d0dc6e6f2a3e80e3708130dc4b --- /dev/null +++ b/named/GNUmakefile.in @@ -0,0 +1,74 @@ +# +# EMULAB-COPYRIGHT +# Copyright (c) 2000-2004 University of Utah and the Flux Group. +# All rights reserved. +# + +SRCDIR = @srcdir@ +TESTBED_SRCDIR = @top_srcdir@ +OBJDIR = .. +SUBDIR = named + +ETCDIR = /etc +NAMEDB_DIR = $(ETCDIR)/namedb +OURDOMAIN = @OURDOMAIN@ + +# This is silly. Needs to be done properly. +TESTBED_NETWORK = @TESTBED_NETWORK@ +REVERSE_MAPNAME = $(subst .0,,$(TESTBED_NETWORK)) + +NAMED_FILES = named.conf.template named_makeconf \ + reverse.head resolv.conf localhost.rev forward.head \ + $(REVERSE_MAPNAME).db.head $(OURDOMAIN).db.head \ + named.conf + +include $(OBJDIR)/Makeconf + +# +# Force dependencies on the scripts so that they will be rerun through +# configure if the .in file is changed. +# +all: $(NAMED_FILES) + +include $(TESTBED_SRCDIR)/GNUmakerules + +# This file is just a copy for now. Ick. +$(REVERSE_MAPNAME).db.head: reverse.head + cp reverse.head $(REVERSE_MAPNAME).db.head + +$(OURDOMAIN).db.head: forward.head + cp forward.head $(OURDOMAIN).db.head + +named.conf: named.conf.template named_makeconf + perl named_makeconf named.conf.template > named.conf + +# This is not a safe install target after initial install! +install: + echo "Are you sure you want to reinstall the namedb files!" + +install-real: $(NAMEDB_DIR)/named.conf \ + $(NAMEDB_DIR)/localhost.rev \ + $(NAMEDB_DIR)/$(OURDOMAIN).db.head \ + $(NAMEDB_DIR)/reverse/$(REVERSE_MAPNAME).db.head \ + $(ETCDIR)/resolv.conf + -rm -rf $(NAMEDB_DIR)/$(OURDOMAIN).internal.db.head + ln -s $(OURDOMAIN).db.head $(NAMEDB_DIR)/$(OURDOMAIN).internal.db.head + +clean: + rm -f $(NAMED_FILES) + +$(ETCDIR)/%: % + @echo "Installing $<" + -mkdir -p $(ETCDIR) + $(INSTALL) $< $@ + +$(NAMEDB_DIR)/%: % + @echo "Installing $<" + -mkdir -p $(NAMEDB_DIR) + $(INSTALL) $< $@ + +$(NAMEDB_DIR)/reverse/%: % + @echo "Installing $<" + -mkdir -p $(NAMEDB_DIR)/reverse + $(INSTALL) $< $@ + diff --git a/named/forward.head.in b/named/forward.head.in new file mode 100644 index 0000000000000000000000000000000000000000..c84ed9eef747569c7b649799bdefb78a5fb7e0ab --- /dev/null +++ b/named/forward.head.in @@ -0,0 +1,46 @@ +; +; Authoritative data for @OURDOMAIN@ +; + +$TTL 30 + +@ IN SOA @BOSSNODE@. testbed-ops.@BOSSNODE@. ( + 30 ; Serial (leaveme) + 3600 ; Refresh + 900 ; Retry + 3600000 ; Expire + 3600 ) ; Minimum + IN NS ns.@OURDOMAIN@. + +$TTL 30 + + +; '@OURDOMAIN@' is implied in the line below + IN A @BOSSNODE_IP@ + IN MX 10 ops + +; Apparently, CNAME NS records are a bad idea - so, ns.emulab.net +; and boss are both A records +ns IN A @BOSSNODE_IP@ +boss IN A @BOSSNODE_IP@ + IN MX 10 ops + +; CNAMEs for boss +www IN CNAME boss +db IN CNAME boss +cvsup IN CNAME boss + +; Plastic and names it is otherwise known as... +ops IN A @USERNODE_IP@ + IN MX 10 ops +users IN CNAME ops +fs IN CNAME ops +ntp1 IN CNAME ops +ntp2 IN CNAME ops +event-server IN CNAME ops + +; Routers interfaces in the various subnets +private-router IN A @PRIVATE_ROUTER@ +public-router IN A @PUBLIC_ROUTER@ +control-router IN A @CONTROL_ROUTER_IP@ + diff --git a/named/localhost.rev.in b/named/localhost.rev.in new file mode 100644 index 0000000000000000000000000000000000000000..874c0353188919ca885fcc1478e4d5bfada3439e --- /dev/null +++ b/named/localhost.rev.in @@ -0,0 +1,11 @@ +$TTL 3600 + +@ IN SOA @BOSSNODE@. testbed-ops.@BOSSNODE@. ( + 69 ; Serial (leaveme) + 3600 ; Refresh + 900 ; Retry + 3600000 ; Expire + 3600 ) ; Minimum + IN NS @BOSSNODE@. + IN PTR localhost.@OURDOMAIN@. + diff --git a/named/named.conf.template.in b/named/named.conf.template.in new file mode 100644 index 0000000000000000000000000000000000000000..b1c81ed3fbf046f974db1cd20a86bc03485cdd23 --- /dev/null +++ b/named/named.conf.template.in @@ -0,0 +1,77 @@ +# +# DNS configuration for @BOSSNODE@ +# + +##################### +# IMPORTANT!!!! +# +# Note that there are now two 'views' in this file, and unfortunately, we +# have to duplicate all zones in both of them! So, if you make any zone +# changes, make sure to make them in both places!!! +##################### + +# +# global server configuration options +# +options { + directory "/etc/namedb"; + # Put forwarders here if you have them + #forwarders { + # 1.1.1.1; + #}; +}; + +view "internal" { + match-clients { + 127.0.0.0/8; + %internal_network_withmask%; + 172.16.0.0/12; + }; + + zone "@OURDOMAIN@" in { + type master; + file "@OURDOMAIN@.internal.db"; + }; + + zone "0.0.127.in-addr.arpa" { + type master; + file "localhost.rev"; + }; + + zone "." in { + type hint; + file "named.root"; + }; + + zone "%internal_network_dotted_reverse%.in-addr.arpa" in { + type master; + file "reverse/%internal_network_dotted%.db"; + }; +}; + +view "external" { + match-clients { + any; + }; + + zone "@OURDOMAIN@" in { + type master; + file "@OURDOMAIN@.db"; + }; + + zone "0.0.127.in-addr.arpa" { + type master; + file "localhost.rev"; + }; + + zone "." in { + type hint; + file "named.root"; + }; + + zone "%internal_network_dotted_reverse%.in-addr.arpa" in { + type master; + file "reverse/%internal_network_dotted%.db"; + }; +}; + diff --git a/named/named_makeconf.in b/named/named_makeconf.in new file mode 100755 index 0000000000000000000000000000000000000000..67db335e0c0d8e6565b6f1698b955dade0feaedb --- /dev/null +++ b/named/named_makeconf.in @@ -0,0 +1,97 @@ +#!/usr/bin/perl -w + +# +# EMULAB-COPYRIGHT +# Copyright (c) 2000-2004 University of Utah and the Flux Group. +# All rights reserved. +# +use Getopt::Std; +use Socket; + +# +# named_makeconf - helper script to create named.conf file. The template +# looks like standard file, only with %token% strings that need to be +# replaced. See below. +# +sub usage { + print "Usage: $0 <templatefile>\n"; + print "Spits out a named.conf file on stdout, as in:\n"; + print "$0 named.conf.template > named.conf\n"; +} + +# +# Configure variables +# +my $TESTBED_NETWORK = "@TESTBED_NETWORK@"; +my $TESTBED_NETMASK = "@TESTBED_NETMASK@"; +my $BOSSNODE_IP = "@BOSSNODE_IP@"; +my $USERNODE_IP = "@USERNODE_IP@"; +my $CONTROL_ROUTER_IP = "@CONTROL_ROUTER_IP@"; +my $CONTROL_NETWORK = "@CONTROL_NETWORK@"; +my $CONTROL_NETMASK = "@CONTROL_NETMASK@"; +my $PRIVATE_NETWORK = "@PRIVATE_NETWORK@"; +my $PRIVATE_ROUTER = "@PRIVATE_ROUTER@"; +my $PRIVATE_NETMASK = "@PRIVATE_NETMASK@"; +my $PUBLIC_NETWORK = "@PUBLIC_NETWORK@"; +my $PUBLIC_ROUTER = "@PUBLIC_ROUTER@"; +my $PUBLIC_NETMASK = "@PUBLIC_NETMASK@"; + +# Testbed libraries. +use lib "@prefix@/lib"; +use libdb; + +# Simple is good. I stole this out of a google search. +my @NETMASKS = + (0x10000000, # 0 + 0x80000000, 0xC0000000, 0xE0000000, 0xF0000000, # 1 - 4 + 0xF8000000, 0xFC000000, 0xFE000000, 0xFF000000, # 5 - 8 + 0xFF800000, 0xFFC00000, 0xFFE00000, 0xFFF00000, # 9 - 12 + 0xFFF80000, 0xFFFC0000, 0xFFFE0000, 0xFFFF0000, # 13 - 16 + 0xFFFF8000, 0xFFFFC000, 0xFFFFE000, 0xFFFFF000, # 17 - 20 + 0xFFFFF800, 0xFFFFFC00, 0xFFFFFE00, 0xFFFFFF00, # 21 - 24 + 0xFFFFFF80, 0xFFFFFFC0, 0xFFFFFFE0, 0xFFFFFFF0, # 25 - 28 + 0xFFFFFFF8, 0xFFFFFFFC, 0xFFFFFFFE, 0xFFFFFFFF # 29 - 32 +); + +my $TESTBED_SLASH_NETMASK = "24"; +for (my $i = 0; $i < scalar(@NETMASKS); $i++) { + my $foo = pack("N", $NETMASKS[$i]); + + if ($TESTBED_NETMASK eq inet_ntoa($foo)) { + $TESTBED_SLASH_NETMASK = "$i"; + last; + } +} + +# This is for the dotted and reverse dotted notation needed for the +# reverse maps. This is probably all wrong ... +my ($a, $b, $c, $d) = ($TESTBED_NETWORK =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/); + +$infile = shift @ARGV || exit &usage; + +open(IF,"<$infile") or + die("Unable to open $infile for reading\n"); + +while (<IF>) { + if (/^(.*)\%([-\w]*)\%(.*)$/) { + if ($2 eq "internal_network_withmask") { + print $1 . "${TESTBED_NETWORK}/${TESTBED_SLASH_NETMASK}" ."$3\n"; + } + elsif ($2 eq "internal_network_dotted") { + print $1 . "${a}.${b}.${c}" . "$3\n"; + } + elsif ($2 eq "internal_network_dotted_reverse") { + print $1 . "${c}.${b}.${a}" . "$3\n"; + } + else { + die("*** $0:\n". + " Unknown special tag in named template file!\n"); + } + } + else { + # It's a regular line + print; + } +} +close(IF); +exit(0); diff --git a/named/resolv.conf.in b/named/resolv.conf.in new file mode 100644 index 0000000000000000000000000000000000000000..28b950bbc8257c2d20725c852541f5afa81ceb4b --- /dev/null +++ b/named/resolv.conf.in @@ -0,0 +1,3 @@ +domain @OURDOMAIN@ +search @OURDOMAIN@ +nameserver 127.0.0.1 diff --git a/named/reverse.head.in b/named/reverse.head.in new file mode 100644 index 0000000000000000000000000000000000000000..c00ef1ecd8ad735de122ddca8f90752112cae9b1 --- /dev/null +++ b/named/reverse.head.in @@ -0,0 +1,11 @@ +$TTL 10800 + +@ IN SOA @BOSSNODE@. testbed-ops.@BOSSNODE@. ( + 14 ; Serial (leaveme) + 3600 ; Refresh + 900 ; Retry + 3600000 ; Expire + 3600 ) ; Minimum + IN NS ns.@OURDOMAIN@. + +