25 |
print "Received query from $peerhost to ". $conn->{"sockhost"}. "\n"; |
print "Received query from $peerhost to ". $conn->{"sockhost"}. "\n"; |
26 |
$query->print; |
$query->print; |
27 |
|
|
28 |
if ( $qtype eq "A" && $qname eq "pxelator" ) { |
if ( $qname =~ s{\Q$server::domain_name\E$}{} ) { |
29 |
my ($ttl, $rdata) = (3600, "172.16.10.1"); |
warn "local $qname $qtype"; |
30 |
push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype $rdata"); |
if ( $qtype eq "A" && $qname eq "pxelator." ) { |
31 |
$rcode = "NOERROR"; |
my ($ttl, $rdata) = (3600, "172.16.10.1"); |
32 |
} elsif ( $qname eq "foo.example.com" ) { |
push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype $rdata"); |
33 |
$rcode = "NOERROR"; |
$rcode = "NOERROR"; |
34 |
|
} else { |
35 |
|
$rcode = "NXDOMAIN"; |
36 |
|
} |
37 |
|
|
38 |
} elsif ( my $packet = $res->query( $qname, $qtype ) ) { |
} elsif ( my $packet = $res->query( $qname, $qtype ) ) { |
39 |
|
|
46 |
$rcode = "NXDOMAIN"; |
$rcode = "NXDOMAIN"; |
47 |
} |
} |
48 |
|
|
49 |
|
warn "rcode: $rcode ",dump( @ans ); |
50 |
|
|
51 |
# mark the answer as authoritive (by setting the 'aa' flag |
# mark the answer as authoritive (by setting the 'aa' flag |
52 |
return ($rcode, \@ans, \@auth, \@add, { aa => 1 }); |
return ($rcode, \@ans, \@auth, \@add, { aa => 1 }); |
53 |
} |
} |
59 |
Verbose => $debug, |
Verbose => $debug, |
60 |
) || die "couldn't create nameserver object\n"; |
) || die "couldn't create nameserver object\n"; |
61 |
|
|
62 |
|
warn "DNS $server::domain_name"; |
63 |
|
|
64 |
$ns->main_loop; |
$ns->main_loop; |
65 |
} |
} |
66 |
|
|
67 |
1; |
1; |