MikroTik Hairpin NAT: Open Your Public IP or Domain from Inside the LAN
Why a forwarded server works from outside but not from inside your own network, and how to fix it on MikroTik with hairpin NAT or a static DNS entry.
Problem
Your web server or NVR works from the internet through port forwarding, but when you use the same public IP or domain from a PC inside the office, it does not open.
Symptoms
http://your-domain.comworks on mobile data but times out on office Wi-Fi.- The server sees the connection with a strange source address, or none at all.
Likely causes
The dst-nat rule matches only traffic coming in on the WAN, so LAN traffic to the public IP is not forwarded. Even when it is forwarded, the server replies directly to the LAN client (same subnet), and the client drops the reply because it expected an answer from the public IP. Hairpin NAT fixes both parts.
Prerequisites
- A working port forward (see MikroTik port forwarding).
- Example: public IP
203.0.113.10, server192.168.88.20port 80, LAN192.168.88.0/24onbridge-lan.
Solution (WinBox / CLI)
1. Match the public IP, not the WAN interface:
/ip firewall nat add chain=dstnat dst-address=203.0.113.10 protocol=tcp dst-port=80 action=dst-nat to-addresses=192.168.88.20 comment="Web server"If your public IP changes, enable IP > Cloud DDNS and add the DDNS name to an address list, then use dst-address-list instead:
/ip cloud set ddns-enabled=yes
/ip firewall address-list add list=my-public-ip address=YOUR_SERIAL.sn.mynetname.net2. Masquerade LAN-to-server traffic so replies come back through the router:
/ip firewall nat add chain=srcnat src-address=192.168.88.0/24 dst-address=192.168.88.20 protocol=tcp dst-port=80 out-interface=bridge-lan action=masquerade comment="Hairpin"Place both rules above other NAT rules if needed.
Alternative: split DNS. If you use a domain name, point it to the inside address for LAN users only:
/ip dns static add name=your-domain.com address=192.168.88.20This works when LAN clients use the router as their DNS server.
Verification
From a LAN PC, open http://203.0.113.10 or your domain. Check the counters with /ip firewall nat print stats.
Common errors
- Using
dst-address-type=localwithout excluding the router's LAN IP: you also forward the router's own WebFig. - The server logs show every LAN visitor as the router's IP. That is expected with hairpin masquerade.
Rollback
/ip firewall nat remove [find comment="Hairpin"]This topic is covered hands-on in MTCNA — MikroTik Certified Network Associate.
View MTCNA