1NAME
2 Net::Nslookup - Provide nslookup(1)-like capabilities
3
4SYNOPSIS
5 use Net::Nslookup;
6 my @addrs = nslookup $host;
7
8 my @mx = nslookup(type => "MX", domain => "perl.org");
9
10DESCRIPTION
11 "Net::Nslookup" provides the capabilities of the standard UNIX command
12 line tool nslookup(1). "Net::DNS" is a wonderful and full featured
13 module, but quite often, all you need is `nslookup $host`. This module
14 provides that functionality.
15
16 "Net::Nslookup" exports a single function, called "nslookup". "nslookup"
17 can be used to retrieve A, PTR, CNAME, MX, NS, SOA, TXT, and SRV
18 records.
19
20 my $a = nslookup(host => "use.perl.org", type => "A");
21
22 my @mx = nslookup(domain => "perl.org", type => "MX");
23
24 my @ns = nslookup(domain => "perl.org", type => "NS");
25
26 my $name = nslookup(host => "206.33.105.41", type => "PTR");
27
28 my @srv = nslookup(term => "_jabber._tcp.gmail.com", type => "SRV");
29
30 "nslookup" takes a hash of options, one of which should be *term*, and
31 performs a DNS lookup on that term. The type of lookup is determined by
32 the *type* argument. If *server* is specified (it should be an IP
33 address, or a reference to an array of IP addresses), that server(s)
34 will be used for lookups.
35
36 If only a single argument is passed in, the type defaults to *A*, that
37 is, a normal A record lookup.
38
39 If "nslookup" is called in a list context, and there is more than one
40 address, an array is returned. If "nslookup" is called in a scalar
41 context, and there is more than one address, "nslookup" returns the
42 first address. If there is only one address returned, then, naturally,
43 it will be the only one returned, regardless of the calling context.
44
45 *domain* and *host* are synonyms for *term*, and can be used to make
46 client code more readable. For example, use *domain* when getting NS
47 records, and use *host* for A records; both do the same thing.
48
49 *server* should be a single IP address or a reference to an array of IP
50 addresses:
51
52 my @a = nslookup(host => 'example.com', server => '4.2.2.1');
53
54 my @a = nslookup(host => 'example.com', server => [ '4.2.2.1', '128.103.1.1' ])
55
56 By default, when doing CNAME, MX, and NS lookups, "nslookup" returns
57 names, not addresses. This is a change from versions prior to 2.0, which
58 always tried to resolve names to addresses. Pass the *recurse => 1* flag
59 to "nslookup" to have it follow CNAME, MX, and NS lookups. Note that
60 this usage of "recurse" is not consistent with the official DNS meaning
61 of recurse.
62
63 # returns soemthing like ("mail.example.com")
64 my @mx = nslookup(domain => 'example.com', type => 'MX');
65
66 # returns soemthing like ("127.0.0.1")
67 my @mx = nslookup(domain => 'example.com', type => 'MX', recurse => 1);
68
69 SOA lookups return the SOA record in the same format as the `host` tool:
70
71 print nslookup(domain => 'example.com', type => 'SOA');
72 dns1.icann.org. hostmaster.icann.org. 2011061433 7200 3600 1209600 3600
73
74TIMEOUTS
75 Lookups timeout after 15 seconds by default, but this can be configured
76 by passing *timeout => X* to "nslookup".
77
78DEBUGGING
79 Pass *debug => 1* to "nslookup" to emit debugging messages to STDERR.
80
81AUTHOR
82 darren chamberlain <darren@cpan.org>
83
84