From: Julien Vehent <julien@linuxwall.info>
To: Diego Casado Mansilla <diego.casadomansilla@gmail.com>
Cc: netfilter@vger.kernel.org, netfilter-devel@vger.kernel.org,
netfilter@lists.samba.org
Subject: Re: NAT in an already established TCP connection
Date: Tue, 28 Oct 2008 13:53:53 +0100 [thread overview]
Message-ID: <362dff85992463f0566f965662f8b75b@localhost> (raw)
In-Reply-To: <4906F699.6010006@gmail.com>
On Tue, 28 Oct 2008 12:25:13 +0100, Diego Casado Mansilla
<diego.casadomansilla@gmail.com> wrote:
> Hello all!!!
>
> This is my first mail in the list.
>
> Hopefully the question is interesting and you can figure out how to help
> me.
>
> I use iptables rules to manage the connections from internet to my local
> network. I know how to filter, do nat, etc...
> But this days I'm trying to do NAT in connections that are already
> established. The problem is (as far as I know) the packets which pass
> throught the nat table are only the SYN packets (once), thus, the
> packets that are used to perform a NEW connection.
>
> After that the connection is created, the maintenance and the resolution
> of the SNAT and DNAT are kept till the connection finish.
> What I'm wondering is: how can I change the ports or IPs of an already
> established connection if my packets just go throught the nat table at
> the connection time?
>
What you want is to redirect an existing connection to a new destination.
If you use TCP protocol, the only way to do that is to record the current
connection and, in parralel, create a second connection to you new
destination and replay the payload on the packet in the new one.
If you use UDP, this doesn't apply since there's no connection tracking in
the UDP protocol. Netfilter, however, does some connection tracking on UDP
packets, so make some test to see if it's doable.
I had to solve the same problem in a honeypot project to redirect active
connections from low interaction honeypots to high interactions honeypots.
The solution I choosed was to queue the connections in userland using
netfilter_queue, process them and replay those I've selected to the new
destination in parrallel, and then drop the packet from the initial
connection.
It's tricky to do, and there's many issue to solve, but AFAIK this is the
most reliable solution.
> **** Maybe doing packets' replication since those ones are redirected to
> annother machine?
Note : window-tracking is for the tracking of the window size in the tcp
header, it has nothing to do with this.
>
> **** NAT TCP Extensions??Patch-O-Matic --> window-tracking??
>
> **** I read this in an interntet site:
>
> --- NEW (and RELATED non-icmp)
> This is a very important part relevant for understanding the whole
NAT
> subsystem. Only if the packet has the state NEW (i.e. it would
> establish
> a new connection, if we'd accept it), the NAT table is traversed by
> calling ip_nat_rule.c:ip_nat_rule_find(), which in turn calls
> ip_tables.c:ipt_do_table() for the actual IP table traversal. The
> traversal
> ends up in either ACCEPTing the packet as it is, or one of the nat
> targets
> (SNAT, DNAT and if loaded: REDIRECT, MASQUERADE) Please see
> chapter FIXME for further description of those targets.
>
> --- ESTABLISHED
> This packet belongs to an already established connection. We don't
need
> to traverse the NAT table again, as the necessary information
> (struct ip_nat_info) was already gained Hello everybody,
>
>
> Thank you very much in advance and if my questions are not clear don't
> doubt to send me a message.
>
> Diego.
>
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
Regards,
Julien
--
www.linuxwall.info
next prev parent reply other threads:[~2008-10-28 12:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-28 11:25 NAT in an already established TCP connection Diego Casado Mansilla
2008-10-28 12:53 ` Julien Vehent [this message]
2008-10-28 16:18 ` Jan Engelhardt
2008-10-29 10:01 ` Diego Casado Mansilla
2008-10-29 10:22 ` Julien Vehent
2008-10-30 12:47 ` [OffTopic] " Diego Casado Mansilla
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=362dff85992463f0566f965662f8b75b@localhost \
--to=julien@linuxwall.info \
--cc=diego.casadomansilla@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=netfilter@lists.samba.org \
--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