How does port forwarding work?
A router shares one public internet address among every device in the building, a job called network address translation, or NAT. It lets devices inside start conversations with the internet but refuses conversations started from outside, because it doesn't know which device they are for. A port forwarding rule supplies the answer: anything arriving on this port goes to that device.
A port is a number that separates one kind of traffic from another on the same address. A recorder's RTSP video is on port 554 by default. A rule might say that outside port 5540 goes to 192.168.1.64 port 554, the recorder. A camera that is opened inside the building at 192.168.1.64 port 554 is then opened from outside at the site's public address, port 5540. The recorder should have a fixed local address so the rule keeps pointing at it.
What does a port forwarding rule look like on a router?
Routers list it under port forwarding, virtual server or NAT, usually in the advanced settings. Each rule is one row with the same few fields.
- Name: a label for your own reference, such as Recorder RTSP.
- External port: the number people outside connect to, 5540 in the example.
- Internal address: the recorder's address on the local network, 192.168.1.64.
- Internal port: the port the recorder listens on, 554 for RTSP.
- Protocol: TCP, UDP or both. RTSP needs TCP.
Which ports does a CCTV recorder use?
A recorder listens on several ports, and each is a separate door. Port 80 serves its settings pages to a web browser. Port 554 serves live video by RTSP. A further port carries the maker's own app and computer software: 8000 by default on Hikvision recorders and 37777 on Dahua. The recorder's network menu lists them and lets you change each number.
Forward only the door a given use needs. Outside software that only reads video needs the RTSP port and nothing else. The settings pages on port 80 are the door most worth keeping shut.
Is port forwarding safe for a CCTV recorder?
It carries a real risk, because the recorder's login becomes reachable by anyone on the internet, and automated scanners find open ports quickly. Recorders with default passwords or old firmware are a common target. An unusual outside port number hides the door from casual scans only; anyone who finds it still meets the same login.
If you forward a port, forward only the one you need, set a long unique password, keep the recorder's firmware current and switch off features that open ports by themselves. Port forwarding also can't work when the internet provider shares one public address among many customers. DDNS is usually set up alongside it so the site can be found when its address changes.
How is port forwarding different from UPnP, a DMZ and DDNS?
These four sit near each other in a router's menu and are often confused.
- Port forwarding: one rule you write, sending one outside port to one device.
- UPnP: devices ask the router to open ports for them, with no rule written by anyone. Ports can then be open that you never chose.
- DMZ: every port that has no rule of its own is sent to one device. Putting a recorder there exposes all of its doors at once, so avoid it.
- DDNS: a name that follows the site's changing address. It finds the router; it opens nothing.
What are the common port forwarding problems and how do you recognise them?
The usual sign is a recorder that answers inside the building and times out from anywhere else. Test from a phone on mobile data, not on the site's Wi-Fi, because many routers can't loop a request back to themselves and an inside test proves nothing.
- It worked, then stopped after a power cut: the router gave the recorder a new local address and the rule points at the old one. Give the recorder a fixed address.
- The rule is right and nothing arrives: there are two routers in a row, typically the provider's box and your own. The rule is needed on both, or the first is set to pass everything through.
- It never worked on this line: the provider uses a shared address, called carrier-grade NAT. No rule on your router can help.
- One port works and another doesn't: some providers block certain low-numbered ports. Choose a different outside number.
What should you ask an installer about port forwarding?
Ask for a written list of every port open on your router, which device each leads to, and why. Ask whether UPnP is on, on the router and on the recorder, and have it switched off if nobody can say what relies on it. Ask whether the recorder has a fixed local address and whether its password was changed from the one it shipped with.
Installers often open more than is needed because it gets the phone app working quickly. If remote viewing works through the maker's app by scanning a code, you may need no forwarded ports at all.
Do you need port forwarding to get alerts from your cameras?
No. GoKavach connects in one of two ways. Directly, it reaches the recorder at a public IP or DDNS name with the RTSP port forwarded, which suits sites where an installer has already set that up. You enter the address and the outside port, and GoKavach reads RTSP over TCP through that rule. Alerts, live view and playback need nothing else. Hard-disk alerts and the camera siren on Hikvision and Dahua firmware also use the recorder's web port, 80, so on a direct connection they work only if that port is reachable too.
Otherwise the site connector, a small app on an always-on Windows, Mac or Linux computer at the location, makes an outgoing connection only. The router sees ordinary outbound traffic, so nothing is opened and no rule is added. Viewing CCTV remotely without a static IP explains the choice, and the Hikvision page shows a typical setup. Whichever you pick, a camera offline alert tells you when the connection is lost.