NetFilter
[Top] [All Lists]

Re: is it possible to nat to the routed IP?

To: netfilter@lists.netfilter.org
Subject: Re: is it possible to nat to the routed IP?
From: Pascal Hambourg <pascal.mail@plouf.fr.eu.org>
Date: Sat, 16 Dec 2006 12:02:10 +0100
Delivered-to: sp-com-lists@consult.net
Delivered-to: netfilter-list1@securepoint.com
In-reply-to: <000f01c720e8$f75b5d50$0202fea9@tanjian>
List-archive: </pipermail/netfilter>
List-help: <mailto:netfilter-request@lists.netfilter.org?subject=help>
List-id: General discussion and user questions <netfilter.lists.netfilter.org>
List-post: <mailto:netfilter@lists.netfilter.org>
List-subscribe: <https://lists.netfilter.org/mailman/listinfo/netfilter>, <mailto:netfilter-request@lists.netfilter.org?subject=subscribe>
List-unsubscribe: <https://lists.netfilter.org/mailman/listinfo/netfilter>, <mailto:netfilter-request@lists.netfilter.org?subject=unsubscribe>
Organization: Plouf !
References: <000f01c720e8$f75b5d50$0202fea9@tanjian>
Sender: netfilter-bounces@lists.netfilter.org
User-agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)
Hello,

Rob Sterenborg a écrit :

$ipt -t nat -A PREROUTING -d 210.153.22.y -p tcp --dport 80 \   -j
DNAT --to 192.168.2.208

Zhen Zhou wrote:

Now another issue is pop up:

210.153.22.x is Internet gateway IP, 210.153.22.y is a public ip for
publish 192.168.3.208. ofcs, from Internet traffic to 192.168.3.208,
is go through 210.153.22.y. But in the another hand all the traffic
from 192.168.3.208 to outside, it will go to 210.153.22.x, could it
be a possible go via 210.153.22.y under some protocols? How to
configure?

Insert this kind of rule before the generic SNAT rule :

$ipt -t nat -A POSTROUTING -o <interface> -s 192.168.2.208 -p <proto> \
  [--dport <port>] -j SNAT --to 210.153.22.y

[...]
A http connection is made to the server at destination port 80/tcp.
[...] So, return packets are coming from source port 80/tcp.
I think this is what you want:

$ipt -t nat -A POSTROUTING -s 192.168.2.208 -p tcp --sport 80 \
  -j SNAT 210.153.22.y

This rule is useless to handle HTTP return packets. Return packets are in the ESTABLISHED state and don't traverse the 'nat' chains.

Packets from 192.168.2.208:80 are SNAT-ed to 210.153.22.y

Yes, but not because of this SNAT rule but because of the DNAT rule above and because stateful DNAT does implicit SNAT on return packets.


<Prev in Thread] Current Thread [Next in Thread>