I'm trying to create a proxy of sorts using just iptables.The linux computer (my proxy) has two ports:p2p1 is connected to the Internet.em1 is connected to a local network.There are two devices on the local network (not including the linux machine). To connect to these, we should type (from any computer on the Internet):xx.xx.xx.xx:10001xx.xx.xx.xx:10002where xx.xx.xx.xx is the public IP (and is dynamic).These devices can be accessed from the linux machine on the em1 port by accessing the following IPs:192.168.3.100:80192.168.3.101:80So, all traffic that gets routed into xx.xx.xx.xx:10001 on p2p1 should be redestined for 192.168.3.100 on em1.I also need to retain the source IP, or something to that effect, so the packets can find their way back.Here's what I'm using in my IP tables script.iptables -t nat -F  # Clear out any old rules.MyIP=10.27.155.200MyPort=10001DestIP=192.168.3.100DestPort=80iptables -t nat -A PREROUTING --dst $MyIP -p tcp --dport $MyPort -j DNAT --to-destination $DestIP:$DestPortiptables -t nat -A POSTROUTING -p tcp --dst $DestIP --dport $DestPort -j SNAT --to-source $MyIPiptables -t nat -A OUTPUT --dst $MyIP -p tcp--dport $MyPort -j DNAT --to-destination $DestIP:$DestPortObviously there are some problems because my IP is dynamic, yet I'm hard coding it in every time. Furthermore, the packets, once they return to the computer, don't know how to get to their original source.I don't know where to go from here.
Routing packets between networks with iptables
iptables;proxy;nat