Outgoing DNAT, incoming SNAT?

myopius_at_gmail.com
Date: 11/19/05


Date: 18 Nov 2005 17:06:43 -0800

I know it's possible to perform SNAT on outgoing packets and DNAT on
incoming ones, for purposes of IP masquerading, but is it possible to
perform DNAT on outgoing packets and SNAT on incoming packets that
match specific IP addresses, or specific IP addresses and ports? If so,
what do I need to do that, and how do I do it?

I have a client program which doesn't allow me to alter the IP/ports to
which it connects, and seeing as I can't compile from source, this
would allow me to connect to a different IP which is accessible and
that in turn connects to the server through port forwarding.

Using iptables in Linux I can accomplish this easily with rules
resembling:

iptables -t nat -A OUTPUT -p tcp -o eth0 -d 64.233.161.99 -dport 80 -j
DNAT --to-destination 216.155.200.155
iptables -t nat -A POSTROUTING -p tcp -s 216.155.200.155 -sport 80 -j
SNAT --to-source 64.233.161.99

which is what I would type to make it so that whenever I tried to
connect out to Google's web server, I would be connected to Altavista
instead. (This is just an example, my client isn't a web client.)

Right now my connection to the internet is through the LAN, behind a
router. I'm assigned an IP address over DHCP.

Thanks,
Matt



Relevant Pages

  • Outgoing DNAT, incoming SNAT?
    ... I know it's possible to perform SNAT on outgoing packets and DNAT on ... incoming ones, for purposes of IP masquerading, but is it possible to ...
    (microsoft.public.windowsxp.general)
  • Re: Routereinstellungen
    ... > Hi Andreas ... > Dazu m??te der Home-User die DNAT und SNAT schon kennen, ... TCP will zu heise, also 193.99.144.85 Port 80. ...
    (microsoft.public.de.security.heimanwender)
  • Re: [PATCH 0/3] netfilter : 3 patches to boost ip_tables performance
    ... > both DNAT and SNAT which might have been applied need to be ... DNAT is reversed at places where we usually do ... > required enabling NAT in LOCAL_OUT unconditionally. ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: [PATCH 0/3] netfilter : 3 patches to boost ip_tables performance
    ... There are lots of other hooks and conntrack/NAT already have a ... DNAT is reversed at places where we usually do ... SNAT, SNAT is reversed where usually DNAT is ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: Routereinstellungen
    ... Andreas Kretschmer wrote: ... I.d.R. braucht der Home-User ... > kein DNAT, sondern nur SNAT. ...
    (microsoft.public.de.security.heimanwender)