Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Vikram Ragukumar <vragukumar@signalogic.com>
To: netfilter@vger.kernel.org
Cc: netfilter-devel@lists.netfilter.org
Subject: Regarding Iptables Redirect Target rule
Date: Mon, 01 Feb 2010 20:26:36 -0600	[thread overview]
Message-ID: <4B678D5C.7090701@signalogic.com> (raw)
In-Reply-To: <LB95CFD713BF44ce1B06C76BE068BFE90.1265010613.scalix01.aarboard.ch@MHS>

Hello,

Interface 1                  Interface 2
9090(encrypted)  ---------  9000(decrypted)
   ------>-------|Fire wall|--->-----
   ------>-------|         |--->-----
9000(unencrypted)--------- 9000(unencrypted)

I need to encrypt/decrypt and port translate traffic coming in on a 
particular port (9090).

I first perform decryption by queuing packets to a userspace program 
with the following iptables rule
(a) iptables -t mangle -A PREROUTING -p udp --dport 9090 -j NFQUEUE

To achieve port translation i use the REDIRECT target as shown below
(b) iptables -t nat -A PREROUTING -p udp --dport 9090 -j REDIRECT 
--to-port 9000

The iptables rule with the REDIRECT target ensures that traffic on port 
9000 on Interface 2 gets port translated to port 9090 while going out 
through Interface 1, only if they belong to a connection that was port 
translated from 9090 to 9000 while coming in on Interface 1.

I would like to know how to construct a rule to intercept packets that 
belong to the port translated stream, but now are coming from Interface 
2 and would like to encrypt them before they go out on Interface 1 ? 
There are other connections that use port 9000, however these do not 
belong to the port translated stream.

Will the following rule work ?

iptables -t mangle -A POSTROUTING -p udp --sport 9090 -j NFQUEUE
i.e. Will REDIRECT, ensure that the source port is rewritten from 9000 
to 9090 by the time the packet hits mangle POSTROUTING ?

Thanks in advance,
Vikram.



  parent reply	other threads:[~2010-02-02  2:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-01  7:50 How to debug RST filter ? Andre Schild
2010-02-01  8:05 ` Remzi AKYÜZ
2010-02-01  8:13   ` a.schild
2010-02-01 18:54     ` Mart Frauenlob
2010-02-01 19:29     ` Pascal Hambourg
2010-02-02  6:42       ` Andre Schild
2010-02-02  6:46         ` a.schild
2010-02-02  2:26 ` Vikram Ragukumar [this message]
2010-02-02 19:18   ` Regarding Iptables Redirect Target rule Pascal Hambourg

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=4B678D5C.7090701@signalogic.com \
    --to=vragukumar@signalogic.com \
    --cc=netfilter-devel@lists.netfilter.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