Ubiquiti · port forwarding

UniFi gateways: port forwarding does not work

Ubiquiti's port forwarding article gives the current path: in Network 9.4 go to Settings, Policy Engine, Port Forwarding, and in 9.3 use Settings, Policy Table, Create New Policy, Port Forwarding. Name the rule, choose one WAN or all, set the incoming address and port and whether it comes from anywhere or specific addresses, set the forward address and port to the target device, choose TCP, UDP or both, and optionally enable syslog. It lists the causes when a rule seems not to work.

The gateway may not have a public address, as with double NAT or carrier NAT: check whether the WAN address is in 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 or 100.64.0.0/10. A WAN port can be forwarded to only one device, so TCP 443 can go to just one LAN host, though several WAN ports can go to the same LAN port. UPnP may already be using the port; Ubiquiti recommends keeping UPnP disabled unless needed, and to disable it under Internet settings to test.

Traffic may be blocked upstream at the modem or a third-party firewall. The LAN host may be blocking the port with its own firewall or may have the wrong default gateway. Test from outside the network and remove rules you no longer use.

Before you forward anything, decide whether you need to. Many services, such as remote viewing of cameras or file access, have a secure cloud or VPN route that does not expose a port.

If you do forward, choose a non-standard external port, limit the source addresses where you can, keep the target device updated and review the list of rules every few months. Give each rule a clear name so that an old rule is obvious when you look at the list. If a rule works from outside but not from inside the house, that is hairpin NAT, and the fix is to use the device's internal address or a local DNS record for indoor use.

Model compatibility: Device coverage
ScopeCovered or excluded
ConditionPort forwarding is not working

Differential

UniFi gateways: compare the causes

  1. 1

    Double or carrier NAT

    What separates it.

    The rule never sees traffic because a double NAT or carrier NAT sits in front of the gateway

    How to confirm.

    Bridge the modem or the provider's unit, so that the gateway has a public address

  2. 2

    The WAN port already forwarded

    What separates it.

    There is a conflict because the WAN port is already forwarded to another device

    How to confirm.

    Forward each WAN port once only, since a WAN port can go to one device

  3. 3

    UPnP using the port

    What separates it.

    The rule is ignored because UPnP already uses the port

    How to confirm.

    Disable UPnP as a test, and see whether the manual rule then works

  4. 4

    A LAN host firewall

    What separates it.

    The connection is refused because the firewall on the LAN host blocks the port

    How to confirm.

    Allow the port in the host's own firewall, as well as in the gateway's rule

  5. 5

    A wrong route on the host

    What separates it.

    There is no reply because the host has a wrong route back to the gateway

    How to confirm.

    Fix the host's default gateway, so that replies go back through the UniFi gateway

Record before making changes

UniFi gateways: observations

  • The settings of the rule that you created
  • Whether UPnP is switched on for the gateway
  • The state of the firewall on the host
Completed: 0 / 7
  1. Open Port Forwarding, which is in the Policy Engine or the Policy Table, depending on the version.

  2. Create the rule

    Create the rule by giving it a name, choosing the WAN interface and entering the ports.

  3. Set the target, by entering the address and the port of the device on the LAN.

  4. Choose TCP, UDP or both

    Choose the protocol for the rule, which can be TCP, UDP or both, depending on the service.

  5. Check for conflicts, such as UPnP using the same port, or a second rule for the same port.

  6. Test from outside

    Test from outside your home network, using cellular data on a phone rather than your wifi.

  7. Remove unused rules

    Remove unused rules regularly, so that ports are not left open when they are not needed.

Model-specific

UniFi gateways: model limits

Menus

The Policy Engine path applies to Network 9.4; earlier versions differ.

Multi-WAN

You can choose one WAN or all WANs.

Stop boundary

UniFi gateways: service criteria

  • !

    If the port stays closed with a public WAN address and no upstream firewall, contact Ubiquiti support

  • !

    If the provider blocks the port, ask the provider

  • !

    If the host does not reply, check its routing

References

Exact questions

UniFi gateways: common questions

Can one WAN port go to two devices?+

No, one WAN port can be forwarded to only one device on the LAN.

What does UPnP do?+

UPnP opens ports automatically, though Ubiquiti recommends keeping it switched off.

Can the host block it?+

Yes, the host can block the traffic through its own firewall, so allow the port there too.

Can I log rules?+

Yes, you can log rules, using syslog, to see what traffic they match.

Is a VPN better?+

Ubiquiti suggests WireGuard or Teleport for remote access, instead of opening ports.

Model-specific instructions

Ubiquiti UniFi Dream Machine Special Edition

Port forwarding on a UniFi Dream Machine Special Edition is straightforward in the UniFi Network application, but it works only if the device's address, the rule and the internet connection all line up, and the last of these is the one most often wrong. The UDM SE is a rack gateway with a built-in PoE switch and no Wi-Fi radio, with the same processor as the UDM Pro, managed through UniFi Network.

A forwarding rule sends traffic that arrives at the gateway's public address on a chosen port to a device on your network, for a game server, a camera, a remote desktop or a web service.

First give the target a fixed address. In UniFi Network, open the client list, select the device, and set a fixed IP address, or create a DHCP reservation, so that the address never changes. Then create the rule.

Open Settings and find the Port Forwarding section, which is under Firewall and Security or Routing depending on the version, and add a rule: name it, choose the protocol, TCP, UDP or both, set the external port the internet will use, the forward IP address of the device and the forward port it listens on. Make sure that the rule is enabled and that the interface is the WAN you use. If your gateway has two WANs, choose the right one.

Check the other sides. The device's own firewall must allow the port, and the application must be running and listening. Test from outside your network with a phone on mobile data or an online port checker, since tests from inside often fail with some setups unless hairpin NAT is enabled.

Check that the gateway's WAN address is a public one: if it is a private address or begins with 100.64, your provider uses carrier-grade NAT, which makes forwarding impossible; ask the provider for a public address. If the UDM SE sits behind another router, you have a double NAT; use bridge mode on the first or forward on both. Review the firewall rules and any threat-management settings, since an intrusion prevention feature can block traffic.

If you do not need a fixed external address, use dynamic DNS. Quote the model and the serial number to Ubiquiti if the port stays closed.

Only listed models
FieldValue
Model
Ubiquiti UniFi Dream Machine Special Edition
UDM-SE
Conditionport forwarding is not working
  • The application and its ports
  • The device's address
  • The gateway's WAN address
  • Whether a second router is in front

Compare possible causes

The target has no fixed address
What separates it.

The rule fails after a lease changes

How to confirm.

Set a fixed address or a DHCP reservation

Port, TCP/UDP selection or WAN does not match
What separates it.

The port shows closed

How to confirm.

Match the application and the WAN

The device firewall or application not listening
What separates it.

The gateway rule is right and the port stays closed

How to confirm.

Allow the port and run the application

Carrier-grade NAT or a double NAT
What separates it.

Nothing works from outside

How to confirm.

Ask for a public address or use bridge mode

A firewall or threat-management rule
What separates it.

Traffic is dropped

How to confirm.

Review the rules and the intrusion settings

  1. Fix the target's address.

    Reservation.

  2. Add the rule.

    In Port Forwarding.

  3. Match the ports and WAN.

    Protocol too.

  4. Allow the port.

    On the device.

  5. Test from outside.

    On mobile data.

  6. Check the WAN address.

    For carrier-grade NAT.

A fixed address

The rule points at one address.

The rule

External port, protocol, forward address and port.

Testing

Test from outside the network.

NAT types

Carrier-grade and double NAT block forwarding.

Firewall

Rules and IPS can drop traffic.

Ubiquiti help

Quote the model and serial number.

How do I forward a port on a UDM SE?

Fix the address, then add a rule in Port Forwarding.

Why is my port closed?

The device, a double NAT or carrier-grade NAT.

Where is the setting?

Under Firewall and Security or Routing, by version.

Can IPS block it?

Yes.

Should I test from inside?

No, from outside.

Who do I contact?

Ubiquiti.

  • Close rules you no longer use
  • Contact Ubiquiti if the port stays closed

Ubiquiti UniFi Cloud Gateway Ultra

Port forwarding on a Ubiquiti Cloud Gateway Ultra lets a service on your network be reached from the internet, and it works only if the gateway has a public address, the device has a fixed internal address and the rule is correct. In the UniFi Network application, go to Settings, Security, Port Forwarding, or the Firewall and Security section in newer versions, and create a rule.

Give it a name, choose the protocol (TCP, UDP or both), enter the external port that people will connect to and the internal address and port of the device. Set the device to a fixed address first, either by setting a static address on it or by making a DHCP reservation in the application, since a changed address breaks the rule.

If it does not work, check the basics. The gateway's WAN address must be public: if your provider uses carrier-grade NAT, the address shown for the gateway begins with 100.64 to 100.127, or is a private address, and forwarding from the internet cannot work until the provider gives you a public address. Test from outside your network, such as from a phone on mobile data, because testing from inside often fails without hairpin NAT.

Make sure the device's own firewall allows the connection and that the service is listening on the port. Check that no other rule or Intrusion Prevention feature is blocking the traffic.

Security matters. Forward only the ports you need, prefer a VPN to opening a service to the whole internet and keep the service up to date. Check the gateway's logs for blocked traffic.

If you change the gateway's WAN type or restart it, the rules persist. For cameras and game servers, use the vendor's recommended ports. Some devices can use UPnP, which Ubiquiti lets you enable, but manual rules are easier to control.

Contact Ubiquiti support if a correct rule on a public address does not work, and send a support file. In UniFi, forwarding is separate from the firewall: a rule in Port Forwarding makes the translation, but a firewall policy in the Zone-Based Firewall or the older Traffic Rules can still block the traffic, so check the Security settings for a rule that drops traffic from the internet to the internal zone.

If you have a Dream Machine or another router in front of the gateway, there are two layers of translation and you must forward on both. Dynamic DNS can provide a name for a home address that changes. Keep the forwarded device updated and avoid forwarding administrative services such as remote desktop.

Only listed models
FieldValue
Model
Ubiquiti UniFi Cloud Gateway Ultra
UCG-Ultra
  • When the problem started and what changed
  • Any message on the screen
  • Whether it happens in every app
  • The model and serial number

Compare possible causes

A device with a changing address
What separates it.

The rule stops working later

How to confirm.

Reserve a fixed address

Carrier-grade NAT
What separates it.

The WAN address is not public

How to confirm.

A public WAN address is required for inbound connections that carrier-grade NAT otherwise blocks

Testing from inside the network
What separates it.

The service looks unreachable

How to confirm.

Test from mobile data

A firewall on the device
What separates it.

The connection is refused

How to confirm.

Allow the port on the device

A conflicting rule
What separates it.

Traffic is blocked

How to confirm.

Check firewall rules and Intrusion Prevention

  1. Reserve the device's address.

    Static or DHCP reservation.

  2. Create the forwarding rule.

    Protocol, ports, address.

  3. Check the WAN address.

    It must be public.

  4. Test from outside.

    Use mobile data.

  5. Check device firewall.

    And service listening.

  6. Contact Ubiquiti.

    With a support file.

Carrier-grade NAT

The provider shares one public address.

VPN

Safer than opening a port.

Why doesn't my port forward work?

Carrier-grade NAT or a changing address.

Where do I set it?

In the UniFi Network settings.

How do I test?

From outside your network.

Is it safe?

Forward only what you need.

  • If the steps do not clear it, contact the maker with the model and serial number
  • Back up important data before a reset
  • Check the warranty before paying for a repair

References for the model instructions