Linux Netfilter discussions
 help / color / mirror / Atom feed
From: "Leonardo Rodrigues Magalhães" <leolistas@solutti.com.br>
To: Aleksei Bebinov <alex@gipi.kg>
Cc: netfilter@vger.kernel.org
Subject: Re: multiple exclusive DNAT does not work
Date: Fri, 26 Dec 2008 16:57:20 -0200	[thread overview]
Message-ID: <49552910.2030503@solutti.com.br> (raw)
In-Reply-To: <49552652.1040705@gipi.kg>



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





  reply	other threads:[~2008-12-26 18:57 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 [this message]
2008-12-27  8:19     ` Aleksei Bebinov

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=49552910.2030503@solutti.com.br \
    --to=leolistas@solutti.com.br \
    --cc=alex@gipi.kg \
    --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