How to Setup and Secure UniFi VLAN

When you have a UniFi Security Gateway or UniFi Dream Machine (UDM, UDM Pro) you can create different VLANs on your network. Virtual LANs (VLANs), allow you to divide your physical network into virtual networks, offering isolation, security, and scalability.

Now you might think, do I really need VLANs? But when guests are connecting to your home network, you probably don’t want them to have access to all your network devices. And if you have a smart home, then creating a separate VLAN might be a good idea. Because the security of IoT devices is not always as it should be.

So in this article, I will explain how to set up and secure VLANs in the UniFi Network Console.


This article is updated in April 2024, using the latest UniFi Network version (8.1.x). It now include the new Traffic Rule and Firewall rule screens.

Setup UniFi VLANs

Creating VLANs in UniFi exists out of a couple of steps because we not only have to create the different networks, but we also need to secure the VLANs. The “problem” with UniFi is that inter-VLAN traffic is allowed by default. So without any firewall rules, traffic from for example the guest VLAN can just access the main VLAN.

In this example, we will be creating 3 VLAN networks for:

  • Guests – VLAN 20
  • Cameras – VLAN 30
  • IoT devices – VLAN 40

The guest VLAN is a bit different from the other VLANs because UniFi will automatically create the necessary firewall rules for the guest network. All you have to do is Isolate the network in the network settings.

So in the steps below, we will create the guest network, with the correct settings, but further on I will use the IoT VLAN as an example.

Step 1 – Create the UniFi VLAN Networks

The first step is to create the different networks for the VLANs. I have used custom VLAN IDs in the steps below, but you can also leave Auto Scale Network on. This way UniFi will automatically create the IP Range and VLAN ID.

Open your UniFi network console and navigate to:

  1. Settings >Networks
  2. Click on New Virtual Network

We are first going to create the guest network:

  1. Enter Guests at the Network Name
  2. Deselect Auto-Scale Network
  3. Set the host address to
  4. Change Advanced Configuration to Manual
  5. Change the VLAN ID to 20 so it matches the IP range
  6. Enable Isolation by checking Network
  7. Change the Content Filtering to Family (optional)
  8. Click Apply Changes

Next, we need to create the network for the Cameras and IoT devices. Click again on New Virtual network, and repeat the steps below for both Cameras and IoT, using VLAN 30 for cameras and 40 for IoT:

  1. Network Name: IoT
  2. Disable Auto Scale Network
  3. Host Address:
  4. Advanced Configuration: Manual
  5. VLAN ID: 40
  6. Isolation: Off
  7. Click Apply Changes (and repeat for cameras)

Using VLAN Magic

If you are running UniFi Network 8.0.24 or higher, then you can also use the new VLAN Magic feature to create virtual networks. It allows you to create a new virtual network from the device overview, and simply assign devices to the VLAN by selecting them.

UniFi Network will then use the virtual network override feature to move the device to the assigned VLAN. The advantage of this method is that you don’t need to create wireless networks for your VLANs, but when applying this on a wired device, you will need to make sure that your ports are configured correctly (I will explain that later in the article).

UniFi VLAN Magic

To create a new VLAN with VLAN Magic:

  1. Open the Topology view
  2. Click on the plus icon the create a new VLAN
  3. Select the devices in the overview to assign them
  4. Click on Apply Changes

Step 2 – Block traffic between VLANs

With the networks and VLANs created, we need to block the traffic between them. By default, devices in, for example, the IoT VLAN, can access the device in your main VLAN. Guests however are already isolated by the automatically generated firewall rules by the Isolated Network option.

There are two options to block inter-VLAN traffic, we can create custom firewall rules, or use a Traffic Rule. The latter is a lot quicker to create, but I will explain both methods.


During my tests, it took a couple of minutes until a traffic rule was effective. So after creating a rule, give it a couple of minutes before you test it out.

Using Traffic Rules

Ubiquiti is really promoting the use of Traffic Rules to block or allow traffic on your network. In the last update, they merged the Traffic Rules and Firewall rules into one screen. You can now create two rule types: Simple and Advanced. Simple is the “old” Traffic Rule, and Advanced is the Firewall rule.

  1. Click on Security
  2. Choose Traffic & Firewall Rules
  3. Click on Create Entry
  4. Make sure Simple is selected as Rule type
Create Traffic Rule

When creating Traffic rules, make sure that you have set the Rule Type to simple.

  • Rule type: Simple
  • Name: Block Inter-VLAN
  • Action: Block
  • Source: All Devices
  • Destination: All Local Networks
  • Traffic Direction: Traffic from all local networks
  • Schedule: Always
Block inter-vlan traffic

You probably want to access your IoT device, for example, from your main (default) VLAN. To do this we can create another Traffic Rule to allow traffic from the Default network to the IoT network. Now this is where Traffic Rules become a bit confusing for most, let’s first create the rule and I will then explain it a bit:

In the Traffic Rules click on Create Entry:

  • Name: Allow Default to Access IoT Devices
  • Action: Allow
  • Source: Default
  • Destination: Local Network
    Select: Iot
  • Traffic Direction: Traffic to all networks
  • Schedule: Always
Allow default to access vlan

So what we have done here, is Allow all traffic from the Default network (Device/Network) to a local network, in this case IoT. The Traffic Direction is set to Traffic to all local network, which means that traffic initiated from the default network is allowed, but traffic initiated from the IoT network not.

I have only selected IoT here as the local network, but you can also select the other VLANs you want to have access to from your default network.

Using Firewall Rules

We can also block the inter-VLAN traffic with custom firewall rules. This is however a bit more work compared to the Traffic Rules.

Before we can block the inter-VLAN traffic, we first need to create 3 other rules:

  • Allow established and related connections
  • Drop invalid state connections
  • Allow the main VLAN to access all VLANs

To create a new Firewall rule, we create a new entry in the Traffic & Firewall Rules. But make sure that you set the type to Advanced in the new rule.

  1. Click on Create New Rule
Create new firewall rule

We are first going to create the rule that allows all established and related sessions.

  • Rule Type: Advanced
  • Type: LAN in
  • Description: Allow established and related sessions
  • Action: Accept
  • Source Type: Port/IP Group
  • IPv4 Address Group: Any
  • Port Group: Any
  • Destination Type: Port/IP Group
  • IPv4 Address Group: Any
  • Port Group: Any
  • Under Advanced: select Match State Established and Match State Related
  • Apply Changes

The second rule that we are going to create is to drop all invalid states:

  • Rule Type: Advanced
  • Type: LAN in
  • Description: Drop invalid state
  • Action: Drop
  • Source Type: Port/IP Group
  • IPv4 Address Group: Any
  • Port Group: Any
  • Destination Type: Port/IP Group
  • IPv4 Address Group: Any
  • Port Group: Any
  • Under Advanced: select Match State Invalid
  • Apply Changes

And the third rule that we need to add is to allow traffic from our main VLAN to the other VLAN. This way we will be able to manage all the devices even if they are in IoT VLAN for example.

To create this rule we will first need to define an IP Group. Port/Ip Groups allow you to easily apply a rule to multiple port numbers or IP ranges. In this case, we want to match the IP ranges of all VLANs.

  1. In the settings menu, click on Profiles
  2. Scroll down and click Create New under IP Groups
  3. Profile name: All Private IPs
  4. Type: IPv4 Address/Subnet
  5. Address: (this will match all addresses that start with 192.168.x.x)
  6. Click Add
