NAME

Enum::DNSserver - A DNS Name Server Framework for Perl.

SYNOPSIS

use Enum::DNSserver;

$ns = new Enum::DNSserver;

$ns->add_static($domain, $type, $value, $ttl);
$ns->add_dynamic($domain, $handler);

$ns->answer_queries();

DESCRIPTION

Enum::DNSserver is a DNS name server framework. It allows you to make any information accessible with perl available via DNS. To put it another way, it's a name server with a perl back end.

METHODS

new [ %arguments ]

Allocates and returns a new Enum::DNSserver object. The optional arguments can be used to tailor how the name server works. Here they are:

  • listen_on => \@interfaces

    A reference to an array of interfaces to listen on. Interfaces can be specified by name or IP address. If listen_on is not specified, the host name is used.

  • port => PORT

    The port to listen on. The default is 53.

  • defttl => SECONDS

    The default time to live value for answers given out by the name server. The default is 3600 seconds.

  • debug => LEVEL

    The debug level.

  • daemon => 'yes' | 'no'

    Tells whether the name server should become a detached daemon. The default is 'yes'.

  • pidfile => FILENAME

    File in which to store the process ID of the name server process. No file is created unless this argument is present.

  • logfunc => \&function

    A reference to a function taking a single string argument. This function is called with any messages the name server logs. No logging is performed unless this argument is present.

  • loopfunc => \&function

    A reference to a function to run every time through the inner server loop, i.e. for each query or every 10 minutes if there are no queries. Use this to do any periodic maintenance.

  • exitfunc => \&function

    A reference to a function to run when the name server exits. Use this for any final cleanup. Note that Enum::DNSserver catches INT, QUIT, and TERM signals, so providing an exitfunc is the only way to clean up when any of those signals are received.

  • dontwait => 0 | 1

    Enum::DNSserver forks to handle TCP DNS queries. It catches SIGCHLD in order to wait(3) for these processes. Setting dontwait to 1 tells Enum::DNSserver not to catch SIGCHLD nor wait for those forked processes. Use dontwait when your program provides a SIGCHLD handler - just be sure to wait(3) for the forked TCP processes.

add_static $domain, $type, $value, $ttl

Add a domain with the specified properties to the DNS server. When the DNS server is queried for this domain it will respond with the given answer.

add_dynamic $domain, $handler

Add a domain with the specified handler to the DNS server. When the DNS server is queried for any name in this domain, it runs the specified handler as follows:

&$handler($domain, $residual, $type, $class, $dnsmsg, $from);

where

  • $domain is the domain in the query.

  • $residual is the name in the query.

  • $type is the type of the query.

  • $class is the class of the query.

  • $dnsmsg is a pointer to the DNS message. The handler may add answers and/or authority records to the DNS message using functions from the Enum::DNS module.

  • $from is the name or IP address of the system that made the query.

answer_queries

Start listening for DNS queries and answer them as specified by previous calls to add_static and add_dynamic.

CONTRIBUTIONS

Enum::DNSserver is based on lbnamed by Roland Schemers. Initial transformation from lbnamed into Enum::DNSserver by Marco d'Itri. Multiple interface support by Dan Astoorian. Further suggestions and code from Aidan Cully and Mike Mitchell. Module name suggested by Ivan Kohler. Integration, modernization, documentation and final assembly by Rob Riepel.

SEE ALSO

Enum::DNS