My goal is to forward the local port 8088 on one machine to a remote machine.
The local machine has an eth0 interface (10.0.0.10) and lo (127.0.0.1).
On 10.0.0.10 the rules
Quote:
iptables -t nat -A PREROUTING -p tcp --dport 8088 -j DNAT --to-destination 10.0.0.20:8088
iptables -t nat -A POSTROUTING -p tcp -d 10.0.0.20 -j MASQUERADE
|
Allows me to connect from a third machine (10.0.0.30) to 10.0.0.10 and that connection is forwarded to 10.0.0.20.
This works and connects to 10.0.0.20
Quote:
[10.0.0.30~] telnet 10.0.0.10 8088
|
However, from 10.0.0.10 itself the connection fails. This does not work
Quote:
[10.0.0.10~] telnet 10.0.0.10 8088
|
Adding this rule allows me to connect to the eth0's address from the local machine
Quote:
iptables -t nat -A OUTPUT -p tcp --dport 8088 -j DNAT --to-destination 10.0.0.20:8088
|
Now this does work
Quote:
[10.0.0.10~] telnet 10.0.0.10 8088
|
However, connecting to the lo interface still does not work
Quote:
[10.0.0.10~] telnet 127.0.0.1 8088
|
I'm looking for a rule on 10.0.0.10 that will forward the connection to 127.0.0.1 port 8088 to 10.0.0.20 port 8088
I googled this problem to no end and found suggestions that either do not work, or are syntactically wrong
Please only reply with a rule that is known to work.
Thanks.