Skip to contentSkip to conversation

local NAT

DISCUSSION Nils Radtke 5 participants 8 messages Jun 7, 2003 – Jun 14, 2003 netfilter

lore
Share & tools
lore
#0 lore raw

Hi all,

Fact:
inbound connection from net A on eth2 needs to be SNATted to net b (connected to eth0) as some local (box with eth0-2) services accept only net b.

Is this already implemented? The only evidence in this topic seems to be an email dated 31 march 2002 stating that the implementor of local DNAT also did SNAT which was (by a member of ct) not considered worth getting into kernel.

As understood, the NAT in the mentionned email is not exactly the required funtionality but close to it.

Question:
Is there code around implementing the feature of SNATting incoming packets for local processes?

Hints are welcome! Thanks in advance.

Nils Radtke

Signature · 5 lines
* N.Radtke@                 * University of Stuttgart *    icq / lc   *
*      www.Think-Future.de  *    dep.comp.science     * 9336272/92045 *
:x                                                                   :)

   I don't believe in natural science.   -- Gödel, Kurt 
#1 lore raw
Quoted 3 lines · Nils Radtke

Question:
Is there code around implementing the feature of SNATting incoming packets for local processes?

not that I am aware of. And I can still not imagine a setup where this would make any sense. Please enlighten me.

Quoted 1 line

Nils Radtke

Signature · 5 lines
- Harald Welte <[email protected]>             http://www.netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie
#2 lore raw
Quoted 7 lines · Harald Welte
Quoted 3 lines · Nils Radtke

Question:
Is there code around implementing the feature of SNATting incoming packets for local processes?

not that I am aware of. And I can still not imagine a setup where this would make any sense. Please enlighten me.

a security proxy analyzing HTTP requests before the real webserver gets its hand on it. if you want the webserver to get the original client as the source of the connection you need something like this.

using an application proxy on the same host as the webserver has the following benefits:

1) protocol sanitization

2) completely separate jails for separate users of the same box, e.g. you have a dozen webservers, each running in different chroot under different uid, the proxy choosing the appropriate local webserver based on the Host header of the HTTP request.

3) separate webservers for WebDAV like requests (where the webserver needs write permissions to the webroot) and usual HTTP requests (where it is read only access is enough)

Signature · 2 lines
Bazsi
PGP info: KeyID 9AF8D0A9 Fingerprint CD27 CFB0 802C 0944 9CFD 804E C82C 8EB1
#3 lore raw
Quoted 6 lines · Balazs Scheidler
Quoted 5 lines · Harald Welte
Quoted 3 lines · Nils Radtke

Question:
Is there code around implementing the feature of SNATting incoming packets for local processes?

Quoted 6 lines
Quoted 2 lines

not that I am aware of. And I can still not imagine a setup where this would make any sense. Please enlighten me.

a security proxy analyzing HTTP requests before the real webserver gets its hand on it. if you want the webserver to get the original client as the source of the connection you need something like this.

Oh, well. Either you or me misunderstood the feature Nils was requesting. You seem to be talking about SNAT'ing outgoing packets sent by local processes. I was talking about SNAT'ing incoming packets received for a socket of a local process.

Nils: which one are you interested in?

Quoted 1 line

Bazsi

Signature · 5 lines
- Harald Welte <[email protected]>             http://www.netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie
#4 lore raw
Quoted 11 lines · Harald Welte
Quoted 3 lines · Balazs Scheidler

a security proxy analyzing HTTP requests before the real webserver gets its hand on it. if you want the webserver to get the original client as the source of the connection you need something like this.

Oh, well. Either you or me misunderstood the feature Nils was requesting. You seem to be talking about SNAT'ing outgoing packets sent by local processes. I was talking about SNAT'ing incoming packets received for a socket of a local process.

Nils: which one are you interested in?

I am talking about SNATing outgoing packets sent by local processes destined _to_ a local process.

Is this the same case?

Signature · 2 lines
Bazsi
PGP info: KeyID 9AF8D0A9 Fingerprint CD27 CFB0 802C 0944 9CFD 804E C82C 8EB1
#5 lore raw
Quoted 2 lines · Balazs Scheidler

