OpenWrt Forum Archive

Topic: Firewall custom rule not working to forward port 80 to 7575 on lan

The content of this topic has been archived on 4 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

hi,
I have openwrt 15.05.1 installed on Tp-link WR841ND.  I have created small website on my android phone  which runs on port 7575 as port 80 is not available in android.

I can access my website on phone with url, 192.168.2.103:7575 but I want it to access it 192.168.2.103. I have setup following firewall rules under "Custom Rules" as below

iptables -t nat -A PREROUTING -p tcp -d 192.168.2.103 --dport 80 -j DNAT --to-destination 192.168.2.103:7575
iptables -t nat -A POSTROUTING -j MASQUERADE

But these rules are not working. Any help or pointers?  thanks in advance

Any reason for not using OpenWRT firewall abstraction?
https://wiki.openwrt.org/doc/uci/firewa … on_natdnat

Just in case you want to "get rid of the port while inside of your network": Your other computers won't call your phone "through the router", so that's not possible by adding config to your router. You need to adjust that on your phone.

You could add a rule that redirects 192.168.3.1:80 to 192.168.2.103:7575 with NAT and use 192.168.3.1 in your browser. But for sure you need to use an IP address that will get routed instead if just being handled by the router switch component.

(Last edited by golialive on 29 Jul 2017, 14:21)

@golialive,  thanks for reply. But i am new to all this and not sure where to put that script.   Also if i understand given example, that will work if the request coming from wan(internet).

I forgot to mention that, i do not have internet connection on router. this lan only configuration... thx

The discussion might have continued from here.