All of lore.kernel.org
 help / color / mirror / Atom feed
* Multiple iptables exceptions?
@ 2004-09-23 15:08 Jaret
  2004-09-23 15:23 ` Aleksandar Milivojevic
  0 siblings, 1 reply; 4+ messages in thread
From: Jaret @ 2004-09-23 15:08 UTC (permalink / raw)
  To: netfilter

When dealing with iptable rules you can use the "!" exception rule.
For instance...

IPTABLES -t nat -A PREROUTING -s 10.1.1.2 -d ! 207.46.0.0/16 --proto
tcp --dport 80 -j DNAT --to-destination 10.1.1.3:80

That statement will redirect any port 80 traffic from 10.1.1.2 to
10.1.1.3 -unless- it is trying to reach the class B network
207.46.0.0/16. That 207.46.0.0/16 happens to be part of the microsoft
domain, this way the user will only be allowed to go get updates but
will not be allowed to browse online freely. This has been tested and
proven.

So here comes the twist... microsoft does some dns load balancing and
sometimes the update site resolves at 64.4.xx.xx. Ive been digging
through documentation and trying to insert customized rules but I cant
get it to accept anything I try to allow two exception statements...

conceptually what im looking for is something like this...

IPTABLES -t nat -A PREROUTING -s 10.1.1.2 -d ! 207.46.0.0/16,
64.4.0.0/16 --proto tcp --dport 80 -j DNAT --to-destination
10.1.1.3:80

But iptables will not allow the double exception.. well it doesnt
recognize the comma delimit anyways. Like I said I've tried to get
this working a few ways and havent been able to in a single statement
or through multiple statements.

Does anyone out there know a work around for this? Preferably a
solution that stays within IPtables.

Thanks!


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiple iptables exceptions?
  2004-09-23 15:08 Multiple iptables exceptions? Jaret
@ 2004-09-23 15:23 ` Aleksandar Milivojevic
  2004-09-23 15:59   ` Abdul-Wahid Paterson
  0 siblings, 1 reply; 4+ messages in thread
From: Aleksandar Milivojevic @ 2004-09-23 15:23 UTC (permalink / raw)
  To: netfilter

Jaret wrote:
> conceptually what im looking for is something like this...
> 
> IPTABLES -t nat -A PREROUTING -s 10.1.1.2 -d ! 207.46.0.0/16,
> 64.4.0.0/16 --proto tcp --dport 80 -j DNAT --to-destination
> 10.1.1.3:80

You can try using user defined chain.  Add source, protocol and port 
options back into three PREROUTING rules, I left them out for clarity:

iptables -t nat -N MS
iptables -t nat -A MS -j ACCEPT
iptables -t nat -A PREROUTING -d 207.46.0.0/16 -j MS
iptables -t nat -A PREROUTING -d 64.4.0.0/16 -j MS
iptables -t nat -A PREROUTING -j DNAT --to-destination 10.1.1.3:80

-- 
Aleksandar Milivojevic <amilivojevic@pbl.ca>    Pollard Banknote Limited
Systems Administrator                           1499 Buffalo Place
Tel: (204) 474-2323 ext 276                     Winnipeg, MB  R3T 1L7


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiple iptables exceptions?
  2004-09-23 15:23 ` Aleksandar Milivojevic
@ 2004-09-23 15:59   ` Abdul-Wahid Paterson
  2004-09-23 18:27     ` Jaret
  0 siblings, 1 reply; 4+ messages in thread
From: Abdul-Wahid Paterson @ 2004-09-23 15:59 UTC (permalink / raw)
  To: Netfilter List

I think it is better to do it this way incase there are other rules
that need to be traversed in the PREROUTING chain.

iptables -t nat -N MS
iptables -t nat -A MS -d 207.46.0.0/16 -j RETURN
iptables -t nat -A MS -d 64,4,0,0/16 -j RETURN
iptables -t nat -A MS -j DNAT --to-destination 10.1.1.3:80
iptables -t nat -A PREROUTING -j MS

