I want connections coming in on ppp0 on port 8001 to be routed to 192.168.1.200 on eth0 on port 8080.
I've got these two rules
-A PREROUTING -p tcp -m tcp --dport 8001 -j DNAT --to-destination 192.168.1.200:8080
-A FORWARD -m state -p tcp -d 192.168.1.200 --dport 8080 --state NEW,ESTABLISHED,RELATED -j ACCEPT
and it doesn't work. What am I missing?
Best Answer
First of all - you should check if forwarding is allowed at all:
If both returns
1
it's ok. If not do the following:Second thing -
DNAT
could be applied onnat
table only. So, your rule should be extended by adding table specification as well (-t nat
):Both rules are applied only to TCP traffic (if you want to alter UDP as well, you need to provide similar rules but with
-p udp
option set).Last, but not least is routing configuration. Type:
and check if
192.168.1.0/24
is among returned routing entries.