* multiple exclusive DNAT does not work
[not found] <S1751268AbYLZSRi/20081226181738Z+155@vger.kernel.org>
@ 2008-12-26 18:45 ` Aleksei Bebinov
2008-12-26 18:57 ` Leonardo Rodrigues Magalhães
0 siblings, 1 reply; 3+ messages in thread
From: Aleksei Bebinov @ 2008-12-26 18:45 UTC (permalink / raw)
To: netfilter
Hi all,
tinkering with OpenWRT router ( Kamikaze 7.09) and need so finctionality :
1. all the web traffic thet flow throw router and masquerading have to
be forwarded to external proxy
2.but i have 22 subnets of my local ISPs that have to flow directly
without proxyng.
I do so :
---------------
cat /etc/config/kg-nets | while read LINE
do
#iptables -t nat -A PREROUTING -i br-lan -d ! $LINE -p tcp -m
multiport --dports 80 -j DNAT --to-destination pr.oxy.ip:3128
done
--------------------------------------------
My script cat the file line by line and add excluding rules ( with ! )
of nets that i dont need to redirect.
BUT!
if only one rule ( for one subnet) persist in table - it works fine, and
if i ll add second - with second net - all the traffic redirecting to
proxy - without any exclusions.
i cant understand why ?
Could somebody help me please ?
Thanks in advance,
Aleksei
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: multiple exclusive DNAT does not work
2008-12-26 18:45 ` multiple exclusive DNAT does not work Aleksei Bebinov
@ 2008-12-26 18:57 ` Leonardo Rodrigues Magalhães
2008-12-27 8:19 ` Aleksei Bebinov
0 siblings, 1 reply; 3+ messages in thread
From: Leonardo Rodrigues Magalhães @ 2008-12-26 18:57 UTC (permalink / raw)
To: Aleksei Bebinov; +Cc: netfilter
Aleksei Bebinov escreveu:
> I do so :
> ---------------
> cat /etc/config/kg-nets | while read LINE
> do
> #iptables -t nat -A PREROUTING -i br-lan -d ! $LINE -p tcp -m
> multiport --dports 80 -j DNAT --to-destination pr.oxy.ip:3128
>
> done
> --------------------------------------------
>
> My script cat the file line by line and add excluding rules ( with ! )
> of nets that i dont need to redirect.
> BUT!
> if only one rule ( for one subnet) persist in table - it works fine, and
> if i ll add second - with second net - all the traffic redirecting to
> proxy - without any exclusions.
>
>
wrong rule for your needs. Maybe:
for LINE in `cat /etc/config/kg-nets`; do
iptables -t nat -A PREROUTING -i br-lan -d $LINE -p tcp --dport 80
-j ACCEPT
done
iptables -t nat -A PREROUTING -i br-lan -p tcp --dport 80 -j DNAT
--to-destination pr.oxy.ip:3128
will do it.
if someone asks me ONE single tip for making iptables easier, i
would say "do NOT use negation rules, those with !" ..... they work just
fine, but people rarely understands that it wont allow multiple
exclusions and will keep fighting with that. Anyway, anything done with
negation rules can be written in other single (and easier to understood)
rules.
--
Atenciosamente / Sincerily,
Leonardo Rodrigues
Solutti Tecnologia
http://www.solutti.com.br
Minha armadilha de SPAM, NÃO mandem email
gertrudes@solutti.com.br
My SPAMTRAP, do not email it
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: multiple exclusive DNAT does not work
2008-12-26 18:57 ` Leonardo Rodrigues Magalhães
@ 2008-12-27 8:19 ` Aleksei Bebinov
0 siblings, 0 replies; 3+ messages in thread
From: Aleksei Bebinov @ 2008-12-27 8:19 UTC (permalink / raw)
To: Leonardo Rodrigues Magalhães; +Cc: netfilter
Thanks Leonardo.
It works fine, and its some different than OBSD PF :-)
Leonardo Rodrigues Magalhães пишет:
>
>
> Aleksei Bebinov escreveu:
>> I do so :
>> ---------------
>> cat /etc/config/kg-nets | while read LINE
>> do
>> #iptables -t nat -A PREROUTING -i br-lan -d ! $LINE -p tcp -m
>> multiport --dports 80 -j DNAT --to-destination pr.oxy.ip:3128
>>
>> done
>> --------------------------------------------
>>
>> My script cat the file line by line and add excluding rules ( with ! )
>> of nets that i dont need to redirect.
>> BUT!
>> if only one rule ( for one subnet) persist in table - it works fine, and
>> if i ll add second - with second net - all the traffic redirecting to
>> proxy - without any exclusions.
>>
>>
>
> wrong rule for your needs. Maybe:
>
> for LINE in `cat /etc/config/kg-nets`; do
> iptables -t nat -A PREROUTING -i br-lan -d $LINE -p tcp --dport 80
> -j ACCEPT
> done
> iptables -t nat -A PREROUTING -i br-lan -p tcp --dport 80 -j DNAT
> --to-destination pr.oxy.ip:3128
>
> will do it.
>
> if someone asks me ONE single tip for making iptables easier, i
> would say "do NOT use negation rules, those with !" ..... they work
> just fine, but people rarely understands that it wont allow multiple
> exclusions and will keep fighting with that. Anyway, anything done
> with negation rules can be written in other single (and easier to
> understood) rules.
>
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-12-27 8:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <S1751268AbYLZSRi/20081226181738Z+155@vger.kernel.org>
2008-12-26 18:45 ` multiple exclusive DNAT does not work Aleksei Bebinov
2008-12-26 18:57 ` Leonardo Rodrigues Magalhães
2008-12-27 8:19 ` Aleksei Bebinov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox