IP/PORT forward requests to another server
- by DT.DTDG
I have the following listening PORT:IP set up on my UBuntu server.
12.345.67.890:3636
It receives requests perfectly, however, I would now like to forward any requests to that IP:PORT to another IP:PORT, i.e.:
09.876.54.321:3636
Essentially I want to do a request forward 12.345.67.890:3636 -> 09.876.54.321:3636.
How can I go about it in Terminal and if I wanted to change it back how can I go about that too? Is there also a way to test that the data is forwarding and it is setup properly?
Thanks!
Edit: Can I just do as follows, just wondering how I would go about testing it and how I could disable it?
sysctl net.ipv4.ip_forward=1
iptables -t nat -A PREROUTING -p tcp --dport 3636 -j DNAT --to-destination 09.876.54.321:3636
iptables -t nat -A POSTROUTING -j MASQUERADE