I would like to redirect all incoming traffic on port 1111, to another server again on port 1111, serving as a transparent proxy. After googling around, I've tried using iptables
, but it does not work as expected.
root@glider:~# sysctl net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1
root@glider:~# iptables -t nat -A PREROUTING -p tcp --dport 1111 -j DNAT --to-destination 10.2.4.44:1111
root@glider:~# iptables -t nat -A POSTROUTING -j MASQUERADE
root@glider:~# telnet localhost 1111
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
root@glider:~# telnet 10.2.4.44 1111
Trying 10.2.4.44...
Connected to 10.2.4.44.
Escape character is '^]'.
I am using Kubuntu 14.04 LTS.