MikroTik Port Forwarding (DST-NAT) and Hairpin NAT Generator
Expose internal server/NVR ports to the public internet (DST-NAT) and eliminate local loopback timeouts using Hairpin NAT.
Input Parameters
Calculation Results
- Public WAN Interface
- ether1-ISP
- Public IP Address (WAN)
- 203.142.77.10
- External Port (Public)
- 8000
- Internal Server / Device IP
- 192.168.88.250
- Internal Port (Local)
- 8000
- Transport Protocol
- tcp
- LAN Network Subnet
- 192.168.88.0/24
- Service / Rule Description
- NVR-CCTV-Server
- Hairpin NAT (Loopback) Status
- Yes / Active
- Firewall Filter Forward Status
- Yes / Active
Network Reflex & Speed Drill
Standar SKKNI J.611000.004.01 • MTCNA • CCNA • LPIC-1Interactive speed drill testing your quick calculation reflexes on CIDR/VLSM subnetting, TIA-598-C fiber color codes, well-known ports, and Linux sysadmin commands without using external calculators.
🎯 Your Task: Answer each multiple-choice question as accurately and quickly as possible to benchmark your engineering instincts.
Handles Multi-WAN PCC mangle rules and FQ-CoDel queue trees with low CPU utilization.
add action=dst-nat chain=dstnat dst-address=203.142.77.10 dst-port=8000 protocol=tcp to-addresses=192.168.88.250 to-ports=8000 comment="Port Forward NVR-CCTV-Server (TCP 8000 -> 192.168.88.250:8000)"
add action=masquerade chain=srcnat dst-address=192.168.88.250 dst-port=8000 out-interface-list=all protocol=tcp src-address=192.168.88.0/24 comment="Hairpin NAT Loopback NVR-CCTV-Server (TCP)"
add action=accept chain=forward connection-nat-state=dstnat dst-address=192.168.88.250 dst-port=8000 protocol=tcp comment="Allow Forwarded Port NVR-CCTV-Server (TCP)"
# ===================================================================== # InfraCalc.web.id - Port Forwarding (DST-NAT) + Hairpin NAT (NVR-CCTV-Server) # Target: 203.142.77.10:8000 -> 192.168.88.250:8000 [TCP] # ===================================================================== /ip firewall nat # 1. DST-NAT: Arahkan trafik dari IP Publik / WAN ke IP Server Lokal add action=dst-nat chain=dstnat dst-address=203.142.77.10 dst-port=8000 protocol=tcp to-addresses=192.168.88.250 to-ports=8000 comment="Port Forward NVR-CCTV-Server (TCP 8000 -> 192.168.88.250:8000)" # 2. HAIRPIN NAT: Agar saat staf di jaringan lokal (192.168.88.0/24) mengakses IP Publik/Domain, tidak mental/timeout add action=masquerade chain=srcnat dst-address=192.168.88.250 dst-port=8000 out-interface-list=all protocol=tcp src-address=192.168.88.0/24 comment="Hairpin NAT Loopback NVR-CCTV-Server (TCP)" # 3. FIREWALL FILTER: Izinkan trafik forward hasil DST-NAT melewati firewall /ip firewall filter add action=accept chain=forward connection-nat-state=dstnat dst-address=192.168.88.250 dst-port=8000 protocol=tcp comment="Allow Forwarded Port NVR-CCTV-Server (TCP)"
Multi-Vendor Config Translator & Interactive Packet Flow Visualizer
# ===================================================================== # InfraCalc.web.id - Port Forwarding (DST-NAT) + Hairpin NAT (NVR-CCTV-Server) # Target: 203.142.77.10:8000 -> 192.168.88.250:8000 [TCP] # ===================================================================== /ip firewall nat # 1. DST-NAT: Arahkan trafik dari IP Publik / WAN ke IP Server Lokal add action=dst-nat chain=dstnat dst-address=203.142.77.10 dst-port=8000 protocol=tcp to-addresses=192.168.88.250 to-ports=8000 comment="Port Forward NVR-CCTV-Server (TCP 8000 -> 192.168.88.250:8000)" # 2. HAIRPIN NAT: Agar saat staf di jaringan lokal (192.168.88.0/24) mengakses IP Publik/Domain, tidak mental/timeout add action=masquerade chain=srcnat dst-address=192.168.88.250 dst-port=8000 out-interface-list=all protocol=tcp src-address=192.168.88.0/24 comment="Hairpin NAT Loopback NVR-CCTV-Server (TCP)" # 3. FIREWALL FILTER: Izinkan trafik forward hasil DST-NAT melewati firewall /ip firewall filter add action=accept chain=forward connection-nat-state=dstnat dst-address=192.168.88.250 dst-port=8000 protocol=tcp comment="Allow Forwarded Port NVR-CCTV-Server (TCP)"
Visual Network Topology Generator (SVG / PNG)
Technical Accuracy Note: Calculation results are engineering estimates based on standard RFC/IEEE/ITU-T models. Actual field performance may vary due to protocol overhead, hardware specifications, and environmental factors.
How to Use This Tool
- Enter your public IP (or select your WAN interface), external internet-facing port, and the target internal server IP and port.
- Select the transport protocol (TCP, UDP, or Both), define your local LAN subnet CIDR (e.g. 192.168.88.0/24), and provide a descriptive label.
- Review the generated Destination NAT, Hairpin NAT loopback, and firewall filter rules, then copy the script into your MikroTik RouterOS terminal.
Worked Example: CCTV NVR Camera Port 8000
Computed example: Forwarding external port 8000 (TCP) at public IP 203.142.77.10 to internal host 192.168.88.250:8000 (NVR-CCTV-Server) alongside a Hairpin NAT loopback rule for LAN subnet 192.168.88.0/24.
- Service / Server Description
- NVR-CCTV-Server
- Public WAN IP / DDNS Hostname
- 203.142.77.10
- External Port (Public)
- 8000
- Internal Server IP (LAN)
- 192.168.88.250
- Internal Server Port
- 8000
- Transport Protocol
- TCP (Web, HTTP/HTTPS, SSH, RDP)
- LAN Subnet (Hairpin NAT Loopback)
- 192.168.88.0/24
- WAN Interface (ISP)
- ether1-ISP
- Public WAN Interface
- ether1-ISP
- Public IP Address (WAN)
- 203.142.77.10
- External Port (Public)
- 8000
- Internal Server / Device IP
- 192.168.88.250
- Internal Port (Local)
- 8000
- Transport Protocol
- tcp
- LAN Network Subnet
- 192.168.88.0/24
- Service / Rule Description
- NVR-CCTV-Server
- Hairpin NAT (Loopback) Status
- Yes / Active
- Firewall Filter Forward Status
- Yes / Active
- Port Forwarding Rule (DST-NAT)
- add action=dst-nat chain=dstnat dst-address=203.142.77.10 dst-port=8000 protocol=tcp to-addresses=192.168.88.250 to-ports=8000 comment="Port Forward NVR-CCTV-Server (TCP 8000 -> 192.168.88.250:8000)"
- Hairpin NAT Rule (SRC-NAT Masquerade)
- add action=masquerade chain=srcnat dst-address=192.168.88.250 dst-port=8000 out-interface-list=all protocol=tcp src-address=192.168.88.0/24 comment="Hairpin NAT Loopback NVR-CCTV-Server (TCP)"
- Firewall Filter Accept Rule
- add action=accept chain=forward connection-nat-state=dstnat dst-address=192.168.88.250 dst-port=8000 protocol=tcp comment="Allow Forwarded Port NVR-CCTV-Server (TCP)"
- Terminal Configuration Script (CLI)
- # ===================================================================== # InfraCalc.web.id - Port Forwarding (DST-NAT) + Hairpin NAT (NVR-CCTV-Server) # Target: 203.142.77.10:8000 -> 192.168.88.250:8000 [TCP] # ===================================================================== /ip firewall nat # 1. DST-NAT: Arahkan trafik dari IP Publik / WAN ke IP Server Lokal add action=dst-nat chain=dstnat dst-address=203.142.77.10 dst-port=8000 protocol=tcp to-addresses=192.168.88.250 to-ports=8000 comment="Port Forward NVR-CCTV-Server (TCP 8000 -> 192.168.88.250:8000)" # 2. HAIRPIN NAT: Agar saat staf di jaringan lokal (192.168.88.0/24) mengakses IP Publik/Domain, tidak mental/timeout add action=masquerade chain=srcnat dst-address=192.168.88.250 dst-port=8000 out-interface-list=all protocol=tcp src-address=192.168.88.0/24 comment="Hairpin NAT Loopback NVR-CCTV-Server (TCP)" # 3. FIREWALL FILTER: Izinkan trafik forward hasil DST-NAT melewati firewall /ip firewall filter add action=accept chain=forward connection-nat-state=dstnat dst-address=192.168.88.250 dst-port=8000 protocol=tcp comment="Allow Forwarded Port NVR-CCTV-Server (TCP)"
Core Concept & Engineering Notes
How It Was Calculated (Formulas & Steps)
Mathematical Formulas
- DST-NAT: chain=dstnat dst-address=Public_IP dst-port=External_Port action=dst-nat to-addresses=Internal_IP to-ports=Internal_Port
- Hairpin NAT: chain=srcnat src-address=LAN_Subnet dst-address=Internal_IP dst-port=Internal_Port action=masquerade
- Filter Forward Accept: chain=forward connection-nat-state=dstnat dst-address=Internal_IP dst-port=Internal_Port action=accept
Step-by-Step Calculation
- Destination NAT (DST-NAT): Forward incoming TCP port 8000 at 203.142.77.10 to internal host 192.168.88.250:8000
- Hairpin NAT: Masquerade source address from LAN 192.168.88.0/24 accessing 192.168.88.250 so replies return through the router instead of direct ARP
- Firewall Filter: Forward accept rule allows state=dstnat packets to reach 192.168.88.250:8000
Frequently Asked Questions (FAQ)
Why is my CCTV or internal server accessible from the internet but times out when connected to office Wi-Fi?
This is the classic symptom of missing Hairpin NAT. Internal clients reach out to the router's public IP; the local server replies directly over the local switch, which the client drops because the replying source IP does not match the public IP it contacted.
Do I need to specify a static Public IP if my router uses dynamic PPPoE or DHCP client?
If your public IP is dynamic, you can substitute the `dst-address` match condition with `in-interface=ether1-ISP` or `in-interface=pppoe-out1` in your RouterOS DST-NAT configuration rule.
Can the external public port differ from the internal server port?
Yes. Port translation allows you to expose public port 8080 on the WAN while mapping it to standard port 80 on your internal local web server.
Is port forwarding secure against internet attacks?
Any forwarded port is visible to public internet automated scanners. We strongly recommend changing well-known default ports (e.g. moving RDP 3389 to a high random port), using strong credentials, or accessing sensitive servers through a WireGuard VPN instead.
Related Calculators
View All Network & Routing Tools →Multi-WAN (2–5 ISP) proportional PCC load balancing and recursive failover configuration script generator for RouterOS v7.
Calculate Limit-At (CIR), Max-Limit (MIR), Burst, PCQ, and FQ-CoDel for RouterOS v7 with automated configuration script generation.
Calculate IPv4 network address, broadcast, usable host range, netmask, wildcard, binary mask, and RFC address type (RFC 1918, /31, CGNAT).
Split an IPv4 network into N equal subnets or allocate boundary-aligned VLSM blocks by required host count with CSV and Markdown export.
Expand and compress IPv6 addresses per RFC 5952, calculate network prefix boundaries, /64 SLAAC subnet counts, and child prefix blocks.
Prioritize WhatsApp calls, Zoom/Teams conferences, and gaming latency above bulk downloads using RouterOS v7 FQ-CoDel Queue Trees.
References & Notes
- MikroTik Documentation — Destination NAT (Port Forwarding)
- MikroTik Documentation — Hairpin NAT (NAT Loopback / Reflection)
Note: Results above are mathematical estimates based on standard formulas. Always verify against official vendor documentation and site conditions before production deployment.
🔗Related Scenarios & Companion Calculators
Browse All 30+ Scenarios →⚡ Ready-to-Use Scenario Presets:
Instant /32 CIDR reference: Subnet Mask is 255.255.255.255, Wildcard 0.0.0.0, Total IPs 1, and 1 Usable Hosts. Ideal for OSPF/BGP Router Loopback & Single Host Route.
Instant /30 CIDR reference: Subnet Mask is 255.255.255.252, Wildcard 0.0.0.3, Total IPs 4, and 2 Usable Hosts. Ideal for Point-to-Point Inter-Router WAN Link (2 Usable IPs).
Instant /29 CIDR reference: Subnet Mask is 255.255.255.248, Wildcard 0.0.0.7, Total IPs 8, and 6 Usable Hosts. Ideal for DMZ Public Server Sub-Block & BGP Peering (6 Hosts).
🛠️ Sibling Calculators in this Category:
Calculate IPv4 network address, broadcast, usable host range, netmask, wildcard, binary mask, and RFC address type (RFC 1918, /31, CGNAT).
Split an IPv4 network into N equal subnets or allocate boundary-aligned VLSM blocks by required host count with CSV and Markdown export.
Expand and compress IPv6 addresses per RFC 5952, calculate network prefix boundaries, /64 SLAAC subnet counts, and child prefix blocks.
Calculate Limit-At (CIR), Max-Limit (MIR), Burst, PCQ, and FQ-CoDel for RouterOS v7 with automated configuration script generation.
Engineering Sensitivity Analysis, Response Curve & Technical Citation
1. 1. 3-Point Engineering Sensitivity & Tolerance Envelope
Comparative evaluation across theoretical laboratory bounds (0% loss), current nominal operating point, and conservative field safety bounds (±15% thermal/aging derating).
| Evaluated Parameter | Ideal Theoretical Bound | Nominal Operating Point | Conservative Safety Bound (±15%) | Engineering Derating Rule |
|---|---|---|---|---|
| External Port (Public) | 7,200 | 8,000 | 9,200 | Engineering Safety Margin (+15% Overhead) |
| Internal Port (Local) | 7,200 | 8,000 | 9,200 | Engineering Safety Margin (+15% Overhead) |
2. 2. Mathematical Function Curve & Operating Coordinate (x₀, y₀)
3. 3. Physical Constants & Normative Standard Clauses
DC Loop Resistance for 23 AWG Solid Copper Cat6
Clause 6.4.1 / Table 145-1 — Nominal 23 AWG solid copper loop resistance at 20°C is 14.0 Ω/100m (TIA maximum ceiling is 18.8 Ω/100m).
Single-Mode Optical Fiber Attenuation Coefficient at 1490 nm
Table 1 / Class B+ & C+ Optical Path — Typical G.652.D attenuation at 1490 nm downstream is 0.22–0.25 dB/km (1310 nm upstream: 0.35 dB/km).
Temperature Coefficient of Resistance for Copper
International Annealed Copper Standard — Used in thermal derating equation: R(T) = R_20 × [1 + 0.00393 × (T - 20)].
4. 4. Independent Technical & Academic Citation (IEEE / APA 7th / BibTeX / LaTeX)
Use the standard citation formats below to reference this computational methodology in engineering specifications, audit reports, or academic papers.
[IEEE] KalkuNet Engineering Team, "MikroTik Port Forwarding (DST-NAT) and Hairpin NAT Generator — Standard Engineering Computational Instrument," KalkuNet Technical Suite, 2026. [Online]. Available: https://kalkunet.com/en/tools/mikrotik-nat-calculator. [Accessed: 2026-11-08].
[APA 7th] KalkuNet Engineering Team. (2026). MikroTik Port Forwarding (DST-NAT) and Hairpin NAT Generator (Production release 2026-11-08) [Engineering computational software]. KalkuNet. https://kalkunet.com/en/tools/mikrotik-nat-calculator
@software{kalkunet_mikrotik_nat_calculator_2026,
author = {{KalkuNet Engineering Team}},
title = {{MikroTik Port Forwarding (DST-NAT) and Hairpin NAT Generator --- KalkuNet Engineering Suite}},
year = {2026},
publisher = {KalkuNet.com},
url = {https://kalkunet.com/en/tools/mikrotik-nat-calculator},
urldate = {2026-11-08}
}
% LaTeX Engineering Derivation — Generated via https://kalkunet.com/en/tools/mikrotik-nat-calculator
\begin{equation}
\text{Model: } DST-NAT: chain=dstnat dst-address=Public_IP dst-port=External_Port action=dst-nat to-addresses=Internal_IP to-ports=Internal_Port
\end{equation}
% Parameter Input Terukur: desc = NVR-CCTV-Server, \; pubIp = 203.142.77.10, \; extPort = 8000, \; intIp = 192.168.88.250
% Hasil Evaluasi Numerik : wanIface = \mathbf{ether1-ISP}, \; pubIp = \mathbf{203.142.77.10}, \; extPort = \mathbf{8000}