I want to forward a local port to a remote port (8041) to a port (8042) on a remote machine (10.0.0.42). I can do this via
ssh -L 10.0.0.41:8041:10.0.0.42:8042 user@localhost
where 10.0.0.41
is bound to eth0
.
Now I want to do this without all the userland and encryption overhead.
My guess would be
iptables -t nat -A PREROUTING -i eth0 -p tcp -d 10.0.0.41 --dport 8041 -j DNAT --to 10.0.0.42:8042
and enable ip-forward - but it does not work.
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE