Layer 3 Routing allows a UniFi Switch to route traffic between VLANs and to other destinations using static routes. It is possible use L3 Routing with a UniFi Gateway or third-party gateway.
Note: When using a third-party gateway, it needs to support VLAN tagging and manual configuration of static routes.
How does it work?
Layer 3 Routing is enabled by setting the Router option on a new or existing Virtual Network to the UniFi Switch. Afterwards, an additional network is automatically created with the Inter-VLAN routing name. This network has the following characteristics:
Subnet - The
10.255.253.0/24IP address range is used by default but it can be changed.
- VLAN - Fixed to VLAN ID 4040.
UniFi Gateway - If present, the UniFi Gateway will use the
UniFi Switch - The first UniFi Switch that L3 Routing is enabled on will use the
10.255.253.2IP address. Additional L3 UniFi Switches will use the
10.255.253.3IP address and so on.
Default Gateway - The L3 UniFi Switches use
10.255.253.1as the default gateway to the internet (default route).
In addition to routing traffic between VLANs, L3 UniFi Switches provide the below features:
- Static Routing - Create a static route to a next-hop IP address or interface.
- DHCP Server - Provide DHCP assigned IP addresses to devices.
- DHCP Relay - Forward DHCP requests to another DHCP server.
Using a Third-Party Gateway
When using a third-party gateway, it needs to match the configuration used by UniFi. The required steps are outlined below. Please refer to the documentation of the third-party manufacturer for more information.
- Configure a VLAN Virtual Interface (VIF) on the third-party gateway 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.
- Assign the
10.255.253.1/24IP address to the interface of the third-party gateway.
- Create a static route on the third-party gateway that matches the subnet of the network configured in UniFi (for example
192.168.2.0/24) and use
10.255.253.2as the next-hop.
- If more than one network is configured in UniFi, add additional static routes.
- If there are other L3 UniFi switches using different IP addresses, add additional routes.
Configuration Example and Testing
Below is an example configuration that can be used on an EdgeRouter. The eth1 interface connects to the Layer 3 UniFi Switch.
set interfaces ethernet eth1 vif 4040 address 10.255.253.1/24 set protocols static route 192.168.2.0/24 next-hop 10.255.253.2
commit ; save
Afterwards, test if the UniFi Switch is reachable on both networks: