Skip to content

Instantly share code, notes, and snippets.

@skaji
Created March 15, 2014 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skaji/9563514 to your computer and use it in GitHub Desktop.
Save skaji/9563514 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use 5.014;
use Net::DNS::Nameserver;
use Net::DNS::RR;
my $handler = sub {
my ($qname, $qclass, $qtype, @opt) = @_;
my ($rcode, @ans, @auth, @add);
my $ttl = 777;
$rcode = "NOERROR";
@ans = (
Net::DNS::RR->new("$qname $ttl $qclass $qtype 'I am shoichi'")
);
return ($rcode, \@ans, \@auth, \@add, { aa => 1 });
};
my $ns = Net::DNS::Nameserver->new(
LocalAddr => '0.0.0.0',
LocalPort => '5053',
ReplyHandler => $handler,
Verbose => 1,
);
$ns->main_loop;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment