All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Tomas Mandys <tomas.mandys@2p.cz>
Cc: netfilter-devel@lists.netfilter.org
Subject: Re: Changing source/destination address for local packets
Date: Mon, 25 Jun 2007 18:09:05 +0200	[thread overview]
Message-ID: <467FE8A1.6030905@trash.net> (raw)
In-Reply-To: <200706251758.00586.tomas.mandys@2p.cz>

Tomas Mandys wrote:
> Hi,
> I playing in my RTPPROXY module (finally almost ready) with change of source 
> and destination addresses. It works but there is problem when is changed 
> address for locally generated packets to another local address.
> 
> 
> IP: 192.168.1.1
> UDP packet:  192.168.1.1:10000  -->  192.168.1.1:50000
> OUTPUT hook changes destination address (like DNAT) resp. dest port only: 
> 50000 --> 20000
> POSTROUTING changes source port (like SNAT): 10000 --> 60000
> now PREROUTING is called but conntrack (ip_conntrack_get) is related to 
> session 192.168.1.1:10000  -->  192.168.1.1:50000 
> (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip/udp.port) instead
> address from (*pskb)->nh.iph->daddr (192.168.1.1:60000), pudph->dest 
> (192.168.1.1:20000).


You need to change the conntrack tuples as well if you mangle
a packet in case you're not using the standard NAT functions
for this (which you probably should). If you change the destination
address to a local one you additionally need to perform rerouting
(you *should* do that whenever you change the destination in OUTPUT,
but for this case it really is necessary).

  reply	other threads:[~2007-06-25 16:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-25 15:58 Changing source/destination address for local packets Tomas Mandys
2007-06-25 16:09 ` Patrick McHardy [this message]
2007-06-25 16:56   ` Tomas Mandys

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=467FE8A1.6030905@trash.net \
    --to=kaber@trash.net \
    --cc=netfilter-devel@lists.netfilter.org \
    --cc=tomas.mandys@2p.cz \
    /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 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.