I just switched from an old Asus router running Tomato, to Nanopi R4S running OpenWRT. Everything runs fine, devices have access to internet, except for port forwarding. I can't reach any LAN device from the internet.
In my case I have a router from ISP, which assigns a private IP address to my OpenWRT (192.168.64.XXX; it did the same to my Asus), and my OpenWRT assigns my LAN IPs (192.168.0.XXX; again, same as Asus did).
With Asus, if I needed to forward a port, I would just create a new rule, provide protocol (TCP), external port (5001 in my case), internal IP (192.168.0.143 in my case), give it a name, and done. Port forwarding works, regardless if I had two routers (ISP's + mine) in the chain.
But not in OpenWRT. I can't make this thing send any such packets from internet to my server
I left firewall rules on OpenWRT on default, just created new port forwarding rule as per numerous guides I found on internet: in LUCI I specified source zone (WAN), destination zone (LAN), external port, internal port, internal IP address and gave it a name. No go. My port still shows as closed by all online port-checkers, and I can't connect to my server using device on internet.
How does one make OpenWRT forward a port so that it actually works??
P.S.: My ISP let's me set up port forwarding rules on their device via webUI, and port forwarding setting on ISP device have remained the same when switching from Asus router w Tomato (where port forwarding worked without issues) to openWRT.
Oh, and the service on port 5001 works fine if I access from LAN using internal IP and port number (192.168.0.143:5001).
Let's make sure that everything is configured properly on OpenWrt:
Please connect to your OpenWrt device using ssh and copy the output of the following commands and post it here using the "Preformatted text </> " button:
Remember to redact passwords, MAC addresses and any public IP addresses you may have:
ubus call system board
cat /etc/config/network
cat /etc/config/firewall
ifstatus wan | grep address
Make sure that the ISP router is port forwarding to the address above. This is absolutely critical.
Next, remove the promiscuous option from below:
Next, make sure that the host that is actually hosting the service is indeed at 192.168.0.143 and also verify that it is listening for inbound connections on TCP port 5001. One good method to verify is to ensure that you can access it from another device on the 192.168.0.0/24 network by directly entering 192.168.0.143 as the address.
Delete the rule below:
Don't forget to reboot after making the changes and then test after the reboot.
Well... this is awkward. I'll start with me not being complete idiot, and then do a full turnaround.
I deleted traffic rule.
Host service is running on 192.168.0.143:5001 and can be accessed from LAN.
I removed promiscuous option.
...and then I went back to check forwarding rules on ISP's device. They're IP based. When I unplugged my old Asus and plugged in OpenWRT, for some reason I expected OpenWRT would be assigned same IP. It didn't, IP changed form .101 to .102.
I went back and re-wrote all forwarding rules on ISP side, and create very simple rules on OpenWRT side (I specified only ext port and target IP, nothing else). Port forwarding now works as expected.
Thank you for all the help and for making me go back to double-check settings on ISP's device!