Private IP Group

With the IP group created, go back to Traffic & Firewall Rules and create the following rule:

  • Rule Type: Advanced
  • Type: LAN in
  • Description: Allow main VLAN access to all VLAN
  • Action: Accept
  • Source Type: Network
  • Network: Default
  • Network Type: IPv4 Subnet
  • Destination Type: Port/IP Group
  • IPv4 Address Group: All Private IPs (the IP Group that we just created
  • Port Group: Any

We can now create the rule that will block traffic between the VLANs. The rules that we just created will ensure that we can still access the devices in the other VLANs from the main VLAN. For this rule, we are also going to use the IP Group that we created earlier.

Click on Create New Rule in Traffic & Firewall Rules and add the following rule:

  • Rule Type: Advanced
  • Type: LAN in
  • Description: Block VLAN to VLAN
  • Action: Drop
  • Source Type: Port/IP Group
  • IPv4 Address Group: All Private IPs
  • Destination Type: Port/IP Group
  • IPv4 Address Group: All Private IPs
  • Port Group: Any

We now have separated the VLANs in our UniFi network, preventing unwanted inter-VLAN traffic.

Step 3 – Block Access to Unifi Network Console from VLANs

Devices in your VLAN will need to have access to your network console (UDM Pro for example). But what we don’t want is that users (guests or IoT devices) are able to access the interface of our UniFi network console.

What we also want to prevent is that devices from IoT can access the gateway of the main VLAN.

Now this is something that should be possible with a Traffic Rule in my opinion, but honestly, I can’t get it to work. I am still waiting for an answer about this from Ubiquiti. I created the following rule, if anybody knows why this isn’t working, please drop a comment below:

  • Action: Block
  • Category: IP Address
  • IP Address:
    • – Port 22,80,443
    • – Port 22,80,443
    • – Port 22,80,443
    • – Port 22,80,443
  • Device/Network: IoT, Cameras, Guests
  • Schedule: Always
  • Description: Block VLANs to Gateway except Default

So for now, we will create a firewall rule for this. First, we need to create a couple of Port and IP Groups. Open the Profiles in the settings menu and click on Create New Group under Port and IP Groups. Create the following IP Groups:

Profile NameTypeAddress / Port
Block IoT to GatewaysIPv4 Address/Subnet192.168.1.1
Block IoT Gateway InterfaceIPv4 Address/Subnet192.168.40.1
Block Cameras to GatewaysIPv4 Address/Subnet192.168.1.1
Block Cameras Gateway interfaceIPv4 Address/Subnet192.168.30.1

The last Port Group that we need to create is to block only HTTP, HTTPS, and SSH access to the UniFi Network Console. The device will need to be able to access the gateway, but as mentioned, we don’t want to expose the console self.

  • Profile Name: http,https,ssh
  • Type: Port Group
  • Port: 80, 443, 22

Next, we are going to add the firewall rules. This time we will be using the type LAN Local

  • Rule Type: Advanced
  • Type: LAN local
  • Description: Block IoT to Gateways
  • Action: Drop
  • Source Type: Network
  • Network: IoT
  • Destination Type: Port/IP Group
  • IPv4 Address Group: Block IoT to Gateways
  • Port Group: Any

And the rule to block access to the UDM Console. Note that we will be using the Port Group http,https,ssh here that we created earlier!

  • Rule Type: Advanced
  • Type: LAN local
  • Description: Block IoT to UDM Interface
  • Action: Drop
  • Source Type: Network
  • Network: IoT
  • Destination Type: Port/IP Group
  • IPv4 Address Group: Block IoT Gateway Interface
  • Port Group: http,https,ssh

Repeat the steps above but this time for the Cameras VLAN.

Assign devices to VLANs in UniFi Network

We have created all necessary rules to block inter-VLAN traffic, so all we need to do now is assign our devices to the correct VLAN in UniFi Network. For wired devices, we can assign a network to the port on the switch. And for the wireless devices, we will need to create a separate SSID.

Assign VLAN to Switch Port

By default, each switch port allows all tagged VLAN traffic. This means that if the connected device has the correct VLAN ID configured, it can access that VLAN. Which for most situations. It also allows access points or switches to pass through traffic from all VLANs if needed.

But when we have a network camera or smart home device connected to a switch, then we want to only allow access to the corresponding VLAN. The device should not be able to access any other VLAN (by changing its VLAN ID for example).

To do this, we will need to configure the Native VLAN on the port and block all tagged VLAN traffic.

In the UniFi Network console, open the new Port Manager and select your Switch. We are going to use the new Ports Manager because this will give you a create overview of all your switch ports and VLANs.


By default, you can select and change multiple ports by just selecting them one after another. Mind this when you want to change another port.
  1. Open the Port Manager
  2. Select the Switch
  3. Select a port of a camera or smart home device
  4. Change the Native VLAN to the correct Network (VLAN)
  5. Change Tagged VLAN Management to Block All
  6. Reboot your Camera by Power Cycle the port
Assign VLAN to switch port

Change the other ports as well, assign them to the main VLAN by selecting the Port Profile LAN or another appropriate Port Profile.

Make sure that you Allow All Tagged VLAN traffic on the Uplink port (recognized by the up arrow ^) and the access points port

Assign VLAN to Wireless Devices

If you have a UniFi doorbell, for example, you might also want to assign this device to the camera’s VLAN. The problem is that we can’t set a VLAN on the doorbell itself. The same problem occurs with a lot of IoT devices, on most, you can’t configure a VLAN ID.

So the only option is to create a separate SSID (wireless network) for each VLAN and assign the wireless network to the correct VLAN.


We can also use Private Pre-Shared keys for this. This way you only have one SSID, but depening on the used password, a device is assigned to a different virtual network (VLAN).

But I have noticed, that not all devices seem to work well with this yet, so make sure you test it out properly.
  1. Open Settings and select WiFi
  2. Click on Create New WiFi network
  3. Enter a name and password for the wireless network
  4. Change network to the correct VLAN (IoT for example)
  5. Click Add WiFi network
Assign VLAN to UniFi WiFi network

You can change the WiFi connection of your UniFi Doorbell in the Protect Console > Devices > Settings > WiFi Connection.

Creating Firewall Exceptions

Sometimes you need to allow access between specific devices in different VLANs. In these cases, there are again two options to allow this. We can create a Traffic Rule or add a Firewall rule.

Using a Traffic Rule

Traffic Rules are the most convenient to use for this. We can simply create a new rule where we can select the device that we want to give access to the specified VLAN. For example, to give the LAB01 notebook access to the Default VLAN, we can create the following traffic rule:

  • Action: Allow
  • Source: <select-device>
  • Destination: Local Network
  • Select network: Default
  • Traffic Direction: Traffic to all local networks
  • Schedule: Always

Using a Firewall Rule

When using a Firewall rule, we need to create an allow rule and place the rule above the Block VLAN to VLAN rule. Let’s take the following example, allowing IoT devices to access a Raspberry PI in the main VLAN.

When you create an allow rule, try to be as specific as possible. If it’s only between two devices, then use the IP Address of both devices. If you know the protocol, then specify the port number as well.

Create a new firewall rule:

  • Type: LAN In
  • Description: IoT to Raspberry Pi
  • Action: Allow
  • Source Type: Network
  • Network: IoT
  • Destination Type: IP Address
  • IPv4 Address: 192.168.1.x

Next, we will need to move the rule above the Block VLAN to VLAN rule that we have created in the beginning. You can drag and drop rules using the 6 dots at the beginning of the rule:

  1. In the Traffic & Firewall Rules select Advanced
  2. Choose LAN In
  3. Drag the new rule above the Block VLAN to VLAN (Rule index 2003)
Drag Firewall rules

Wrapping Up

VLANs allow you to secure your local network by making sure that devices from one VLAN can’t access the other. Because inter-VLAN access is by default allowed in UniFi, we will need to create quite an amount of rules before we can safely use it.

I hope this article helped you to set up UniFi Vlans. If you have any questions, just drop a comment below.

193 thoughts on “How to Setup and Secure UniFi VLAN”

  1. Hello Rudy, great article that I used to implement firewall rules on my VLANs.
    Your setup allowed me to understand that many devices, in particular Amazon’s ones (EchoDot/Flex…) are trying to access to gateways and are blocked by your rule “Block IoT to Gateways”.
    At the same time I had some issues with MSFT Teams web meeting and I related that to the “drop invalid state” rule. The rule was dropping the connection to MSFT servers generating issues and pausing it the problem disappeared. Do you have any insight for this? I see that the same rule is dropping also other connections to servers like Amazon.
    Thanks a lot

    • That is quite strange. Drop invalid state blocks incoming traffic that is not new, related or belongs to established flow. So it should not cause any issues and is something you should implement.

      I have the rules just like in the article, and haven’t had any issues with Teams.

  2. Thank you for the great walk-through guides! They’re really helpful.
    Do you have any experience of configuring AirPlay-devices through different VLANs?
    I’ve been trying to setup my AirPlay-devices in a guest-network.
    I’m aiming at securing my default network from temporary devices(e.g. friends visiting), but still making it possible for my friends to access my AirPlay-devices.
    So far I’ve only been able to see a speaker connected to other VLAN, but when connecting to it, it doesn’t play. Firewall port issue?
    Any tip is appreciated!

  3. Hi ,

    Trying to setup the firewall rules i do not see the local network under destination. The only option are app, app group, domain name , IP address, region

  4. Hello. Thx for this supernice guide. Im verry noob at this but I meet a problem. Im using home assistant. What WLAN is best for that? Separate VLAN or is it ok with IoT? Currently Im havin it on default but I cant controll anything from HA cuz of the rules. When I pause “Block Inter-VLAN” then it works. The real reason why I would like to avoid to move Home Assistant to IoT VLAN is cuz I have to change IP adress of HA and I think that will give me new problems :’)

  5. Hi Rudy,

    Great article! i think the clearest I have found around so far. I used parts of it to separate my camera vlan from the other internal devices in my home. I pulled the camera from the cable attached a laptop and indeed everything is blocked! next challenge now is when i reattach the camera, everything remains blocked so also the camera. I have searched for the port to reset. or to delete the block on the port, but so far no succes. Is there something there or do I need to reset the camera to fact def? It seems the port needs to be reset. Other angle would be to remove the rules and reapply them once everything is attached.

      • Hi Rudy,

        Tried all of that, no succes. Finally reset the camera to fact default, moved it to another port, applies default network. Wait for it to come online, updated. then applied vlan to the new port. Lastly after everything settled, unpaused the rules. Everything is fine, but still feels a bit strange as the camera device should be known to the switch (USW 8 port pro). or is it that the state of the port changed then it will accept no other connections? Tried many things, applied def netw to the port, power cycled the port. the only thing now that seeems to work is to use another port on the switch. but weird, but at least the rules work and the traffic is blocked when cable is removed.

  6. It seems that since you wrote this Ubuqiti has once again changed the screens. I can’t seem to find the Traffic Rules screen you have posted that exactly matches. Have my IoT network setup on my new Unifi Gateway Ultra with 8.1.113 installed.

      • Thanks. I like that they keep working on the software, and I was able to follow the detailed rules pictures thankfully, so all seems to be working now!

        Thanks as always for posting all the stuff you do. I’ve referred to your stuff many time over the years. Would love to see anything about how possibly to get AirPlay to work across these VLANS, etc. as well so I can quit having to join my IoT network from my phone to stream to the TV. LOL But I don’t trust LG (or any TV company for that matter) to be on my regular network!

  7. Hi.
    Great Article, thanks.

    Followed you Article on an Installation with Unifi Cameras.
    Created the VLANs and Rules exactly like in your Article.
    But as soon as I change the Native VLAN from the Default to my Camera VLAN DHCP stops working on that Port.
    Also my Camera VLAN WLAN cant give out DHCP Addresses.
    Any Idea why that happens?

  8. Good afternoon Rudy ,

    In your section Assign VLAN to Wireless Devices, you are explaining that
    If you have a UniFi doorbell, for example, you might also want to assign this device to the camera’s VLAN. The problem is that we can’t set a VLAN on the doorbell itself. The same problem occurs with a lot of IoT devices, on most, you can’t configure a VLAN ID.

    My question was why not just assign these devices to the IOT network ? That way the device would connect to the right VLAN no? For example if i set my doorbel to the Camera IP of, It would pulled an IP address from that therefore be assigned to VLAN 30. At least i think it would.

    • If you go to device in your UniFi network console, you can select the device > settings and then under IP Settings use the virtual network override option. This way you can assign a device to a specific virtual network.

  9. First off, I just want to show my appreciation and thank you for such a well written and comprehensive how-to article. I was confused about VLANs and using this article I was able to get everything setup. I followed ALL instructions and created the necessary VLAN and WiFi networks, and Traffice Rules when possible over Firewall rules. I did everything except for Step 3 “Block Access to Unifi Network Console from VLANs”. Has this issue with the traffic rule been resolved? If not, as with other commenters, I’m still confused why this is an issue. If an IoT device manages to get access to the default network gateway address of, I have a VERY strong password setup (24 characters long) and have 2FA setup, so rally what is the danger? My apologies but I’m still confused about this. Thanks !

    • There is indeed not a real danger from a IoT device. But in larger environments with guest networks for example, you just want to compeletly shield of the gateway. Security is all about adding layers, a strong password is one, seperating networks is another, and restricting access to a device is another.

      Compare with securing an warehouse. You have a good lock on the door, so they won’t be able to enter the warehouse. But by placing a fence around the warehouse, they won’t even be able to access that door, so they can’t even try to open the lock.

  10. Great article, thank you!

    I had a comment/question about the “Assign VLAN to Wireless Devices” section.

    You state:
    “So the only option is to create a separate SSID (wireless network) for each VLAN and assign the wireless network to the correct VLAN.”

    It looks like if you go to Clients > > Settings there is an option for “Virtual Network Override” which seems to allow you to assign a VLAN to the client. Would this not be a valid alternative to having to create a separate SSID for each VLAN?

    • Yes, virtual network override can be used as well. Is has only be available since the last couple of months, and it’s not working with every device or console.

  11. I’ve used this article recently to configure a small office, and it’s great. Thanks for the writeup! I have everything working smoothly, but one thing is still nagging me.

    Your first step is to create a Traffic Rule to prevent Cross-VLAN traffic, which I did, and it works perfectly.

    I have three VLAN’s – one secure, one for less-secure devices, and one Guest all on 3 different Networks, and 3 SSIDs. If I checked “network isolation” on Less-Secure and Guest hotspot, do I even need that traffic rule? Or would the secure VLAN still have cross traffic because you can’t check network isolation on your Default network?

    And then to add onto that, should I even bother checking Network Isolation on those two? Does that rule take care of that?

    • Network isolation isolates the clients from each other on the same network. So yes, you should enable it on the guest network atleast. Guest isolation alone should work as well, but with VLANs you can also set differenent access restrictions on the network, like bandwidth limiting.

      • I think it’s “Device Isolation” that isolates clients from each other on the same network, “Network Isolation” is for cross VLAN traffic:

        From Unifi: “Device Isolation blocks traffic between devices on the same Virtual Network (VLAN) whereas Network Isolation blocks IPv4 traffic between VLANs.”

        So i’m assuming your Traffic Rule (block cross VLAN traffic) makes checking Network Isolation redundant? Your rule works great, so i’m assuming it’s not necessary. But Unifi does recommend using Network Isolation (vs Traffic/Firewall) if you are also using a Unifi Switch in conjunction with a Gateway.

  12. Never Mind, I got it to working with my allow airplay rule, and correct port numbers. it sometimes takes some minutes for unifi to understand new firewall rules.

    • How did you do that?
      I’ve been trying to make a guest network with airplay-devices included. I want to be able to access them from my default/trusted network as well.

  13. Hello great instructions, but airplay is not working if I have my airplay devices on IOT network, is there any way to fix this, i also have mDNS on

  14. Excellent article, many thanks. See, I was afraid of locking myself out of my router but you explained it nicely and showed how to prevent that from the very first rules.

    I have a question around how to prevent anyone or anything self-assigning an IP in the default network. As the UDM resides on I have vacated this subnet as much as possible but also run pi-hole and couple other components. I have turned off DHCP and limited the subnet to a /28 but I have a few gaps in that range. How do I block those IP’s from being used, say if I manually set my IP on a laptop – how to stop it from communicating on the network? There is no MAC address filtering on a network, that only exists in WiFi. Would I need to implement 802.1x, use traffic or firewall rules to effectively null the IP’s in

    I hope I am explaining this correctly.

    Thank you for your time.

  15. Hi Rudy!
    Great guide. It brings a lot of new insights 🙂
    One thing though: I’m confused as to why (part of) step 3 is necessary. When you already block VLAN to VLAN communication, doesn’t that include the .1 addresses of the other VLANs? (The block access to the console is clear to me).
    If that’s true, you’d only need to block HTTP(S) and SSL access to the gateway of its own VLAN.

    Am I missing something here? Your solution seems (too) redundant.

  16. Great post, helped me a lote with my UDR. Any luck blocking Teleport VPN traffic from accesing the console admin or the main VLAN?

  17. Hi Rudy,

    Thanks for the very detailed HowTo’s, it helped me a lot improving overall security of my home network.

    May I ask you your help (more an explanation actually…) on how I can achieve the following:

    I kind of have the network layout setup according to you layout.

    My default network is and on the UDM-pro there are some more VLAN’s which are not relevant for my issue. I’ve setup a L2TP siste-to-site VPN server ( to let some remote Synology NAS systems “call home”.

    The clients are able to connect but it basically stops there. The remote clients are able to ping to the UDM-pro. The UDM-pro is also able to ping to the remote client and I can SSH into them, that part is fine.

    However, when I try to ping from my default network (a W11 client in the network) to the remote client (192.168.60.x) the requests will time out, the same happens in the other direction.

    Can you point me in the right direction on how to resolve this?

    Thanks in advance!

      • Hi Rudy,

        Meanwhile I discovered that L2TP has it’s limitions on pushing routes. To make life easier I switched to the built-in OpenVPN server which pushes most part of the routes to the clients. To add missing routes you need to make some changes in the .ovpn file you can download and add them in the client config file.

        Works like a charm now 🙂

        To use the downloaded client configs where a Synology NAS is the client you have to remove these 3 lines:

        # Downgrade privileges after initialization (non-Windows only)
        user nobody
        group nogroup

        For a little more safety, change this line:

        cipher AES-256-CBC


        cipher AES-256-GCM

        If you want a full tunnel add this in the client before the certificate part starts:

        redirect-gateway def1

        If you want split-tunneling don’t add that line.

        If you need additional routes which aren’t pushed by the OpenVPN server running on the UDM add one or more of these lines (adapt to your needs):

        route 192.168.x.0

  18. Hi Rudy,
    Thanks for writing the article it’s helped a lot, but…..
    I don’t have a UDM, my system is based on a USG 3P and a UCK G2 Plus with a few Unifi switches and AP’s.
    I’m trying to connect my neighbor to my Broadband connection (he hasn’t any) using a couple of Loco M5’s in Station/AP bridge modes – that was the easy part to set up…..
    If I just connect the Station M5 it to my network LAN, he can see all my devices and I can see his – not a good idea!

    So I’m trying to implement a separate VLAN to connect the M5 bridge to.

    I’ve followed your steps and have succeeded up to a point.

    If I isolate (tick the Isolation box) for his VLAN10 (192.168.10.xx) all works fine, except he can ping the USG at – but can’t login as he hasn’t the password.
    So that’s OK, but as I’m on the default VLAN1 (192.168.1.xx) I can’t access the M5’s to change any settings.

    So I need to implement your Step 3 – Block Access to Unifi Network Console from VLANs etc…..

    But you’ve lost me I’m afraid.

    Originally my Network OS was v7.xx but have upgraded to UniFi OS Version 3.2.10 which included Network OS v8.0.28. – quite an upgrade…
    I eventually found Traffic Rules in Security>Firewall Rules>Create Entry. but it’s not available, using the link just gives ‘UniFi is having trouble with this direction’

    So I need more help with doing it using Firewall Rules please.


      • Hi Ruby,
        Suddenly started getting updates from your LazyAdmin post – didn’t even realise my question had been posted, so thanks.
        I eventually sussed about the USG, so I’ve ordered a Ubiquiti Unifi Dream Machine (Special Edition) which should be with me soon.
        But I hoped you would explain more about ‘Step 3 – Block Access to Unifi Network Console from VLANs etc…..’
        Are your instructions for Step 3 not using Traffic Rules?
        If so, do I start your instructions in:
        ‘settings/profiles/port-ip-groups/form/new’ ?

  19. Brilliant articles on UDM. It’s beneficial and up-to-date!

    Thanks so much. The Traffic Rule block bug still exists for Gateways 🙂

  20. What would i need to block if i just want to block wifi on a different vlan from accessing the main network and access to the dream machine? Thx

  21. Traffic Rules are created in the LAN-IN chain and take precedence over the LAN-IN Firewall Rules. Blocking to the Gateway IP’s requires LAN-Local rules.

    I suspect this is done to prevent people locking themselves out of their controllers.

    • Between all clients or between specific clients? For the first you could use network isolation and for the second you will need to make sure that the clients have a fixed IP Address. Then you can make a traffic rule for it.

  22. I do not have access from my main vlan to devices in other vlans. I paused all rules.

    Does anybody know why that is so?


  23. Thank you for this tutorial and relatively up to date screenshots (Unifi keeps tweaking) to help me with my UDR.

    I followed everything you did and it works beautifully! Now when I went to allow my IoT network to my Plex sever hosted on Default I ran into issues.

    I tried the Firewall Rules and placed it at the top. Tried a few different iterations of this but none of them would work. I finally tried your Traffic Rules method pointed to an IP address of my server with the port and it finally worked.

    Action: Allow
    Category: IP Address
    IP Address:
    Device/Network: IoT
    Schedule: Always

    I used Traffic Rules to create the blocking of VLAN traffic. So I can only think that the Traffic Rules were not playing well with the Firewall Rules for allowing certain traffic through. Thought on what I did (outlined above) and thoughts of why it may not have worked with Firewall Rules?

    • We can see the firewall rules created by the traffic rules, so you can’t place your firewall rule above the rule created by the traffic rule. That’s why it’s probably not working.

      Your traffic rule looks fine.

  24. Hello, I used your settings for VLAN blocking. However, I need advice on one thing. I have 2 houses (different VLANs) with cameras in both. Let’s say house 1, where the NVR is located, has the IP, and house 2, where the other cameras are (connected wirelessly via AP), has the IP In house 2, VLAN is set on the port for cameras, but the NVR in house 1 cannot see the cameras. I’m interested in how to set up a rule or firewall so that the NVR can see those cameras.

    • Create a seperate VLAN for the cameras and NVR, and use that in both houses. Or alternatively, create a separate VLAN for the cameras in house 2, and use a traffic rule to allow access to and from that network to the NVR

  25. Rudy,

    Great article! I am new to UniFi equipment and have a question about your article. Is there a way to setup a secure/isolated network for port forwarding for hosting a game server? It looks like the guest network setup may work, but I want to make sure I have any additional steps needed. Thans for any help!
    Happy New Year and Best Regards,

  26. Will the traffic rules allow me to access my printer on IoT network? Right now I’m not able to an upon searching lots of people have the same issue with HP printers.

  27. Can I ask a vlan question regarding guest networks?

    Using the 8.0 unifi console I had originally created a vlan with the “isolation” option checked and then a wifi SSID as “open” with the “hotspot” option checked. This worked but required my “guests” to login to the hotspot portal to access the network. I decided I preferred an easier approach so that guests could scan a QR code to connect to the guest network.

    I left the vlan with the isolation option set but change the SSID to wpa2/wpa3 and unchecked the “hotspot” option. I then created a QR code for the SSID and all works fine. But, guests then had access to my main vlan.

    Lastly, I create a couple of firewall rules. 1 to drop traffic from guest->main and 1 to drop traffic from guest->iot. This seems to work in my testing but wanted to see if I am missing anything that would cause a security leak.

    Any thoughts?

  28. Thank you for the write up. It is really helpful.
    Unifi now tells me to user Traffic Rules instead of the firewall rules. They seem to be easy to setup. Do you think they are better and easier than the firewall setup?

  29. Hi, Rudy.
    On the part “Step 3 – Block Access to Unifi Network Console from VLANs”.
    Are there any easier ways of doing this with 10+ VLANs?
    I mean … Instead of two rules for each VLAN, could it be done with a more generic rule that allowed VLAN 1 to access the UDM, but everything else for everyone else is closed? Of course they would need DHCP-respons and stuff, but DNS shouldn’t be needed (I use Quad9 and so on), and definetily not https/http/ssh from any other VLAN than default.
    I am going to build a dormitory network with a UAP-AC-IW in each room, with it’s own VLAN on the WLAN and outgoing ports. Each room should only need itself and Internet. No need to reach anything else.
    It would be quite time consuming and possible forgotten if I need to rules for each VLAN created.

    • I haven’t found a solution yet. I though Traffic Rules would be a solution for this, but that doesn’t seem to work when it comes to blocking http(s) and ssh access to the gateway.

      • Thanks for the detailed write up.

        I was able to get the “block UDM gateway” as a Traffic Rule by specifying the IPs using CIDR notation like this:,80,443,80,443,80,443,80,443

      • I think this is a good case to change the default port for access to the gateway when an http(s) ui is enabled. It would seem to me that if you block traffic on common ports per IP (80,443) you may also block services running across that port, not just access to the console itself.

  30. In step: Assign Port Profiles to Switch Ports, it seems the Unifi menu options have changed. The Port Insights page has changed.
    Should we be changing the Ports Page’s Native VLAN/Network to “Cameras”per your example and have Tagged VLAN Management set as Allow All?

  31. Just wanted to share my thanks for this write-up, was easy to follow and helped me clean up a few of my newbie-mistakes in my home setup.

  32. I cant get Printer access to work. I have my Printer on VLAN 20 my IOT VLAN I set my IP to Im not able to ping this IP from default. I used your rule IOT to Raspberry changing it to default to I still can not ping my HP Printer. Any help is greatly appreciated. Ive noticed a lot of people have issue with printers.

  33. Hi, as far as I know I followed the tutorial to the letter. I have an issue with DHCP. For example my IOT network is defined to be in the range – 254 by the DHCP settings for that network. However, when I connecf a client (like a windows pc f.i.) it does NOT get an IP address assigned. My DHCP settings are :

    DHCP mode: DHCP Server
    DHCP Range: –
    DHCP default gateway : tries both as well as Auto

    What could possibly be wrong and what should I verify ?

    Big thanks !!!!

    • is the PC connected to an access port on a switch set to that same vlan? are the vlans from the unifi console trunked to the switch you are connecting it to?

  34. Great guide, thank you !

    Question … When a IOT device sits in a specific Wifi network, assigned a VLAN ID … I see it connects to the network without issues, however the IP address of that device does not show in the Unifi Client list interface ?

  35. Great guide , much appreciated .

    Can you pls expand your guide with the steps required to route VLAN traffic through the new UniFi magic VPN. I’ve 2 sites connected via Magic VPN with Cameras on each site but one NVR in a single site only. I want to use one VLAN for all the cameras and their NVR so would this be possible with the new UniFi magic VPN as it’s very easy to setup?

    I would imagine that would be policy routing approach and work around for traffic in 2 layers 2 and 3 (based on my limited understanding) , will this be possible? What are the steps to implement it?

    Thank you

  36. Hi,

    thanks for this nice guide. Finally a guide which describes all settings on the new unifi ui.

    Why is it necessary to add the Rule “Block IoT to Gateways”? Why should the IOT devices be blocked from reaching its DHCP or DNS Server?

    When I add the rule I’m not able to add new tuya devices.

  37. Ruud, thank you, this is an excellent article!

    I don’t quiet understand two things, only concerning the “Block traffic between VLANS”:
    – Allow established and related connections
    – Drop invalid state connections
    – Allow the main VLAN to access all VLANs
    – Block VLAN to VLAN

    1. For the first two rules you use as source “Any” and destination “Any”. For the fourth rule you use as source “All Private IPs” and destination “All Private IPs”. I get the logic for the fourth rule but don’t understand why the first two rules are “Any”. Wouldn’t it be enough to just use “All Private IPs” as well?

    2. I do technically understand what the second rule does “Drop invalid state connections” but I don’t understand why it’s used here? Is that just a best practice thing to do?

    The first question is for understanding but the second one is if particular interest to me as I see some traffic being dropped and not sure this is right, e.g. I have Apple devices in my network and they seem to want to contact Couldflare ( and and those connections are being dropped now as invalid.

    Appreciate any comments. Cheers!

    • 1. These rules also apply to connection to the internet
      2. The firewall not only blocks strange or messed-up packets but also rejects any packets that don’t belong to an ongoing conversation. Think of it like this: if you were getting a file, and the transfer finished, the connection would close. So, if the server sends more data after that, the firewall sees it as odd because there’s no active talk going on. To be safe, it’s smart to have these rules to stop any weird attempts from a compromised device.

  38. Perfect and simple example of vlan’s setting up. I doubt about iot and video restriction access to router, this case you can’t control smart homing and NVR remotely, but it can be tuned individually.
    What you can advice for such trlcky task: secondary wan link (ethernet) present near usw24 (not L2) switch, connection to UDM Pro via optic. There are free ethernet ports at usw24 and at udm-pro. Is it possible to build isolated trunk between ethernet ports to path trough this wan link to udm?

  39. hello,
    what about trunking? what would be the configuration for having all created vlans including the management vlan trunked out of the UDM on a single port, down range to other switches trunk ports to expand my network?


  40. After setting up VLANs and triple checking firewall rules, I have a couple of devices in my IoT network that can only be accessed remotely or from the IoT local wifi network. Shouldn’t I be able to access them from the default local wifi network, too? Feels like I missed something.

    Thanks for a great article…very helpful.

  41. First, thank you so much for the guide.

    I was wondering if you could explain a bit more on why you have LAN In for some, and LAN Local for others?

      • `LAN In` is from internet? Wouldn’t that be `WAN In`? Cause all the rules in this article are `LAN …` for blocking inter VLAN traffic — nothing about internet. I’m a bit confused?

        • The labels are indeed confusing:
          LAN-IN = traffic entering the LAN interface (usually sourced from clients on the LAN, but VPN traffic is also filtered here). Also traffic from the WAN interface to the LAN interface can be filtered here.
          LAN-OUT = traffic leaving the LAN interface (destined for the LAN clients)
          WAN-IN= traffic entering the WAN interface (usually sourced from anything on the internet)
          WAN-OUT= traffic leaving the WAN interface

          • I researched some more and I think I figured it out.

            Conceptually, `LAN Local` is the same as `LAN In` where `destination` is the UDM itself.

            But, if traffic comes in where `destination` is the UDM itself, the UDM does not trigger `LAN In` rules. Hence why those rules need `LAN Local`.

            Now I get it. Thank you!

  42. First, thanks for the article, it’s been very helpful!

    Correct me if I’m wrong, but I believe the “Block VLAN to VLAN” rule you created at or near the beginning makes blocking access to the group of gateway IP’s that are in your other VLAN’s unnecessary, as they should already be blocked, right? Thus, I think the only rule needed would be the one to block http,https,ssh to the gateway interface for said VLAN.

    • That is what I thought too but Unifi does not trigger the `LAN In` rules for traffic destined to the router itself. Thats why you need the other `LAN Local` rules.

  43. Hello, I wanted to ask. If port 443 and HTTP, and HTTPS are blocked, how do you connect to the unify web interface control window? Do I need to connect directly through the computer after downloading the unifi program?

      • Hi,

        I am a mac os user. I haven’t installed anything on my computer yet. That’s all it takes to install the controller on the computer and I’ll be able to connect? maybe you have written somewhere in your blog about creating firewall execption rules to connect to UDM?

    • 443 is only blocked from IoT. So devices on your main/default can still access the Unifi web interface control from your LAN.

  44. Hi,

    I am thinking of upgrading the home network to something more serious. I am choosing between meraki and unifi. Do you think unifi has a good enough firewall like cisco? and I wonder if cloud key2 can be connected to cisco meraki router.? if I would like to add wifi cameras.

    Thank you for you opinion

    • I prefer UniFi. It’s easier to set up and you don’t need monthly licenses to run and configure your hardware. The firewall of UniFi is good enough for a home or small business network. You can place the cloud key behind the Meraki router.

      • Hi, Rudy

        Thank you for your reply. I’m thinking about UDM/SE, although at the moment the internet provider only offers 1GB internet speed. Maybe in a few years there will be a higher speed. Investment in the future. I’m also thinking about acces point pro, it should probably be enough for an 88 sq m apartment.

  45. Hey Ruud,
    I wanted first to say that your article was very helpful and thank you! With that, I’ve found two oddities that perhaps you could provide insight into. First, when I run an external scan of my domain (strictly housed behind the UDMP running Network 7.4.150), I find that I have a ton of ports open. I’ve confirmed that I have UPnP off, so no ports are being opened for arbitrary services. I can’t figure out why they are open.

    The second is regarding securing IPv6. I’d like the same VLan structure in place, along with the firewall rules to match that coincide with the IPv4 rules and VLan’s. I currently have about 40-50 devices of various types and am trying to slowly transition to IPv6. Do you have any ideas on how to approach this, or any good references that could point me in the right direction?

  46. Oh wow, perfect article to guide a beginner like me. Many, many thanks. After setting up the groups to block port 22,80,443, I can no longer SSH to a machine on the blocked network. For now, I have excluded port 22 but would rather add a rule to allow SSH from the blocked VLAN to a specific machine on my main network. Any examples?

  47. Thank you for year great tutorial!
    I have tried to implement a similar setup using USG-PRO4 and UniFi Console 7.4.150, but did find that Switch port profile configuration under which you referred to as “new Ports Insights feature” was not available.
    There are some other differences as well.
    Do you know if I should be able to set up a similar solution without a UDM?
    If not would you be able able to point out what I need to configure different?
    Thank you in advance

  48. Great article Rudy – thankyou. I guess like many who found this article I was perplexed by the “problem” that inter-VLAN traffic is allowed by default, having set up VLANs which did “nothing”. This article has saved me hours. The rules Unifi creates with the same description are indeed “Internet In”, “Internet Local”, or “…v6…” rules and cannot be edited and the detail cannot be viewed, but I could take a reasonable guess at what they do. I read a post from Unifi that suggests they cannot be edited/viewed to “…enable the best user experience” – saving us from ourselves perhaps.
    UDM 7.3.83, U6-LR, u6-Lite, USW-Lite-8-poe.

  49. I followed this tutorial and everything seems to have worked – perhaps too well. I cannot access my HDHomerun Flex 4K tuners from a different VLAN. Everything I’ve read online seems to suggest a tricky situation working with HDHR devices and VLANs. Wondering if there’s a simple way for a non-IT weekend warrior like myself.

    What I hope to accomplish is to regain access from my Pixel 6 (VLAN 20) to several HDHR devices (VLAN 1). Is there a firewall rule to use? I’ve tinkered without success so far. Alternately, should I consider moving the HDHR devices to a separate VLAN? Might that clear things up? I have an unused MEDIA VLAN in my network list; no devices are assigned to it yet.

    Ideally, I’d like all mobile devices on VLAN 20 to have access, so if this involves a new profile/group then I’d like help with that as well.


  50. Would any of these rules stop internet in traffic? I set up the vlan for having a game server separated from the rest of my network but the port forwarding is still blocked after creating a rule. I can get OUT from the vlan but I can’t get in.

  51. Rudy,

    First off, I love this site as well as the simplicity of the information you presented on this topic. I was able to follow along on this tutorial and get firewall rules set up properly. Now my IOT network is isolated from all others on my UniFi Dream Machine Pro. Thank you! This tutorial was much easier to follow than the dozens of YouTube videos out there claiming to “make it easy”. I’m not an IT professional so all of this is sort of “weekend warrior IT” for me.

    A question I have on the HTTP, HTTPS and SSH group profile. I use ports 80 and 443 to renew SSL certificates every 90 days. I have port forwarding for 80 & 443 disabled until I need to use them. Should I expect that group profile to interfere with those certificate renewals? Is disabling the profile sufficient while renewing, or can I remove ports 80 and 443 from the profile?

    Thanks again!

  52. I think I got the tutorial right, but from the beginning my vlan doesn’t seem to assign an ip. I have just one pc plugged into a port on the switch that is set to use this vlan (called “gaming” in my case) but it gets no ip when then pc is plugged in.

  53. Hi all,
    thanks for useful post and comments!
    I have from Ubiquiti only a USW PRO 48 POE switch and the CloudKeyGen2Console.
    I have set the vlans (100,200,300) across the router and switch (only 1 router only 1 switch), but trying to get the printer on vlan 100 to be accessible from 200 and 300. how do I do that? tried different option but not successful so far and see in this post some functionalities are not available to me… thanks for any suggestion/feedback!

  54. Thanks for the guide, I’ve gotten to blocking the UDM interface and I don’t have the option in the red box. Am I missing something or did they update the interface?

  55. Ok, I followed this to the letter and verified 3 times that I made no mistakes but I can’t get any trafic between VLAN’s.
    I have a camera server on (Default network) that can’t a ping a Camera that had it’s ip set via DHCP on VLAN id 30
    I brought back this cam on Default LAN and I had no issue to ping it.
    Is there an easy way to see what firewall rules block this traffic ? (running 2.4.27)


  56. Drat, new UDM Pro, updated to version 2.4.27, a lot of this stuff looks different. I am at the step: “Next, we are going to add the firewall rules. This time we will be using the type LAN Local”, however, LAN Local is no longer an option.

    The Firewall & Security Type pulldown has: Internet In, Internet Out, Internet Local, and LAN in.

    Any idea which of those updated pulldown choices are equivalent to “LAN Local”?

  57. Ok im back and have sorted out my cable issue. I thought this was resolved because I could print from my phone. I was thinking ok things are talking. I have now realized that my phone was the only device that could print. I have the firewall rule established and related but that doesnt seem to work. I also can not ping the printer. I have it wired to a static IP.

  58. Hello Rudy,
    Thanks for the step by step tutorial on setting up the UDM PRO it is invaluable in understanding VLANs. It was hard finding information on how to setup VLANs on the UDM PRO until I came accross your article. However I have a consistent problem between three of these Dream Machines (UDM PRO). I followed your tutorial almost to a T on a out of the box new UDM PRO. When done with the configurations, I am not able to set the LAN ports on the UDM PRO to a specific defined network. The only option is “ALL” or “Disable” with “Default” and “Networks” grayed out under a port profile. There must be something basic in the setup that I am missing. Can you help?

    • Just to be sure, you can normally scroll down. Default and Networks are “headers” in the dropdown list (and indeed greyed out). So under Default, you will see All and Disable. And under Networks, you will find the network profiles that you have created (after you scrolled down).

    • Hello Rudy,

      I spent hours trying to setup VLANs with multiple Dream machines, unlike other pull downs in the dream machine settings the one for configuring switch ports on a specific VLAN this pull down has a hard to see side scroll. Not too straight forward in my opinion. Thanks for your help

  59. Good morning Ruud,
    Do I really need a UniFi Security Gateway or UniFi Dream Machine (UDM, UDM Pro) for creating different VLANs on my network?
    I hava a nighthawk R7000 router to which I attached a 16PoE lite and I have a 8 PoE lite connected to the 16 PoE switch.
    To the 16 Poe I connected 2 Unifi AP’s, Hue bridge and solar pannels.
    Doorbell, chromecast and google home mini are connected via wifi.
    To the 8PoE switch I connected 1 unifi AP and a desktop.
    Kind regards

    • Well, it makes it a lot easier. You can also create the VLANs on your router, and then create the appropriate wireless networks in the UniFi Controller. That should also work.

  60. hello rudy
    thanks so much for this tutorial, finally beginning to understand things a little bit.
    followed everything step by step including firewall rules and so on
    everything works perfectly as far as i can see from within the wired network.
    the main vlan has access to all other vlans and all other vlans cannot reach the main lan and each other. so far so good.
    however only from the wifi assigned to the main lan i cannot access the other vlans , which should be possible ( allow main network to all vlans — source main network destination all local ip adresses )
    deleted the wifi networks reinstalled them , checked the groups on faults etc etc .
    this drives me a little bit crazy it is probably something small but i have no idea whatsoever
    may be you or somebody out there can give me a hint in the correct direction
    dank je wel

  61. Do you have any write ups on creating a mgmt VLAN for access points? I don’t want my APs to use the default VLAN since we already have an AP mgmt VLAN in place. Applies to the unifi controller software on a server.

    Thank you

  62. Hi, thanks for this great tutorial !

    Just one thing .. when creating the networks, I have the option to select the “Network Group” … (assigned to a specific port on f.i. my USG) .. I select LAN2 Here ? (This is the 3rd port besides WAN and LAN1)

    Thank You !!!!

  63. Hi,
    Excellent write up. Thanks.
    I’ve got just one question. In my main vlan (default) i have a machine which runs an application (on for example port 4333). How can i configure devices from the IoT vlan to connect the machine in the main vlan (default) by only this port?

    I red you’re exceptions and tried a port group with port 4333 to the particular machine’s IP). But wasn’t succesful.

    Any help?

    • Exceptions can sometimes be a bit of a trial and error. Make sure that you order the rules correctly. And you can try to allow access first based on IP and if that works narrow it down to specific port only.

  64. i have an UDM and have aproblem with wifi and wlan. i created a network (IOT-Devices) and enabled DHCP servicer in this network. as well i assigned a new SSID in wifi and added this to the network. I can connect with a client to this network but i won’t get an DHCP Ip address to my device.
    is there an additional setting to get DHCP to work

      • I also have this problem. No matter if I create a Guest network or a IoT network i cant get a ip from the dhcp in that network. Have anyone found a solution for this?

          • Just did a quick test here, and seems to work fine. But I see that I haven’t mentioned the DHCP server settings in the article. Can you please check the following:

            – Open Settings > Networks
            – Select the IoT network
            – Scroll down to Advanced Configuration
            – Check if DHCP mode is set to DHCP Server
            – And the DHCP Rnage is in the same subnet as the IoT network is 192.168.40.x – for example.

          • Confirmed that DHCP Server is there along with the subnet range it needs to be in.

            To me it almost seems like firewall is blocking it. Do we need to let the DHCP server traffic through on UDP ports 67, 68? I would think that each network would handle its own DHCP but that doesn’t seem to be the case.

            Getting no router IP and 169 address when connecting (hangs trying to connect on devices essentially)

          • So it’s a UDM connected to a switch and then I have a few devices connected to that including a couple UI wifi 6 aps.

            I think my issue might be the switch actually and it not handling vlan traffic. It’s a Ruckus switch and therefore I don’t think it understands the vlan traffic tagged.

  65. Hello, great tutorial however, when I enable Block Vlan to Vlan it cuts off all network traffic. I can’t find what I’m doing wrong? All network traffic being my AP and direct wire.

  66. I have 5 VLANS,

    (Default), Main, IOT, NOT, HA.
    In the Default/untagged, i have the UDR, USW, and want to set the G4 Doorbell in. (so only unifi devices)
    Is it a good idea to put the Doorbell into the Default LAN? And block the access of the camera to the other VLANS?

      • I have cameras that are blocked from accessing the internet if I use those rules. I’m not an expert but I believe it needs guest type access without the login screen

  67. Duidelijk! nee, dat heeft de niet. Wel een handig gast-netwerk. Dat werkt goed. Maar ik wil ook een game-pc op een aparte VLAN zetten. Dus moet ik wat gaan aanpassen.

  68. Andere vraag: ik heb een fritz!box met 4 LAN-poorten. 1 LAN-poort is verbonden aan de Unifi Switch. Kan ik alleen VLAN’s inregelen voor apparaten achter de switch of ook voor de switch?
    Ik wil voor het hele huis een aantal VLAN’s inregelen. Maar ik denk dat ik dan de Switch direct achter de fritz!box moeten plaatsen en vandaar uit VLAN’s creëren?

  69. hoi, ik loop vast in dit scherm met IP Group aanmaken.
    Als ik in type bij adress: IPv4 Adresses/Subnet krijg ik een foutmelding. Vraagt om een geldig IP of Subnet adress.
    Wat doe ik verkeerd?

  70. Excellent tutorial Ruud. I’ve followed the steps and everything is working great. I need to create a new firewall and I could use your help. I use a Synology NAS with two NIC’s. Each Synology LAN has a static ip address with one on the main LAN and the other on the IoT LAN. Unfortunately 3 VLAN’s don’t go into the two Synology LAN’s so my camera network can’t access Surveillance Station on the NAS.

    Can you tell me how to create a new firewall rule in UniFi that will allow the camera VLAN 30 to access the Synology NAS using the IoT VLAN of 40? The NAS ip address on the IoT VLAN is

  71. How does this still stands when enabling IPv6, and all devices get a public and local IPv6?

    Also using Port 433 in firewall rules is no more allowed as of the latest beta Netwerk Application version.

  72. Thanks Rudi for this useful guide. My current setup is ERX with Unifi AP’s – partially setup with help from your previous articles. I am using VLANS for guests, iot and ’trusted devices’ similar to your descriptions here.

    I now plan to change my ERX to the Unify Dream Machine and one Unify switch.
    Before I do that, I just wanted to double check if can assign the Port Profiles on ports on the Dream Machine as well? Or can this only be done with ports on the switch?

    I am asking because the Dream Machine is a router rather than a switch. Or is it both?

  73. Hello

    First I want to thank you for the excellent explanation!

    But I still have a question. I don’t understand why it’s necessary to do “Step 3 – Block Access to Unifi Network Console from VLANs” when we already have blocked the access from VLAN to VLAN with a firewall rule.
    Can you explain it a bit more to me please?

    And what is the order in which the firewall rules must be put?
    Is it like this:
    1 Allow established/related sessions
    2 Allow main VLAN access to all VLAN
    3 Drop invalid state (what does it do?)
    4 Block VLAN to VLAN
    5 Block IoT to Gateways (why are you not making such a profile for the Guest VLAN?)
    6 Block IoT Gateway Interface (why are you not making such a profile for the Guest VLAN?)
    7 Block Cameras to Gateways
    8 Block Cameras Gateway Interface

    Last question, why do you use drop and not reject?

    Thanks a lot!

    • I agree. An excellent explanation. Good for people new to Ubiquiti and firewall rules. And I have the same question: if we have already blocked VLAN to VLAN access, why do we block access to the Unifi console from VLANs? And also, if we have already blocked VLAN to VLAN access, why block access to other VLAN gateways?


      • Cancel my second question as I see that we are blocking those ports for the VLAN’s own gateway. But I still have the same question as Tom regarding blocking access to other gateways when we have already blocked VLAN to VLAN access.


  74. amazing step-by-step tutorial. thank you for taking the time to document and share it.
    I can’t wait to use it to setup my new unifi network

  75. Nice article, thanks. I ran into an issue where my G3 Flex camera was shown as offline as soon as I set the relevant port on my switch to the newly created Cameras profile. This reverted after setting it to ‘All’ again. Any thoughts on this? This switch is connected to another switch first before being connected to a router, could that influence things?

  76. Hello,

    I just updated my network to Unifi. I followed all of your instructions on this post. I can no longer control my IoT devices using the Google home app. Are these firewall rules restricting that?

  77. Im trying to set up a HP printer on my IoT network. None of my devices seem to be able to see it. Is there something special you would recommend for set up. my rules pretty much mirror yours in this article.

    • First, check if the printer is genuinely in the IoT network. You can do this by checking the IP Address of the printer (most printers can print out the configuration by using the buttons if you don’t have a display on the printer)

      Then can you ping or access the printer from a device in the IoT network?

      • Yes it’s on my IOT network I verified thru UniFi interface an on printer. I can ping from my main network. I’ve read HP is tricky when put on a different VLan

    • Use the method from Step 3 but instead Type LAN local use internet out. That should block all the traffic from the selected port group to the internet. (Haven’t tested it)

  78. Hello,
    I used the following rule to block vlan to other lan’s:

    Drop All IoT from Local
    > After and Drop
    > Network > IoT

    > Port group > All Local IP (here all my local IP addresses including all VLANS and the Untagged LAN.

    Is this also correct?

    Than I changed your rule “Block IoT to Gateways” to at once block all VLAN Gateways (i have 5) to http(s) and ssh:

    Block All VLANs to Base Console
    > After – Drop
    > Group > All VLANs

    > Group > Gateways
    > Ports > http(s), ssh.

    To be able to connect to the main gateway i used the following:

    Allow Trusted VLANs to Base Console
    > Accept – Before
    > All Trusted VLANs (main and untagged)

    > Group > Gateway console (
    > Ports > http(s), ssh.

    Does this the same but in 2 rules for all vlans instead of 1 for every vlan?


  79. If I want to use a separate management VLAN (will be the default VLAN 1) then, when creating the firewall rules, do I have to use the managment VLAN to allow traffic to other VLAN’s?
    All other devices will be other VLAN’s.

  80. Yip, thanks did indeed forget to change the new rule into “LAN in”.

    Is it not sufficient to only block the Gateway ports of the subnet because there is already a rule “Block VLAN to VLAN” in place to prevents access to other VLAN’s (including their Gateway I hope)?

    • The block inter-VLAN rules are also to prevent broadcast requests between the VLANs for example. These can also happen on the switch level, without routing to the gateway first.

  81. I just have my UDM and to be honest I am just a NOOB/Novice. So your article is very helpful. I noticed that some of the Firewall rules are now already predefined (version Network 7.1.66). Is there still a reason to add them anyway (like because predefined firewalls are not brows able so you can not see the exact settings?)

    • If the exact rule already exists then there is no need to add them again. But make sure that you check if they are also located under LAN In, for example.

Leave a Comment