UniFi Network - L3 Routing with Third-Party Gateways

2023-09-25 00:51:48 UTC

This article describes how to use L3 (Inter-VLAN) Routing on a UniFi Switch alongside a third-party gateway. All device-specific assistance should be directed to the third-party manufacturer.

Requirements & Notes

  • For the best experience, we recommend to use a UniFi Gateway instead of a third-party gateway.
  • When using a third-party router, it needs to support VLAN tagging and manual configuration of static routes.
  • If either of the above features are not supported on the third-party router, then it cannot be used with L3 UniFi switches.

Using a Third-Party Gateway Router

Once the network with a UniFi switch set as the Router is created, an additional network is created automatically with the Inter-VLAN routing name. This network is used to route the traffic between the (UniFi or third-party) gateway and the L3 UniFi switch.

  • The Inter-VLAN routing network is assigned the IP range and uses VLAN4040.
  • The first L3 UniFi switch set as a Router will use the IP address.
  • Additional L3 UniFi switches will use the IP address and so on.
  • The L3 UniFi switch uses as the default gateway to the internet (default route).

Note: It is not possible to modify the UniFi switch network range ( or use a different VLAN than 4040. The third-party router needs to match the UniFi configuration.

The following needs to be added to the third-party gateway router to match the UniFi configuration:

  • Configure a VLAN Virtual Interface (VIF) on the third-party router and tag VLAN4040 on an interface that connects to the UniFi switch. This will be the uplink port of the switch.
  • Ensure that the UniFi switch tags VLAN4040 on the uplink port to the third-party gateway using either the All switch port profile or a custom profile.
  • Assign the IP address to the interface of the third-party router.
  • Create a static route on the third-party router that matches the Subnet of the network configured in UniFi (for example and set as the next-hop. 
  • If more than one network is configured in UniFi, add additional static routes.

Note: If additional L3 UniFi switches are used, the next-hop needs to be modified, for example

Was this article helpful?
241 out of 474 found this helpful