Skip to content

Instantly share code, notes, and snippets.

@markjenkins
Created March 15, 2016 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markjenkins/0468e956e8f310562b09 to your computer and use it in GitHub Desktop.
Save markjenkins/0468e956e8f310562b09 to your computer and use it in GitHub Desktop.
$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