All of lore.kernel.org
 help / color / mirror / Atom feed
* Possible Simple Configuration gone wrong
@ 2004-10-03 22:12 Dataforce
  2004-10-04 14:27 ` Nick Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Dataforce @ 2004-10-03 22:12 UTC (permalink / raw)
  To: netfilter

I was just wondering, how would i go about setting up iptables rules as 
follows:

Here is my network setup

the iptables machine has the ip 82.133.x.x on eth1, and 192.168.0.5 on eth0

(82.133.x.x) [Internet]----[iptables]----[Machine 1] (192.168.0.6)
                                 |--------[Machine 2] (192.168.0.2)
                                 `--------[Other Machines]

I setup a port forward as follows:
iptables -A PREROUTING -t nat -i eth0 -p tcp --dst 82.133.x.x --dport 
3389 -j DNAT --to 192.168.0.6:3389

iptables -A PREROUTING -t nat -i eth1 -p tcp --dport 3389 -j DNAT --to 
192.168.0.6:3389

iptables -t nat -A POSTROUTING --dst 192.168.0.6 -p tcp --dport 3389 -j 
SNAT --to-source 82.133.x.x

iptables -A POSTROUTING -t nat -j MASQUERADE

now, this allows machine2 AND internet clients to connect to port 3389 
on 82.133.x.x and get to machine1

however, according to machine1, all clients appear to have come from 
192.168.0.5

I would like it setup so that lan clients appear to come from 
192.168.0.5 (so that packets get routed correctly 
[machine1]--[iptables]--[machine2] not [machine1]--[machine2]) where as 
packets from the internet appear to come from the correct ip.

i have tried replacing
iptables -A POSTROUTING -t nat -j MASQUERADE

with

iptables -t nat -A POSTROUTING -s 192.168.0.0/16 -j SNAT --to-source 
82.133.x.x

iptables -t nat -A POSTROUTING -s ! 192.168.0.0/16 -j MASQUERADE

(suggested by a friend)

and vice versa (swapping the !) however it either prevents external 
connections compeltey or gives the same effect as before.

is what i would like possible with iptables? or will i jsut have to live 
with all clients appearing as 192.168.0.5

thanks

-DF


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-10-04 15:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-03 22:12 Possible Simple Configuration gone wrong Dataforce
2004-10-04 14:27 ` Nick Taylor
2004-10-04 15:21   ` Dataforce

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.