A port forward on MikroTik is a single dst-nat line, yet it is where people stumble most: the server opens from outside but not from inside by the external address; the rule exists but packets do not arrive; RDP is open to the whole internet. Here is how forwarding works, what hairpin NAT is and how not to turn your server into a target.
How forwarding works
A packet from the internet arrives at the router's external address. A dst-nat rule in the dstnat chain changes the destination address and port to the internal server, and then the packet goes through the firewall's forward chain. So you need two things: the NAT rule itself and permission in forward.
/ip firewall nat
add chain=dstnat in-interface-list=WAN protocol=tcp dst-port=8443 \
action=dst-nat to-addresses=192.168.88.10 to-ports=443 comment="web"
In the MikroTik default firewall, forwarded connections are already allowed by the "drop all from WAN not DSTNATed" rule: it drops everything from the internet except what went through dst-nat. If you built the firewall yourself, add an accept rule in forward for connection-nat-state=dstnat.
Why it does not work: five common causes
- The rule is tied to an address that changes. With a dynamic IP from the provider, use
in-interface-list=WANinstead ofdst-address. - The rule sits below a drop rule. NAT and firewall rules are checked top to bottom until the first match.
- The server has a different gateway. Replies must leave through the same MikroTik, or the connection will not be established.
- The server's own firewall. Windows and Linux often accept incoming connections only from their own network.
- The provider gives you a private address. If the address on the WAN interface is in 10.x, 100.64–100.127.x, 172.16–31.x or 192.168.x, you are behind the provider's NAT and cannot be reached from outside. Compare it with what the My IP page shows: if they differ, you need a public address.
To see which rule a packet gets stuck on, use the firewall packet path: paste your rules and describe the packet.
Hairpin NAT: reaching the server by its external address from inside
A typical complaint: "the site opens from the internet but not from the office at the same address". A computer on the local network sends a packet to the external address, the router forwards it to the server, and the server replies to the computer directly, bypassing the router. The computer gets a reply from an address it did not talk to and drops it.
The fix is hairpin NAT: an extra srcnat rule that replaces the source address of such packets with the router's address.
/ip firewall nat
add chain=srcnat src-address=192.168.88.0/24 dst-address=192.168.88.10 \
protocol=tcp dst-port=443 out-interface=bridge action=masquerade
The dst-nat rule itself must also match packets from inside: specify the external dst-address or dst-address-type=local instead of in-interface-list=WAN. An alternative to hairpin is local DNS that returns the internal address for the site's name.
Security: what must not be forwarded as is
A forwarded port is visible to the whole internet, and scanners find it within hours. RDP (3389), SSH, databases and web interfaces of cameras and NAS boxes are especially dangerous.
- Limit the sources. If the server is reached only from known places, add
src-address-list=allowedto the rule. - Do not keep the default port. Moving RDP off 3389 does not protect it, but it removes most of the junk guessing from the logs.
- Block brute force. Staged address lists on MikroTik cut off those who open many new connections in a row.
- Check what is behind the port. Default passwords on cameras and NAS boxes are a common cause of break-ins; default logins of popular devices are collected in the default passwords reference.
dst-nat rules for several servers, hairpin NAT, source limits and brute-force protection for RDP and SSH are built by the MikroTik port forwarding generator. For RDP on the server itself, use the RDP protection script; the dangers of an open 3389 are covered in the article on protecting RDP.
Checking
- Rule counters:
/ip firewall nat print stats— if the dst-nat counter does not grow, packets never reach the rule. - Connections:
/ip firewall connection print where dst-address~"192.168.88.10". - Test from outside — from a phone without Wi-Fi, not from the local network: from inside, without hairpin NAT, the forward will not work even if it is set up correctly.
Which ports to keep closed altogether is covered in the article on ports worth closing.