Linux Netfilter discussions
 help / color / mirror / Atom feed
* transparent proxy with iptable redirect
@ 2015-03-17  6:37 Peter Chen
  2015-03-17  9:07 ` Pascal Hambourg
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Chen @ 2015-03-17  6:37 UTC (permalink / raw)
  To: netfilter

I have a pretty straightforward question that I've been wondering. If
I add an iptable redirect rule (e.g. dst tcp port 80 to tcp port
8080), it would change every tcp packet with port 80 as its
destination to a tcp packet with destination 8080. Now if my
application listening on 8080 were to reply to the source, it would
transmit a tcp packet with src port 8080, but the source side is
expecting a tcp packet with src port 80.

So my question is, how does the reverse path from dest back to the
src, at what point does the port number get rewritten from 8080 back
to 80, making the redirect transparent? Is this done by iptable
automatically on a redirect target?

Thanks,

Peter

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

* Re: transparent proxy with iptable redirect
  2015-03-17  6:37 transparent proxy with iptable redirect Peter Chen
@ 2015-03-17  9:07 ` Pascal Hambourg
  0 siblings, 0 replies; 2+ messages in thread
From: Pascal Hambourg @ 2015-03-17  9:07 UTC (permalink / raw)
  To: Peter Chen; +Cc: netfilter

Peter Chen a écrit :
> I have a pretty straightforward question that I've been wondering. If
> I add an iptable redirect rule (e.g. dst tcp port 80 to tcp port
> 8080), it would change every tcp packet with port 80 as its
> destination to a tcp packet with destination 8080. Now if my
> application listening on 8080 were to reply to the source, it would
> transmit a tcp packet with src port 8080, but the source side is
> expecting a tcp packet with src port 80.
> 
> So my question is, how does the reverse path from dest back to the
> src, at what point does the port number get rewritten from 8080 back
> to 80, making the redirect transparent? Is this done by iptable
> automatically on a redirect target?

Yes. Stateful NAT takes care of both directions of the connection.

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

end of thread, other threads:[~2015-03-17  9:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-17  6:37 transparent proxy with iptable redirect Peter Chen
2015-03-17  9:07 ` Pascal Hambourg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox