This ought to be simple, but I can't get it to work.
I want to redirect all traffic to port 8099 on system A to the same port on system B.
I tried (on A):
But testing from a third system fails:
iptables -t nat -A PREROUTING -p tcp -d ip-of-A --dport 8099 -j DNAT --to ip-of-B:8099
iptables -A FORWARD -p tcp -d ip-of-A --dport 8099 -j ACCEPT
Unlike connecting directly to B:
$ telnet A 8099
telnet: Unable to connect to remote host: Connection timed out
I usually modify rules in /etc/sysconfig/iptables and do "service iptables restart".
$ telnet B 8099
Connected to B (ip-of-B).
Escape character is '^]'.
iptable-config only has:
Do I need to add a module to enable NAT?
I had a similar problem, but with 80 and 21.
Here's what i have for my lines:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o $EXTERNAL -j MASQUERADE
iptables -t nat -A PREROUTING -p tcp -i $EXTERNAL -d 188.8.131.52 --dport 80 -j DNAT --to 192.168.0.3:80
iptables -t nat -A PREROUTING -p tcp -i $EXTERNAL -d 184.108.40.206 --dport 21 -j DNAT --to 192.168.0.2:21
Modify to suite your needs. It's possible you don't have ip_forward turned on(the echo above). Try that and see what happens.