RE: How to block only MX query made to DNS server

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2004-11-30 at 08:17, Jason Opperisano wrote:

whoops...

> my $listenip = "127.0.0.1";
                  ^^^^^^^^^

that should be the inside IP of the firewall in order for it to work
properly with the REDIRECT statement...

> my $listenport = "5353";
> my $verbose = 1;
> 
> my $ns = Net::DNS::Nameserver->new(
>        LocalAddr        => $listenip,
>        LocalPort        => $listenport,
>        ReplyHandler     => \&reply_handler,
>        Verbose          => $verbose
> );
> 
> sub reply_handler {
>   my ($qname, $qclass, $qtype, $peerhost) = @_;
>   my ($rcode, @ans, @auth, @add);
> 
>   if ($qtype eq "MX") {
>     $rcode = "NXDOMAIN";
>     return ($rcode, \@ans, \@auth, \@add, { aa => 1 });
>   } else {
>     my $res   = Net::DNS::Resolver->new;
>     my $query = $res->search("$qname", "$qtype", "$qclass");
>     if ($query) {
>       foreach my $rr ($query->answer) {
>         next if $rr->type eq "CNAME";
>         push @ans, Net::DNS::RR->new($rr->string);
>         $rcode = "NOERROR";
>         return ($rcode, \@ans, \@auth, \@add);
>       }
>     }
# i also forgot to add this here
# if query fails, send negative response
else {
        $rcode = "NXDOMAIN";
        return ($rcode, \@ans, \@auth, \@add, { aa => 1 });
    }

>   }
> }
> 
> $ns->main_loop;
> ---  END PERL SCRIPT  ---

-j

--
"Be careful when we capture him! We cannot claim the reward unless
 we have 51% of the carcass"
	--The Simpsons



[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux