I want in plain english, attempts from localhost to connect to localhost:12345 to be nat'd to remotehost:12345
Before 2.6.11, this was possible if you had CONFIG_IP_NF_NAT_LOCAL in your kernel. After 2.6.11 this went away and I can not find a working solution (apart from using a SSH port forward or other user-level daemon based forwarding).
This is about as close as I have managed (remote is a google server for this example)....
YourIP=127.0.0.1
YourExternalIP=192.168.10.10
YourPort=12345
TargetIP=203.97.30.147
TargetPort=80
iptables -t nat -F
iptables -t nat -A PREROUTING --dst $YourIP -p tcp --dport $YourPort -j DNAT --to-destination $TargetIP:$TargetPort
iptables -t nat -A POSTROUTING -p tcp --dst $TargetIP --dport $TargetPort -j SNAT --to-source $YourExternalIP
iptables -t nat -A OUTPUT --dst $YourIP -p tcp --dport $YourPort -j DNAT --to-destination $TargetIP:$TargetPort
Anybody got any ideas?