Learn how to configure Hairpin NAT (NAT loopback) on MikroTik to access your local server using its public IP address. Step-by-step guide with examples, NAT rul…
Step-by-step for RouterOS v7 and v6 + troubleshooting, common mistakes, and split-DNS comparison.
⚠ This guide is for system administrators and advanced MikroTik users. We show when Hairpin NAT is needed and how to configure it correctly so you can open a local server via its public IP.
Hairpin NAT lets LAN clients access an internal server using its public IP address. Without it, the request stays on the router and fails. Hairpin rewrites the traffic so it looks “external” and the connection succeeds.
When trying to reach an internal server via the router’s public IP on the same device, packets don’t leave the router and the reply never reaches the client. Hairpin NAT redirects and rewrites the connection so it “loops back” to the server with correct addressing.
192.168.88.10, published as 203.0.113.10:8080, must be reachable at the same address from the LAN.interface lists – LAN and WAN.dst-nat rule for external access to the server./ip firewall nat
add chain=dstnat in-interface-list=WAN dst-address=203.0.113.10 protocol=tcp dst-port=8080 action=dst-nat to-addresses=192.168.88.10 to-ports=8080 comment="External access"
/ip firewall nat
add chain=srcnat src-address=192.168.88.0/24 dst-address=192.168.88.10 action=masquerade comment="Hairpin NAT"
Make sure WAN interfaces are members of in-interface-list=WAN.
/ip firewall nat
add chain=dstnat in-interface=<WAN-IFACE> dst-address=203.0.113.10 protocol=tcp dst-port=8080 action=dst-nat to-addresses=192.168.88.10 to-ports=8080 comment="External access"
/ip firewall nat
add chain=srcnat src-address=192.168.88.0/24 dst-address=192.168.88.10 action=masquerade comment="Hairpin NAT"
/ip firewall nat
add chain=dstnat in-interface-list=WAN dst-address=203.0.113.10 protocol=udp dst-port=1194 action=dst-nat to-addresses=192.168.88.10 to-ports=1194
/ip firewall nat
add chain=dstnat in-interface-list=WAN dst-address=203.0.113.10 protocol=tcp dst-port=8000-8100 action=dst-nat to-addresses=192.168.88.10
[ Client 192.168.88.99 ]
│
│ (LAN)
▼
┌──────────────┐
│ MikroTik │───► Internet (203.0.113.10)
└──────────────┘
│
│ (LAN)
▼
[ Server 192.168.88.10:8080 ]
Without Hairpin NAT, http://203.0.113.10:8080 won’t open from the LAN, even if the site is accessible from outside. With Hairpin — it works normally.
srcnat and the specific dstnat above generic rules.accept for connection-state=established,related?/ip firewall nat print detail
/ip firewall connection print where dst-address~"192.168.88.10"
/tool torch interface=<LAN-IFACE> src-address=192.168.88.0/24 dst-address=192.168.88.10
/ip firewall filter add chain=forward connection-state=established,related action=accept comment="Allow established,related"
/ip firewall filter print where action=fasttrack-connection
/ip firewall filter disable X
/ip firewall filter enable X
| Approach | Pros | Cons | When? |
|---|---|---|---|
| Hairpin NAT | Same URL inside/outside; no client DNS changes | Extra NAT rule; careful ordering | Small/medium networks, quick rollout |
| Split-horizon DNS | Clean internal traffic; less conntrack | Requires internal DNS; different inside/outside behavior | Larger environments with central DNS |
dst-nat with protocol=udp.8000–8100).Email us at office@ntg.bg or request a free consultation. More guides: WireGuard site-to-site, MikroTik DNS forwarders.
Tip: keep comments and order tidy in your NAT rules — it makes diagnosing conflicts much easier.