All of lore.kernel.org
 help / color / mirror / Atom feed
* RE: Differentiating direct, and redirected access?
@ 2004-10-18 14:24 Jason Opperisano
  2004-10-18 17:34 ` Ложечник Александр
  0 siblings, 1 reply; 8+ messages in thread
From: Jason Opperisano @ 2004-10-18 14:24 UTC (permalink / raw)
  To: netfilter

> Hello all,
>
> I'm running a squid at port 3128 as a transparent proxy.
>
> There are requests coming directly to 3128 port and
> those coming to 80 port and then redirected to 3128 by
> following rule:
>
> -t nat -A PREROUTING -i eth0 -p tcp -m tcp \
>    --dport 80 -j REDIRECT --to-ports 3128
>
> What I want is block direct requests to 3128, allowing
> redirected access (transparent proxy) only. How do I do it?
>
> If I just set up a rule in filter chain like:
>
> -t filter -A INPUT -i eth0 -p tcp -m tcp \\
>    --dport 3128 -j DROP
>
> Those requests redirected from port 80 to 3128 are also
> blocked by this rule. It seems that the redirected packets
> come in to this chain once again with the new port number.
>
> How can I differentiate these two different kinds of
> request? Any clue will be greatly appreciated.
>
> Jinsuk Kim

mark the packets that will get redirected, and only accept them if they
have the mark:

  # mark packets with dst port 80
  iptables -t mangle -A PREROUTING -i eth0 -p tcp --dport 80 \
    -j MARK --set-mark 1

  # redirect port 80 to 3128
  iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 \
    -j REDIRECT --to-ports 3128

  # accept packets to 3128 that have the mark
  iptables -A INPUT -i eth0 -p tcp --dport 3128 -m mark --mark 1 \
    -j ACCEPT

-j


^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: Differentiating direct, and redirected access?
@ 2004-10-19  2:15 J Kim
  0 siblings, 0 replies; 8+ messages in thread
From: J Kim @ 2004-10-19  2:15 UTC (permalink / raw)
  To: netfilter

Thank you very much Jason, Jose, Aleksandar, and
Ложечник for all the replies. I
chose the simplest suggestion (putting drop rule before redirect in nat
prerouting chain), and now it works perfect. You guys are great.

Jinsuk Kim


		
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com


^ permalink raw reply	[flat|nested] 8+ messages in thread
* RE: Differentiating direct, and redirected access?
@ 2004-10-18 14:40 Jason Opperisano
  2004-10-18 18:18 ` Ложечник Александр
  0 siblings, 1 reply; 8+ messages in thread
From: Jason Opperisano @ 2004-10-18 14:40 UTC (permalink / raw)
  To: netfilter

> -t nat -A PREROUTING -i eth0 -d ! $INT_ROUTER_IP -p tcp --dport 80 -j
> REDIRECT --to-ports 3128
> -A INPUT -i eth0 -d $INT_ROUTER_IP -p tcp --dport 3128 -J REJECT
>
> TCP SYN have external ip dst_ip.

the TCP SYN to port 80 has the dst IP of the web server on the internet.

the redirected packet to TCP port 3128 has the dst IP of the redirected
interface (eth0 in this case).

your suggested REJECT rule will reject all redirected traffic to port
3128, and is essentially the issue the OP had already run into, and was
asking for a work-around.

-j


^ permalink raw reply	[flat|nested] 8+ messages in thread
* Differentiating direct, and redirected access?
@ 2004-10-18  2:19 J Kim
  2004-10-18 15:50 ` Aleksandar Milivojevic
  2004-10-18 18:14 ` Jose Maria Lopez
  0 siblings, 2 replies; 8+ messages in thread
From: J Kim @ 2004-10-18  2:19 UTC (permalink / raw)
  To: netfilter

Hello all,

I'm running a squid at port 3128 as a transparent proxy.

There are requests coming directly to 3128 port and 
those coming to 80 port and then redirected to 3128 by 
following rule:

-t nat -A PREROUTING -i eth0 -p tcp -m tcp \
   --dport 80 -j REDIRECT --to-ports 3128

What I want is block direct requests to 3128, allowing
redirected access (transparent proxy) only. How do I do it?

If I just set up a rule in filter chain like:

-t filter -A INPUT -i eth0 -p tcp -m tcp \\ 
   --dport 3128 -j DROP 

Those requests redirected from port 80 to 3128 are also
blocked by this rule. It seems that the redirected packets
come in to this chain once again with the new port number.

How can I differentiate these two different kinds of
request? Any clue will be greatly appreciated.

Jinsuk Kim



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


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

end of thread, other threads:[~2004-10-19  2:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-18 14:24 Differentiating direct, and redirected access? Jason Opperisano
2004-10-18 17:34 ` Ложечник Александр
  -- strict thread matches above, loose matches on Subject: below --
2004-10-19  2:15 J Kim
2004-10-18 14:40 Jason Opperisano
2004-10-18 18:18 ` Ложечник Александр
2004-10-18  2:19 J Kim
2004-10-18 15:50 ` Aleksandar Milivojevic
2004-10-18 18:14 ` Jose Maria Lopez

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.