The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
#!/usr/bin/perl

# Choose 1:
use Net::DNS::Create qw(Bind), default_ttl => "1h", conf_prefix => "local_", dest_dir => "./bind";
#use Net::DNS::Create qw(Tiny), default_ttl => "1h";
#use Net::DNS::Create qw(Route53), default_ttl => "1h", amazon_id => "AKIxxxxxxx", amazon_key => "kjdhakjsfnothisisntrealals";


my $localhost = '127.0.0.1';

domain 'example.com', {
    '@'                      => {     soa   => { primary_ns => 'ns1.example.com.',
                                                 rp_email   => 'some-email@example.com',
                                                 serial     => 1234,
                                                 refresh    => '8h',
                                                 retry      => '2h',
                                                 expire     => '4w',
                                                 min_ttl    => '1h' },
                                      ns    => [ 'ns1.example.com.', 'ns2.example.com.' ],
                                      a     => $localhost,
                                      mx    => { 0  => 'mail',
                                                 10 => 'smtp' },
                                      txt   => ["v=spf1 mx -all",
                                                "another different text record"] },
    'www'                    => { a     => $localhost,
                                  rp    => ['david@example.com', 'david.people'] },
    'david.people'           => { txt   => 'For a good time call: 555-1212' },
    'www2'                   => { cname => "www" },
    'www3'                   => { cname => "@" },
    'external'               => { cname => "external.example.net." },
    'mail'                   => { a     => $localhost },
    'smtp'                   => { a     => $localhost },
    'example._domainkey'     => { txt   => "v=DKIM1; n=blah =20 Blah; g=*; k=rsa; p=THISISNOTAREALDOMAINKEYJUSTANEXAMPLENOREALLYBLAHBLAHBLAHDOMAINKEYDOMAINKEYDOMAINKE".
				           "YTHISISNOTAREALDOMAINKEYJUSTANEXAMPLENOREALLYBLAHBLAHBLAHDOMAINKEYDOMAINKEYDOMAINKETHISISNOTAREALDOMAINKEYJUSTANEXAMPLENOR".
					   "EALLYBLAHBLAHBLAHDOMAINKEYDOMAINKEYDOMAINKETHISISNOTAREALDOMAINKEYJUSTANEXAMPLENOREALLYBLAHBLAHBLAHDOMAINKEYDOMAINKEYDOMAI".
					   "NKEYTHISISNOTAREALDOMAINKEY" },
    '_adsp._domainkey'       => { txt   => "dkim=all" },
    stuff                    => { a => $localhost },
    'more.stuff'             => { a => $localhost },
    'even.more.stuff'        => { a => $localhost },
    'tons.of.stuff'          => { a => $localhost },
    'ns1'                    => { a => $localhost },
    'ns2'                    => { a => $localhost },
    calendar                 => { a => $localhost },
    '_carddavs._tcp'         => { srv   => { "calendar.example.com." => { port => 443 } } },
}, {
    # Another section. Anything in here overrides the previous sections
    mail                     => { a => '127.0.0.2' },
    '@'                      => { a => '127.0.0.3' }, # Doesn't stomp over @'s NS, SOA, MX, or TXT.
};

# Bind:
master "master.conf";
# Real bind requires absolute paths in their includes, so this will prefix
# the include files with "/etc/bind" in master.conf:
#master "master.conf", "/etc/bind/";

# Tiny:
#master "data";

# Route53:
#master