I have StatsD daemon running on a remote server (x.x.x.x
) at 8125
. I would like to forward 127.0.0.1:8125
to x.x.x.x:8125
.
I have already tried running the following on localhost
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -p udp --dport 8125 -j DNAT --to x.x.x.x:8125
iptables -t nat -A OUTPUT -p udp --dport 8125 -j DNAT --to-destination x.x.x.x:8125
iptables -t nat -A POSTROUTING -d x.x.x.x -j MASQUERADE
But it is not forwarding correctly.
echo "test.test.test:1|c" | nc -w 1 -u localhost 8125
Fails with error nc: Write error: Connection refused
echo "test.test.test:1|c" | nc -w 1 -u 127.0.0.1 8125
Fails without any error
echo "test.test.test:1|c" | nc -w 1 -u x.x.x.x 8125
Works correctly
Also, will such a port forwarding cause any security issues?