From: Jason Opperisano <opie@817west.com>
To: netfilter@lists.netfilter.org
Subject: RE: How to block only MX query made to DNS server
Date: Tue, 30 Nov 2004 09:28:57 -0500 [thread overview]
Message-ID: <1101824937.2881.20.camel@hubcap.ljm.dom> (raw)
In-Reply-To: <1101820669.2881.11.camel@hubcap.ljm.dom>
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
next prev parent reply other threads:[~2004-11-30 14:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-29 18:27 How to block only MX query made to DNS server Hudson Delbert J Contr 61 CS/SCBN
2004-11-30 7:26 ` pravin rane
2004-11-30 13:17 ` Jason Opperisano
2004-11-30 14:28 ` Jason Opperisano [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-11-30 10:36 hclfm
2004-11-30 11:46 ` Leonardo Rodrigues Magalhães
2004-11-30 11:50 ` pravin rane
[not found] <OFF16F8905.C3905D39-ON65256F5C.002D9EA6@pricol.co.in>
2004-11-30 8:53 ` pravin rane
2004-11-30 12:35 ` a.ledvinka
2004-11-27 21:23 Daniel Chemko
2004-11-28 4:17 ` pravin rane
2004-11-28 6:21 ` Jason Opperisano
2004-11-27 9:51 pravin rane
2004-11-28 7:40 ` Tom Marshall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1101824937.2881.20.camel@hubcap.ljm.dom \
--to=opie@817west.com \
--cc=netfilter@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox