Skip to content

Instantly share code, notes, and snippets.

@markjenkins markjenkins/Makefile
Created Mar 15, 2016

Embed
What would you like to do?
$INCLUDE "/etc/bind/common_TTL_SOA_NS_CNAME_MX_for_cool_zones.db";
@ A 192.168.1.186
$INCLUDE "/etc/bind/common_TTL_SOA_NS_CNAME_MX_for_cool_zones.db";
@ A 127.0.0.1
; default TTL
$TTL 3h
; common SOA
@ IN SOA cool.tld. domains.cool.tld. (
2008081401 ; serial, todays date + todays serial
3H ; slave refresh frequency
15M ; slave retry rate when refresh fails
4W ; expire time until slaves give up on refresh
2D ) ; minimum-TTL if one isn't specified
; common NS
@ NS cool.tld.
; common CNAME
www CNAME @
; common MX
@ MX 10 cool.tld.
$INCLUDE "/etc/bind/common_TTL_SOA_NS_CNAME_MX_A_for_cool_zones.db";
$INCLUDE "/etc/bind/cool_extra_sub_domains.db";
pics CNAME @
chat CNAME @
$INCLUDE "/etc/bind/common_TTL_SOA_NS_CNAME_MX_A_for_internal_cool_zones.db";
$INCLUDE "/etc/bind/cool_extra_sub_domains.db";
#!/usr/bin/env python
from optparse import OptionParser
from sys import stdout
option_parser = OptionParser()
option_parser.add_option("-p", "--prefix", default="")
option_parser.add_option("-s", "--suffix", default="")
(options, args) = option_parser.parse_args()
def iterjoin(join_str, iterable):
first = True
for value in iterable:
if not first:
yield join_str
else:
first = False
yield value
if len(args) > 0:
input_file = file(args[0])
stdout.writelines(
iterjoin("\n",
("""zone "%(zone_name)s" {
\tfile "%(file_prefix)s%(zone_name)s%(file_suffix)s";
\ttype master;
};
""" % {'zone_name': line.strip(),
'file_prefix': options.prefix,
'file_suffix': options.suffix, }
for line in input_file
if len(line.strip()) > 0 ) ) )
input_file.close()
else:
exit(1)
# Makefile
ZONE_LIST=zone_list_file
ZONE_FILE_SUFFIX=".db"
all: zone_list.zones internal_zone_list.zones
zone_list.zones: $(ZONE_LIST) Makefile
./make_zone_list --prefix "/etc/bind/" \
--suffix $(ZONE_FILE_SUFFIX) $^ > $@
internal_zone_list.zones: $(ZONE_LIST) Makefile
./make_zone_list --prefix "/etc/bind/internal_" \
--suffix $(ZONE_FILE_SUFFIX) $^ > $@
// this is named.conf, it implements split DNS
include "/etc/bind/named.conf.options";
view "local_network"
{
match-clients {localhost; };
recursion yes;
// prime the server with knowledge of the root servers
zone "." {
type hint;
file "/etc/bind/db.root";
};
// Consider adding the 1918 zones here, if they are not used in your
// organization
include "/etc/bind/zones.rfc1918";
// be authoritative for the localhost forward and reverse zones, and for
// broadcast zones as per RFC 1912
zone "localhost" {
type master;
file "/etc/bind/db.local";
};
zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
};
include "/etc/bind/internal_zone_list.zones";
};
view "external_network"
{
match-clients {!localhost; any; };
recursion no;
// prime the server with knowledge of the root servers
zone "." {
type hint;
file "/etc/bind/db.root";
};
include "/etc/bind/zone_list.zones";
};
zone "cool.tld" {
file "/etc/bind/cool.tld.db";
type master;
};
cool.tld
super.tld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.