Forwarding a range of ports to another range of ports?

I'm trying forward a range of ports to a camera inside my network. I can specify a range of ports for the external address, but it appears that specifying a range for the internal address does not work.

What I want is if someone connects to port 50034, then it will be mapped to 192.168.1.24:34.

What appears to be happening instead is that OpenWRT sees the "0-999" and just ignores the "-999" and makes all incoming connections in the range 50000-50999 to port 0.

Is this expected behavior? I was really hoping to avoid creating multiple port forwarding rules for each port on my camera.

Yes, it is.

But I do not really understand your original wish. Is the camera's server really listening at 999 different ports for incoming connections? That sounds peculiar.

No, it listens on a few ports, but I don't want to have to figure out exactly which ones. I have several cameras of different models, I was really hoping I could just create one generic mapping for each one.

Why does the "Internal port" field accept a range if it will just break things?

Your approach is ill-advised... spend the time to find out what ports are required so that you can open only the required ports. Doing otherwise may cause additional problems.

Again, this is not a good approach.

A better method entirely would be to setup a VPN so that you can safely and securely access your network from a remote location without exposing your cameras directly to the internet.

Consider Wireguard for this... easy to setup, fast/performant, and secure.
https://openwrt.org/docs/guide-user/services/vpn/wireguard/road-warrior

1 Like

Likely because the same rule can also be used for SNAT (source NAT), instead of DNAT (destination NAT) that you are needing.

Ps. Using ports at 50000+ sounds strange, as they are usually dynamically assigned for outgoing connections. You might accidentally run into port conflicts. Ports above 49152 are meant for that purpose.

1 Like

FYI - Port 0 is not generally used in practice.

Ah, thanks, I'll change it. I was able to get my camera to work under dd-wrt, but for some reason the port forwarding is not working under openwrt.