NAT

MikroTik Port Forwarding (dst-nat) for CCTV, Servers and Games

Open a port on a MikroTik router for a DVR, NVR, web server or game with dst-nat, check it from outside, and understand why it fails behind ISP CGNAT.

Commands in this article follow RouterOS v7 documentation but have not yet been marked as lab-tested on this site. Always test changes in a lab or maintenance window and keep a backup.

Problem

You want to reach a device inside your network from the internet, for example a CCTV NVR, a web server or a game server.

Symptoms

  • The port works inside the LAN but not from outside.
  • Online port checkers show the port as closed.

Likely causes

  • No dst-nat rule, or the rule points to the wrong IP or port.
  • The device's IP changed (no static lease).
  • The ISP uses CGNAT: your router's WAN address is private (for example 100.64.x.x, 10.x.x.x or 172.16-31.x.x), so nothing from the internet can reach it.
  • The ISP blocks common ports such as 80 or 25.

Prerequisites

  • A public IP on the router's WAN. Compare the WAN address with "what is my IP" on a website: they must match.
  • A static IP for the inside device, for example NVR 192.168.88.20 on port 80.

Solution (WinBox / CLI)

Forward outside port 8080 to the NVR's port 80:

RouterOS CLI
/ip firewall nat add chain=dstnat in-interface-list=WAN protocol=tcp dst-port=8080 action=dst-nat to-addresses=192.168.88.20 to-ports=80 comment="NVR web"

If you have a static public IP, you can use dst-address=YOUR_PUBLIC_IP instead of in-interface-list=WAN.

The default firewall already allows forwarded connections with the rule connection-nat-state=!dstnat on the WAN drop rule, so no extra filter rule is needed. If you built your own firewall, add:

RouterOS CLI
/ip firewall filter add chain=forward in-interface-list=WAN connection-nat-state=dstnat action=accept comment="Allow port forwards" place-before=0

Warning: Every open port is a door into your network. Use a non-standard outside port, a strong password on the device, and keep its firmware updated. A VPN is safer for CCTV.

Verification

  • From a phone on mobile data (not your Wi-Fi), open http://YOUR_PUBLIC_IP:8080.
  • Watch the counter: /ip firewall nat print stats where comment="NVR web".

Common errors

  • Testing from inside the LAN with the public IP: this needs hairpin NAT. See MikroTik hairpin NAT.
  • WAN address is private (CGNAT): ask the ISP for a public IP, or use a VPN or cloud service.
  • The inside device has no default gateway, or its gateway is not the MikroTik.

Rollback

RouterOS CLI
/ip firewall nat remove [find comment="NVR web"]
Go deeper in class

This topic is covered hands-on in MTCNA — MikroTik Certified Network Associate.

View MTCNA
WhatsApp