Commit 810a6fea authored by Leigh Stoller's avatar Leigh Stoller

New directory to create the initial named configuration from a set of

template files. This is rather simplistic, but should suffice for
generating a working set of files that can then be customized by the
site as needed.

BIG TODO: Deal with multiple reverse maps when the netmask is greater
then /24, and requires a set of reverse maps, not just one.
parent b7e1fd03
#
# 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) $< $@
;
; 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@
$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@.
#
# 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";
};
};
#!/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);
domain @OURDOMAIN@
search @OURDOMAIN@
nameserver 127.0.0.1
$TTL 10800
@ IN SOA @BOSSNODE@. testbed-ops.@BOSSNODE@. (
14 ; Serial (leaveme)
3600 ; Refresh
900 ; Retry
3600000 ; Expire
3600 ) ; Minimum
IN NS ns.@OURDOMAIN@.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment