Created
August 11, 2010 14:23
-
-
Save horus/519051 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl -w | |
| # Dependence: Net::DNS | |
| # To get correct answers, use TCP. | |
| # I am not going to say more. | |
| use strict; | |
| use Net::DNS; | |
| use Net::DNS::Nameserver; | |
| my $resolver = Net::DNS::Resolver->new( | |
| nameservers => [qw(8.8.8.8 4.2.2.1 4.2.2.5)], | |
| usevc => 1, | |
| debug => 1, | |
| ); | |
| sub reply_handler { | |
| my ($qname, $qclass, $qtype) = @_; | |
| my $packet = $resolver->send($qname, $qtype, $qclass); | |
| return ( | |
| $packet->header->rcode, | |
| [ $packet->answer ], | |
| [ $packet->authority ], | |
| [ $packet->additional ], | |
| ); | |
| } | |
| my $ns = Net::DNS::Nameserver->new( | |
| LocalAddr => "127.0.0.1", | |
| LocalPort => 53, | |
| ReplyHandler => \&reply_handler, | |
| Verbose => 1, | |
| ) or die "couldn't create nameserver object\n"; | |
| $ns->main_loop; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment