Possible Simple Configuration gone wrong

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux