Skip to content

UPnP and Automatic Port Mapping

RouterOS implements Universal Plug and Play Internet Gateway Device (UPnP IGD) versions 1 and 2. UPnP lets applications on the local network automatically request inbound port mappings through NAT — without requiring manual firewall or NAT rules. Common use cases include gaming consoles, P2P clients, and some VoIP applications.

/ip upnp
/ip upnp interfaces

When a UPnP-capable application needs an inbound connection, it sends a UPnP request to the router. RouterOS creates a dynamic dstnat rule in the NAT table that forwards the requested external port to the requesting host. When the application releases the mapping (or its lease expires), the rule is removed.

Dynamic rules created by UPnP are marked with the D flag and appear at the end of the NAT table.

Gaming consoles (PlayStation, Xbox, Nintendo Switch) rely on UPnP to dynamically open ports for multiplayer sessions. When UPnP is unavailable, consoles typically fall back to NAT Type 2 (moderate) or NAT Type 3 (strict), which can prevent peer-to-peer matchmaking or voice chat.

Enabling UPnP with the standard configuration is usually sufficient. The console will automatically request and release mappings as needed. To verify a console is connecting successfully, check the dynamic NAT rules created by UPnP:

/ip firewall nat print where dynamic

You should see dstnat entries appear during active gaming sessions. If not, confirm:

  • The console’s LAN interface is set as type=internal
  • UPnP is enabled on the device itself (usually under network settings)

Media servers like Plex (TCP/UDP 32400) and Emby/Jellyfin (TCP 8096/8920) use UPnP to make themselves accessible for remote streaming. However, for these workloads, manual port forwarding is generally preferred — see UPnP vs Manual Port Forwarding.

If you choose UPnP for a media server, note that any LAN host can request port mappings — there is no built-in per-host restriction in RouterOS UPnP. For stable, predictable access, manual port forwarding is the better choice for media servers.

SIP-based VoIP clients and some conferencing tools use UPnP to open RTP media ports dynamically. RouterOS includes NAT helpers (SIP ALG) which may handle SIP NAT traversal without UPnP. Test with the SIP helper first; enable UPnP only if the helper is insufficient for your deployment.

BitTorrent clients and similar P2P applications use UPnP to improve connectivity. UPnP is appropriate here when all LAN users are trusted and you want to avoid managing per-client port forward rules.

/ip upnp
set enabled=yes

Global parameters:

ParameterDescription
enabledyes to activate the UPnP service
allow-disable-external-interfaceAllow UPnP clients to disable the external interface. Set to no in production.
show-dummy-ruleShow a placeholder NAT rule when no active mappings exist (improves compatibility with some IGD clients).

Recommended settings for most deployments:

/ip upnp
set enabled=yes allow-disable-external-interface=no show-dummy-rule=yes

UPnP requires at least one internal interface (LAN side) and one external interface (WAN side).

/ip upnp interfaces
add interface=bridge type=internal
add interface=ether1 type=external
ParameterValueDescription
interfaceinterface nameInterface to participate in UPnP
typeinternal / externalinternal = LAN; external = WAN facing the internet

Only add trusted LAN interfaces as internal. Never add an untrusted or public-facing interface as internal.

Verify the configuration:

/ip upnp interfaces print

Example output:

Columns: INTERFACE, TYPE
# INTERFACE TYPE
0 bridge internal
1 ether1 external

RouterOS does not provide a dedicated UPnP mappings sub-menu. Active UPnP port mappings are visible only as dynamic NAT rules in the firewall table.

UPnP mappings appear as dynamic dstnat rules:

/ip firewall nat print where dynamic

Example output showing a UPnP-created mapping:

Flags: X - disabled, I - invalid, D - dynamic
# CHAIN ACTION PROTO DST-PORT TO-ADDRESSES TO-PORTS
0 D dstnat dst-nat udp 45678 192.168.88.10 45678
1 D dstnat dst-nat tcp 55000 192.168.88.15 55000

RouterOS does not provide a dedicated UPnP event log. To monitor traffic flowing through UPnP-opened ports, add firewall log rules:

# Log forwarded traffic through a specific UPnP-opened port
/ip firewall filter
add chain=forward protocol=udp dst-port=45678 action=log log-prefix="UPNP-FWD " place-before=0

UPnP is a convenience feature with real security trade-offs. Consider these risks before enabling it:

RiskDetail
Any LAN host can open portsMalware or a compromised device can punch holes through your firewall without admin interaction
No authenticationUPnP has no mechanism to verify that the requesting application is legitimate
Difficult to auditDynamic mappings come and go; without logging you may not know what ports are open at any given moment
Privileged portsAny LAN application can request mappings on any port including ports below 1024

Mitigations:

  • Enable UPnP only on interfaces where all connected devices are trusted
  • Set allow-disable-external-interface=no
  • Periodically review active mappings with /ip firewall nat print where dynamic
  • Consider whether static port forwarding is a better fit for your use case

Manual dstnat rules are the most auditable and stable option. Rules are always visible, never change without admin action, and are appropriate for any service with a fixed address and port.

/ip firewall nat
add chain=dstnat in-interface=ether1 protocol=tcp dst-port=443 \
action=dst-nat to-addresses=192.168.88.10 to-ports=443 \
comment="static forward to internal web server"

RouterOS also implements NAT-PMP. NAT-PMP is simpler than UPnP (no SOAP, no discovery), and some clients (Apple Bonjour, certain game engines) prefer it. It provides the same automatic mapping capability with less protocol overhead.

Configure NAT-PMP under /ip nat-pmp:

/ip nat-pmp
set enabled=yes
/ip nat-pmp interfaces
add interface=bridge type=internal
add interface=ether1 type=external

If clients support both protocols, enabling both in parallel is safe — mappings from each protocol are managed independently.

For UDP-heavy applications like games and VoIP, configuring endpoint-independent mapping (EIM) can improve NAT traversal without requiring any dynamic mapping protocol. With EIM, UDP flows from the same internal source always use the same external port, allowing peers to reach each other through STUN-based hole-punching.

/ip firewall nat
add chain=srcnat action=masquerade out-interface=ether1 protocol=udp \
comment="endpoint-independent NAT for UDP"

When internal hosts need to reach a service by its public IP/domain while both are on the same LAN, hairpin NAT resolves the issue. This is a companion to manual port forwarding, not a replacement for UPnP.

/ip firewall nat
add chain=srcnat action=masquerade src-address=192.168.88.0/24 \
dst-address=192.168.88.10 protocol=tcp dst-port=443 \
comment="hairpin NAT for internal web server"
UPnP / NAT-PMPManual Port Forwarding
SetupAutomatic, application-drivenAdmin-configured
StabilityMappings are temporary and dynamicPermanent until removed
AuditabilityHarder — mappings change dynamicallyEasier — rules are always visible
SecurityLower — any LAN host can requestHigher — admin controls what is open
Best forGaming consoles, P2P clients, dynamic appsServers, PBX, CCTV, stable services

Use UPnP or NAT-PMP when:

  • Devices (gaming consoles, smart TVs) need port mappings but don’t support static configuration
  • Applications dynamically negotiate ports (game clients, BitTorrent, some VoIP)
  • All LAN devices are trusted and managed

Use manual port forwarding when:

  • Running a self-hosted service (Plex, game server, SIP trunk, NVR)
  • You need predictable, auditable, always-on rules
  • Security requirements demand admin control over what ports are open

If /ip firewall nat print where dynamic shows no dstnat entries after a device or application attempts to register:

  1. Verify UPnP is enabled: /ip upnp print should show enabled: yes
  2. Check interface assignments: Both an internal and external interface must be configured — verify with /ip upnp interfaces print
  3. Check client-side UPnP: The device must have UPnP enabled in its own network settings (common on consoles, disabled by default on some PCs)
  4. Firewall blocking discovery: UPnP discovery uses SSDP (UDP multicast to 239.255.255.250:1900). Ensure firewall rules on the internal interface are not blocking this traffic

If a device disconnects without releasing its UPnP mapping, the dynamic NAT rule remains until the lease expires. Dynamic NAT rules created by UPnP cannot be removed individually from the UPnP sub-menu — they will clear automatically when the lease expires or the router reboots.

If a console reports NAT Type 3 (strict) despite UPnP being enabled:

  • Confirm the console’s interface is configured as internal in /ip upnp interfaces
  • Verify that /ip firewall nat print where dynamic shows dstnat entries during an active session — if not, the console’s UPnP requests are not reaching the router
  • Verify no upstream NAT (double-NAT) is occurring between RouterOS and the internet — UPnP only affects the local router’s NAT table

If UPnP stops working after RouterOS restarts, verify your configuration is saved (not just applied in-session). Check with /system script print or review /ip upnp print after reboot to confirm enabled=yes persists.

A typical home or small office deployment:

# Enable UPnP
/ip upnp
set enabled=yes allow-disable-external-interface=no show-dummy-rule=yes
# Define interfaces
/ip upnp interfaces
add interface=bridge type=internal
add interface=ether1 type=external

Verify after enabling:

/ip upnp interfaces print
/ip firewall nat print where dynamic