Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
TestNS(3)	      User Contributed Perl Documentation	     TestNS(3)

NAME
       Net::DNS::TestNS	- Perl extension for simulating	simple Nameservers

SYNOPSIS
       use Net::DNS::TestNS;

ABSTRACT
       Class for setting up "simple DNS" servers.

DESCRIPTION
       Class to	setup a	number of nameservers that respond to specific DNS
       queries (QNAME,QTYPE) by	prespecified answers. This class is to be used
       in test suites where you	want to	have servers to	show predefined
       behavior.

       If the server will do a lookup based on QNAME,QTYPE and return the
       specified data. If there	is no QNAME, QTYPE match the server will
       return a	SERVFAIL.

       A log will be written to	STDERR it contains time, IP/PORT, QNAME,
       QTYPE, RCODE

   Configuration file
       The class uses an XML file to read its configuration. The DTD is
       documented in Net::DNS::TestNS::DTD.

       The setup is split in a number of servers, each with a unique IP/port
       number, each server has 1 or more QNAMEs	it will	respond	to. Each QNAME
       can have	QTYPEs specified.

       For each	QNAME,QTYPE an answer needs to be specified, response code and
       header bits can be tweaked through the qtype attributes.

       The content of the packet can be	specified through ans, aut and add
       elements, each specifying one RR	record to end up in the	answer,
       authority or additional section.

       The optional 'delay' attribute in the QTYPE element specifies how many
       seconds the server should wait until an answer is returned.

       If the query does not match against data	specified in the configuration
       a SERVFAIL is returned.

   new
	   my $server=Net::DNS::TestNS->new($configfile, {
	    Verbose => 1,
	       Validate	=> 1,
	   });

       Read the	configuration files and	bind to	ports.	One can	use <!--
       include="file" --> anywhere inside the configuration file to include
       other XML configuration fragments.

       The second optional argument is hash that contains customization
       parameters.
	   Verbose  boolean	Makes the code more verbose.
	   Validate boolean	Turns on XML validation	based
				on the DTD
				The parser is flexible with
				respect	to the ordering
				of some	of the XML elements.
				The DTD	is not.
				Validation is on by default.

       new returns the object reference	on success and 0 on failure. On
       failure the class variable $Net::DNS::TestNS::errorcondition is set.

   verbose
	   $self->verbose(1);

       Sets verbosity at run time.

   run
       Spawns off the servers and process the data.

   medea
       Cleanup function	that kills all the children spawned by the instance.
       Also known by its alias 'stop'.

Configuration file example
       <?xml version="1.0" standalone="no"?>
	<testns	version="1.0">
	<server	ip="127.0.0.1" port="5354">
	  <qname name="bla.foo">
	    <qtype type="TXT" delay="1">
	     <header>
	       <rcode value="NOERROR"/>
	       <aa value="1"/>
	       <ra value="0"/>
	       <ad value="0"/>
	       <qr value="0"/>
	       <tc value="1"/>
	       <id value="1234"/>
	       <ancount	value="1"/>
	       <nscount	value="1"/>
	     </header>
	     <ans>
	       bla.foo.	 3600 IN TXT "TEXT"
	     </ans>
	     <ans>
	       bla.foo.		 3600	  IN	 TXT	 "Other	text"
	     </ans>
	    </qtype>
	  </qname>
	  <qname name="raw.foo">
	   <qtype type="TXT" delay="1">
	    <header>
	     <rcode value="NOERROR"/>
	       <aa value="1"/>
	       <ra value="0"/>
	       <ad value="0"/>
	       <qr value="0"/>
	       <tc value="1"/>
	       <id value="1234"/>
	      <ancount value="1"/>
	     </header>
	   <raw>
	    <!-- QNAME -->
	    07 74726967676572	<!-- trigger -->
	    03 666f6f		<!-- foo -->
	    00			<!-- closing octet  -->
	    <!-- QTYPE -->
	    00 01		<!-- A RR -->
	    <!-- QCLASS	-->
	    00 01

	  <!-- Answer section -->

	    c0 0c		<!-- Points up -->
	    00 01		<!-- type A -->
	    00 01		<!-- class IN -->
	    00 00 00 05		<!-- ttl 5 seconds  -->
	    00 04		<!-- RD	length 4 octets	-->
	    0a 00 00 01		<!-- 10.0.0.1 -->
	    </raw>
	  </qtype>
	 </qname>

	</server>
       </testns>

Known Deficiencies and TODO
       The module is based on Net::DNS::Nameserver. There is no	way to
       distinguish if the query	came over TCP or UDP; besides UDP truncation
       is not available	in Net::DNS::Nameserver.

       Earlier versions	of this	script used a different	DTD that had no
       version number. The script only validates against version 1.0 of	the
       DTD but parses the old files.

       ==head1 ALSO SEE	Net::DNS::TestNS::DTD, Net::DNS, Net::DNS::RR

AUTHOR
       Olaf Kolkman, <olaf@net-dns.org<gt>

COPYRIGHT AND LICENSE
       Copyright (c) 2003-2005	RIPE NCC.  Author Olaf M. Kolkman
       <olaf@net-dns.net>

       All Rights Reserved

       Permission to use, copy,	modify,	and distribute this software and its
       documentation for any purpose and without fee is	hereby granted,
       provided	that the above copyright notice	appear in all copies and that
       both that copyright notice and this permission notice appear in
       supporting documentation, and that the name of the author not be	used
       in advertising or publicity pertaining to distribution of the software
       without specific, written prior permission.

       THE AUTHOR DISCLAIMS ALL	WARRANTIES WITH	REGARD TO THIS SOFTWARE,
       INCLUDING ALL IMPLIED WARRANTIES	OF MERCHANTABILITY AND FITNESS;	IN NO
       EVENT SHALL AUTHOR BE LIABLE FOR	ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
       DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM	LOSS OF	USE, DATA OR
       PROFITS,	WHETHER	IN AN ACTION OF	CONTRACT, NEGLIGENCE OR	OTHER TORTIOUS
       ACTION, ARISING OUT OF OR IN CONNECTION WITH THE	USE OR PERFORMANCE OF
       THIS SOFTWARE.

perl v5.24.1			  2008-12-30			     TestNS(3)

NAME | SYNOPSIS | ABSTRACT | DESCRIPTION | Configuration file example | Known Deficiencies and TODO | AUTHOR | COPYRIGHT AND LICENSE

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=Net::DNS::TestNS&sektion=3&manpath=FreeBSD+12.0-RELEASE+and+Ports>

home | help