The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

IO::Socket::DNS::Server - Net::DNS::Nameserver personality to handle IO::Socket::DNS client connections.

SYNOPSIS

  use IO::Socket::DNS::Server;

  my $server = new IO::Socket::DNS::Server
    Suffix    => $dns_suffix,
    LocalAddr => \@ips,
    LocalPort => $port,
    Password  => $secret,
    Verbose   => 5,
    IdleTimeout => $timeout,
      or die "Unable to start DNS server";

DESCRIPTION

Listens for DNS queries in order to proxy for use by IO::Socket::DNS clients.

CONSTRUCTOR

The "new" constructor takes arguments in key-value pairs:

  Suffix        Proxy DNS Suffix               Required.
  SOA           Authoritative IP for Suffix    Defaults to Suffix's authority
  LocalAddr     IP address on which to listen  Defaults to SOA IP
  LocalPort     Port on which to listen.       Defaults to 53.
  NotifyHandler NS_NOTIFY (RFC1996) handler    Optional.
  Password      Access password                <password>
  Verbose       Used for debugging             Defaults to 0 (off).

The "Suffix" argument is really the only requirement. This setting may also be passed via the DNS_SUFFIX environment variable. It must be a domain or subdomain for which queries will authoritatively arrive to the machine running this IO::Socket::DNS::Server software.

The "SOA" argument is the IP that will be provided in the authority records for all relevant DNS responses. If none is provided, then it will attempt to automatically determine this based on Suffix by resolving all its NS entries found in global propagation.

The "LocalAddr" argument may be one IP or an array ref of IP addresses to bind to. This defaults to the SOA IP is none is supplied, instead of the BINY_ANY address that the default Net::DNS::Nameserver uses.

The "NotifyHandler" code ref is the handler for NS_NOTIFY (RFC1996) queries. This is just passed through to Net::DNS::Nameserver, but it is not required.

The "Password" setting is to ensure only approved IO::Socket::DNS clients can connect to this server. Only the first 8 characters are used. This setting may also be passed via the DNS_PASSWORD environment variable. Default is no password.

If "Verbose" is specified, additional diagnostic information will be sent to STDOUT.

EXAMPLES

  my $server = IO::Socket::DNS::Server->new(
    Suffix    => "s.example.com",
    SOA       => "199.200.201.202",
    LocalAddr => "192.168.100.2",
    LocalPort => 5353,
    Password  => "No Geeks",
    Verbose   => 6,
  ) or die "connect: $!";

  $ENV{DNS_SUFFIX} = "s.example.com";
  my $server = new IO::Socket::DNS::Server;

  # Continuously handle requests
  $server->main_loop;

SEE ALSO

dnsd, Net::DNS::Nameserver, IO::Socket::DNS

AUTHOR

Rob Brown, <bbb@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2011 by Rob Brown

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