All of lore.kernel.org
 help / color / mirror / Atom feed
* iptables -j REDIRECT
@ 2004-07-05 21:08 Сергеев Сергей Николаевич
  2004-07-07 14:57 ` Cedric Blancher
  0 siblings, 1 reply; 4+ messages in thread
From: Сергеев Сергей Николаевич @ 2004-07-05 21:08 UTC (permalink / raw)
  To: netfilter

Hello!
I'm using iptables v1.2.11 with kernel 2.4.26 at RH8.
Also there is squid-cache 2.5.STABLE1 listening at port 3128.

They works as transparent proxy gateway for small office:

[]# iptables -A PREROUTING -t nat -i LAN -p tcp --dport 80 -j REDIRECT --to-port 3128

to manage and account data going to 80 port I did something like this:
[]# iptables -A PREROUTING -t mangle -i LAN -p tcp --dport 80 -j LOG

the question is:
how can I manage packets incoming from 80 port to my LAN?
All chains and tables(OUTPUT:mangle,nat,filter and POSTROUTING:mangle,nat) shows that one go from local_ip_of_gateway:3128.
But tcpdump started at LAN interface shows that packets go from real ip addresses and src_port 80....
In what chain and table netfilter replaces SRC_ip & SRC_port back by real?

Thank you!
-- 
Best regards,
 Sergeyev , Moscow RU                          mailto:serg@dinfo.ru



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

* Re: iptables -j REDIRECT
  2004-07-05 21:08 iptables -j REDIRECT Сергеев Сергей Николаевич
@ 2004-07-07 14:57 ` Cedric Blancher
  2004-07-08 16:08   ` Martijn Lievaart
  0 siblings, 1 reply; 4+ messages in thread
From: Cedric Blancher @ 2004-07-07 14:57 UTC (permalink / raw)
  To: Сергеев Сергей Николаевич
  Cc: netfilter

Le lun 05/07/2004 à 23:08, Сергеев Сергей Николаевич a écrit :
> how can I manage packets incoming from 80 port to my LAN?
> All chains and tables(OUTPUT:mangle,nat,filter and
> POSTROUTING:mangle,nat) shows that one go from
> local_ip_of_gateway:3128.
> But tcpdump started at LAN interface shows that packets go from real
> ip addresses and src_port 80....
> In what chain and table netfilter replaces SRC_ip & SRC_port back by
> real?

After POSTROUTING, so you are not able to match them. But what you can
do is use CONNMARK target and connmark match to spot thoses connections.

Something like :

	iptables -A PREROUTING -t mangle -i LAN -p tcp --dport 80 \
		-j CONNMARK --set-mark 0x01

Now, every packet that belongs to a connection beginning by one of
theses packets will get connmarked with 0x01. To match them back, use
connmark match like this :

	-m connmark --mark 0x01

Hope it will help.


-- 
http://www.netexit.com/~sid/
PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE
>> Hi! I'm your friendly neighbourhood signature virus.
>> Copy me to your signature file and help me spread!


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

* Re: iptables -j REDIRECT
  2004-07-07 14:57 ` Cedric Blancher
@ 2004-07-08 16:08   ` Martijn Lievaart
  2004-07-10 15:37     ` Cedric Blancher
  0 siblings, 1 reply; 4+ messages in thread
From: Martijn Lievaart @ 2004-07-08 16:08 UTC (permalink / raw)
  Cc: Сергеев Сергей Николаевич,
	netfilter

Cedric Blancher wrote:

>Le lun 05/07/2004 à 23:08, Сергеев Сергей Николаевич a écrit :
>
>
>>how can I manage packets incoming from 80 port to my LAN?
>>All chains and tables(OUTPUT:mangle,nat,filter and
>>POSTROUTING:mangle,nat) shows that one go from
>>local_ip_of_gateway:3128.
>>But tcpdump started at LAN interface shows that packets go from real
>>ip addresses and src_port 80....
>>In what chain and table netfilter replaces SRC_ip & SRC_port back by
>>real?
>>
>>
>
>After POSTROUTING, so you are not able to match them. But what you can
>do is use CONNMARK target and connmark match to spot thoses connections.
>
>Something like :
>
>	iptables -A PREROUTING -t mangle -i LAN -p tcp --dport 80 \
>		-j CONNMARK --set-mark 0x01
>
>Now, every packet that belongs to a connection beginning by one of
>theses packets will get connmarked with 0x01. To match them back, use
>connmark match like this :
>
>	-m connmark --mark 0x01
>
>Hope it will help.
>
>
>

I don't think it will help. There is no nat going on after the
port-redirect. Squid will open a new tcp connection so the source-ip
will always be squids. Nothing you can do about that, but you can maybe
account for the traffic by using the squid logs.

HTH,
Martijn Lievaart





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

* Re: iptables -j REDIRECT
  2004-07-08 16:08   ` Martijn Lievaart
@ 2004-07-10 15:37     ` Cedric Blancher
  0 siblings, 0 replies; 4+ messages in thread
From: Cedric Blancher @ 2004-07-10 15:37 UTC (permalink / raw)
  To: Martijn Lievaart
  Cc: Сергеев Сергей Николаевич,
	netfilter

Le jeu 08/07/2004 à 18:08, Martijn Lievaart a écrit :
> I don't think it will help. There is no nat going on after the 
> port-redirect. Squid will open a new tcp connection so the source-ip 
> will always be squids. Nothing you can do about that, but you can maybe 
> account for the traffic by using the squid logs.

You're right if OP wants to filter communication between Squid and
destination webservers (most probable). I understood he wanted to spot
comminucations between Squid and his LAN.


-- 
http://www.netexit.com/~sid/
PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE
>> Hi! I'm your friendly neighbourhood signature virus.
>> Copy me to your signature file and help me spread!


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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-05 21:08 iptables -j REDIRECT Сергеев Сергей Николаевич
2004-07-07 14:57 ` Cedric Blancher
2004-07-08 16:08   ` Martijn Lievaart
2004-07-10 15:37     ` Cedric Blancher

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.