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

FreeBSD Manual Pages


home | help
Net::Nslookup(3)      User Contributed Perl Documentation     Net::Nslookup(3)

       Net::Nslookup - Provide nslookup(1)-like	capabilities

	 use Net::Nslookup;
	 my @addrs = nslookup $host;

	 my @mx	= nslookup(type	=> "MX", domain	=> "");

       "Net::Nslookup" provides	the capabilities of the	standard UNIX command
       line tool nslookup(1). "Net::DNS" is a wonderful	and full featured
       module, but quite often,	all you	need is	`nslookup $host`.  This	module
       provides	that functionality.

       "Net::Nslookup" exports a single	function, called "nslookup".
       "nslookup" can be used to retrieve A, PTR, CNAME, MX, NS, SOA, TXT, and
       SRV records.

	 my $a	= nslookup(host	=> "", type	=> "A");

	 my @mx	= nslookup(domain => "", type => "MX");

	 my @ns	= nslookup(domain => "", type => "NS");

	 my $name = nslookup(host => "", type => "PTR");

	 my @srv = nslookup(term => "", type => "SRV");

       "nslookup" takes	a hash of options, one of which	should be term,	and
       performs	a DNS lookup on	that term.  The	type of	lookup is determined
       by the type argument.  If server	is specified (it should	be an IP
       address,	or a reference to an array of IP addresses), that server(s)
       will be used for	lookups.

       If only a single	argument is passed in, the type	defaults to A, that
       is, a normal A record lookup.

       If "nslookup" is	called in a list context, and there is more than one
       address,	an array is returned.  If "nslookup" is	called in a scalar
       context,	and there is more than one address, "nslookup" returns the
       first address.  If there	is only	one address returned, then, naturally,
       it will be the only one returned, regardless of the calling context.

       domain and host are synonyms for	term, and can be used to make client
       code more readable.  For	example, use domain when getting NS records,
       and use host for	A records; both	do the same thing.

       server should be	a single IP address or a reference to an array of IP

	 my @a = nslookup(host => '', server	=> '');

	 my @a = nslookup(host => '', server	=> [ '',	'' ])

       By default, when	doing CNAME, MX, and NS	lookups, "nslookup" returns
       names, not addresses.  This is a	change from versions prior to 2.0,
       which always tried to resolve names to addresses.  Pass the recurse =_
       1 flag to "nslookup" to have it follow CNAME, MX, and NS	lookups.  Note
       that this usage of "recurse" is not consistent with the official	DNS
       meaning of recurse.

	   # returns soemthing like ("")
	   my @mx = nslookup(domain => '', type => 'MX');

	   # returns soemthing like ("")
	   my @mx = nslookup(domain => '', type => 'MX', recurse => 1);

       SOA lookups return the SOA record in the	same format as the `host`

	   print nslookup(domain => '', type	=> 'SOA'); 2011061433 7200 3600 1209600 3600

       Lookups timeout after 15	seconds	by default, but	this can be configured
       by passing timeout =_ X to "nslookup".

       Pass debug =_ 1 to "nslookup" to	emit debugging messages	to STDERR.

       darren chamberlain <>

perl v5.32.1			  2013-12-12		      Net::Nslookup(3)


Want to link to this manual page? Use this URL:

home | help