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

NAME

Net::DNS::Create - Create DNS configurations from a nice Perl structure based DSL.

SYNOPSIS

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


# Then, for each domain you have:
domain "example.com", { %records };      # The simplest way.
domain "example.net", { %records },      # Records in %more_records override
                      { %more_records }; # the ones in %record

# Then,
master "master.conf", "/etc/bind/"; # Bind (which requires absolute paths)
# or
master "data";                      # Tiny
# or
master;                             # Route53


# The different records Types:
domain "example.com", {
  'www' => { a => '127.0.0.1' },            # names are non-qualified
  'www1' => { a => ['127.0.0.2',
                    '127.0.0.3'] },         # Use an array for multiple As

  'www2' => { cname => 'www' },             # no trailing dot for local names
  'www2' => { cname => '@' },               # @ is supported
  'www3' => { cname => 'a.example.net.' },  # trailing-dot for external names

  '@' => { soa => { primary_ns => 'ns1.example.com.',
                    rp_email   => 'some-email@example.com',
                    serial     => 1234, # Set this to zero for auto-serial
                    refresh    => '8h',
                    retry      => '2h',
                    expire     => '4w',
                    min_ttl    => '1h' } },

  'a' => { ns => 'ns1.example.com.' },
  'b' => { ns => ['ns1', 'ns2'] },           # use an array for multiple NSes

  'c' => { mx => { 0  => 'mail',
                   10 => 'smtp' } },

  'd' => { txt => "v=spf1 mx -all" },
  'e' => { txt => ["v=spf1 mx -all",         # use an array for multiple TXTs
                   "another different text record" ] },

  '_carddavs._tcp' => { srv => { "www"  => { port => 443 },
                                             # priority & weight default to 0
                                 "www2" => { port => 443,
                                             priority => 2,
                                             weight   => 3 }, } },

  'server' => { rp => ['david@example.com', david.people] },

  'server2' => { rp => [['david@example.com', david.people] # use an array for
                        ['bob@example.com', bob.people]] }, # multiple RPs
};

# Multiple record types for a name
domain "example.com", {
   '@' => { soa => { ... },
            ns  => ['ns1', 'ns2'],
            mx  => { 0  => 'mail',
                     10 => 'smtp' },
            txt => "v=spf1 mx -all",
            a   => '127.0.0.1' },
};

# Overriding specific records
my %standard = ('@' => { soa => { ... },
                         ns  => ['ns1', 'ns2'],
                         mx  => { 0  => 'mail',
                                  10 => 'smtp' },
                         txt => "v=spf1 mx -all",
                         a   => '127.0.0.1' });

domain "example.com", { %standard }, {
  '@' => { a => '127.0.0.2' },  # 'A' record overridden, others remain intact.
};

DESCRIPTION

Net::DNS::Create lets you specify your DNS configuration in a Perl script so that all the duplication that normally occurs in DNS config files can be expressed with variables and functions. This ultimately results in a (hopefully) DRY (Don't Repeat Yourself) representation of your DNS config data, making it easier and less error prone to change.

Net::DNS::Create supports multiple backends which means you can change out your DNS server software with minimal effort.

TIME INTERVALS

The default_ttl option and the SOA record's refresh retry, expire, and min_ttl parameters all take time intervals. They can be conveniently specified using units:

s -> seconds
m -> minutes
h -> hours
d -> days
w -> weeks

This way you can say "1h" instead of "3600" and "2w" instead of "1209600".

OPTIONS

Options to the backends are specified in the use line. For instance:

use Net::DNS::Create qw(Bind), default_ttl => "1h", conf_prefix => "local_", dest_dir => "./bind";

The following options are generic to all the backends:

default_ttl

This lets you set the default TTL for the entries. Currently there is no way to set TTLs for individual records.

The default value is "1h".

See a backend's documentation for the descriptions of the backend's specific options.

SEE ALSO

Net::DNS::Create::Bind

Net::DNS::Create::Tiny

Net::DNS::Create::Route53

The Net::DNS::Create Home Page

AUTHOR

David Caldwell <david@porkrind.org>

COPYRIGHT AND LICENSE

Copyright (C) 2009-2014 by David Caldwell

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.12.4 or, at your option, any later version of Perl 5 you may have available.