Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Aleksei Bebinov <alex@gipi.kg>
To: "Leonardo Rodrigues Magalhães" <leolistas@solutti.com.br>
Cc: netfilter@vger.kernel.org
Subject: Re: multiple exclusive DNAT does not work
Date: Sat, 27 Dec 2008 14:19:18 +0600	[thread overview]
Message-ID: <4955E506.5060907@gipi.kg> (raw)
In-Reply-To: <49552910.2030503@solutti.com.br>

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.
>
>
>
>


      reply	other threads:[~2008-12-27  8:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 message]

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=4955E506.5060907@gipi.kg \
    --to=alex@gipi.kg \
    --cc=leolistas@solutti.com.br \
    --cc=netfilter@vger.kernel.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