Regards,

Abdul-Wahid


On Thu, 23 Sep 2004 10:23:39 -0500, Aleksandar Milivojevic
<amilivojevic@pbl.ca> wrote:
> Jaret wrote:
> > conceptually what im looking for is something like this...
> >
> > IPTABLES -t nat -A PREROUTING -s 10.1.1.2 -d ! 207.46.0.0/16,
> > 64.4.0.0/16 --proto tcp --dport 80 -j DNAT --to-destination
> > 10.1.1.3:80
> 
> You can try using user defined chain.  Add source, protocol and port
> options back into three PREROUTING rules, I left them out for clarity:
> 
> iptables -t nat -N MS
> iptables -t nat -A MS -j ACCEPT
> iptables -t nat -A PREROUTING -d 207.46.0.0/16 -j MS
> iptables -t nat -A PREROUTING -d 64.4.0.0/16 -j MS
> iptables -t nat -A PREROUTING -j DNAT --to-destination 10.1.1.3:80
> 
> --
> Aleksandar Milivojevic <amilivojevic@pbl.ca>    Pollard Banknote Limited
> Systems Administrator                           1499 Buffalo Place
> Tel: (204) 474-2323 ext 276                     Winnipeg, MB  R3T 1L7
> 
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiple iptables exceptions?
  2004-09-23 15:59   ` Abdul-Wahid Paterson
@ 2004-09-23 18:27     ` Jaret
  0 siblings, 0 replies; 4+ messages in thread
From: Jaret @ 2004-09-23 18:27 UTC (permalink / raw)
  To: Netfilter List

Listserves are a beautiful thing.  Thanks for the help guys.  Worked.


On Thu, 23 Sep 2004 16:59:52 +0100, Abdul-Wahid Paterson
<abdulwahid@gmail.com> wrote:
> I think it is better to do it this way incase there are other rules
> that need to be traversed in the PREROUTING chain.
> 
> iptables -t nat -N MS
> iptables -t nat -A MS -d 207.46.0.0/16 -j RETURN
> iptables -t nat -A MS -d 64,4,0,0/16 -j RETURN
> iptables -t nat -A MS -j DNAT --to-destination 10.1.1.3:80
> iptables -t nat -A PREROUTING -j MS
> 
> Regards,
> 
> Abdul-Wahid
> 
> On Thu, 23 Sep 2004 10:23:39 -0500, Aleksandar Milivojevic
> 
> 
> <amilivojevic@pbl.ca> wrote:
> > Jaret wrote:
> > > conceptually what im looking for is something like this...
> > >
> > > IPTABLES -t nat -A PREROUTING -s 10.1.1.2 -d ! 207.46.0.0/16,
> > > 64.4.0.0/16 --proto tcp --dport 80 -j DNAT --to-destination
> > > 10.1.1.3:80
> >
> > You can try using user defined chain.  Add source, protocol and port
> > options back into three PREROUTING rules, I left them out for clarity:
> >
> > iptables -t nat -N MS
> > iptables -t nat -A MS -j ACCEPT
> > iptables -t nat -A PREROUTING -d 207.46.0.0/16 -j MS
> > iptables -t nat -A PREROUTING -d 64.4.0.0/16 -j MS
> > iptables -t nat -A PREROUTING -j DNAT --to-destination 10.1.1.3:80
> >
> > --
> > Aleksandar Milivojevic <amilivojevic@pbl.ca>    Pollard Banknote Limited
> > Systems Administrator                           1499 Buffalo Place
> > Tel: (204) 474-2323 ext 276                     Winnipeg, MB  R3T 1L7
> >
> >
> 
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-09-23 18:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-23 15:08 Multiple iptables exceptions? Jaret
2004-09-23 15:23 ` Aleksandar Milivojevic
2004-09-23 15:59   ` Abdul-Wahid Paterson
2004-09-23 18:27     ` Jaret

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.