I am talking about SNATing outgoing packets sent by local processes destined _to_ a local process.

Afaik, you can SNAT them on OUTPUT chain without any problem.

Quoted 1 line

Is this the same case?

I don't think so.

Signature · 4 lines
Cédric Blancher  <[email protected]>
Consultant en sécurité des systèmes et réseaux - Cartel Sécurité
Tél: +33 (0)1 44 06 97 87 - Fax: +33 (0)1 44 06 97 99
PGP KeyID:157E98EE  FingerPrint:FA62226DA9E72FA8AECAA240008B480E157E98EE
#6 lore raw
In reply to Harald Welte

Hello Harald, hello interested reader,

# Nils: which one are you interested in?
My hope having supplied correct and simple data about the problem didn't
fullfill. I'm sorry if I missed that goal and I'll try to do it better now:

BIG PICTURE: I use an access point to connect my wireless clients to the net. I am paranoid regarding data integrity and privacy. So, of course, WEP is not sufficient. In addition to using VPN (FreeSwan) I implement a different (compared to the private intranet) subnet on the wireless behalf.

VISUALIZATION:

(Internet-) (Intranet-)
Internet ---- Gateway ---- Intranet ---- Gateway ---- AccessPoint - - - - wireless_Intranet
DEV: ppp0 eth0 eth0 eth1 transparent

IP: any private_net wireless_private_net

                             192.168.1.0/24             172.16.1.0/24

FACT: - Using netfilter to connect Intranet and Internet works. Good.
- The Intranet Gateway is hosting a whole bunch of services configured to accept connections from the Intranet. Works. Good.
PROB: - the clients on air (wireless_Intranet) cannot access the
services as, obviously, the IP-range is not allowed to connect. Bad.

SOLUTION: - Need to do local SNAT.
- Map any single IP or IP-range (inbound on eth1 of Intranet-Gateway) from wireless_private_net to a specified single IP or a corresponding specified IP-range belonging to private_net. This must be done _before_ the packet reaches a listening local process.
Then the local processes configured to accept IP-addresses from private_net only can serve to clients connected via WLAN, too.

I hope this time all information has been clearly stated. If any questions remain, do not hesitate to address them to me.

Kind regards,

Nils Radtke

Signature · 6 lines
* N.Radtke@                 * University of Stuttgart *    icq / lc   *
*      www.Think-Future.de  *    dep.comp.science     * 9336272/92045 *
:x                                                                   :)

   Yesterday is but today's memory, and tomorrow is today's dream.  
   -- Kahlil Gibran 
#7 lore raw
In reply to Harald Welte

Hi Harald, excuse my jumping in, I do this all the time. ;-) Here is why. A establishes a connection to B. Then A is suspended and reconnected at C. Normally the connection A<->B seen by the transport would be dropped. Well, not if you let the transport keep thinking the connection A<->B is still there, but translate it into C<->B underneath. That is, on C you SNAT A<->B into C<->B for outgoing traffic; on B you SNAT C<->B back into A<->B for incoming traffic (and you to DNAT appropriately for the reverse traffic of course). This will transparently migrating an existing connection A<->B from A to C (B remains stationary) without ever touching the transport that I'm doing. I'm currently using a patch I made myself to do it. But it would be great if you could incorporate it into netfilter base. It also feels kinda strange that current netfilter local NAT only works for "half" of the traffic, i.e., outgoing only. Hope what I described makes sense to you.

Thanks,

Signature · 10 lines
/Gong


Thus did Harald Welte <[email protected]> write:
*>
*>--rCwQ2Y43eQY6RBgR
*>Content-Type: text/plain; charset=us-ascii
*>Content-Disposition: inline
*>Content-Transfer-Encoding: quoted-printable
*>

*>On Sat, Jun 07, 2003 at 11:50:04PM +0200, Nils Radtke wrote:

*>>   Question:
*>>   Is there code around implementing the feature of SNATting incoming
*>>   packets for local processes?

*>
*>not that I am aware of. And I can still not imagine a setup where this *>would make any sense. Please enlighten me.
*>
*>> Nils Radtke
*>