A managed switch and an OpenWrt router can separate your trusted LAN from cameras, guest devices and the switch management page. Both need to support the same 802.1Q plan, and the router's firewall needs to control which routed traffic can cross between the networks. Assigning VLAN IDs is only part of that setup.

We'll work through an illustrative four-network layout. Before entering commands, check your switch's manual and your OpenWrt device's actual port names, including whether it uses DSA or the older swconfig model. If possible, keep a local console or a known-good management port available while you work: a tagging mistake on your administration port can leave you locked out just when you need to fix it.

1. VLANs, tags and PVIDs

An 802.1Q VLAN separates Layer 2 broadcast domains. A frame sent within the IoT VLAN will not be delivered to the trusted VLAN by the switch merely because both are on the same chassis. The tag identifies the VLAN on a link that carries tagged traffic. An access port usually sends untagged frames to an endpoint; the switch's PVID assigns incoming untagged frames to its VLAN. A trunk link carries the tags needed for multiple VLANs between the switch and router.

This does not prevent routed traffic by itself. Each VLAN has an IP subnet and a gateway interface on OpenWrt. When a camera in VLAN 20 tries to reach a NAS in VLAN 10, the packet has to be routed. That is where the firewall rule matters. Devices within the same VLAN are still peers unless you add a separate isolation mechanism on the switch or Wi-Fi access point.

2. Choose hardware from its actual feature list

The switch needs configurable 802.1Q tagged and untagged membership plus PVIDs. A product advertised merely as “smart” might expose some VLAN feature without the port controls you need. Confirm the exact hardware revision and current manual before buying; price and interfaces change. A five-port switch also fills quickly: one router uplink, one trusted device, one IoT device, one guest device and one management connection consume all five ports in this example.

Look for a router that can carry the VLANs over its switch-facing port and run a firewall zone for each routed network. The names you'll configure depend on the device. On current DSA targets, OpenWrt exposes switch ports as devices such as lan1 and commonly uses bridge VLAN filtering with logical devices such as br-lan.10; a device with a separate Ethernet interface may use a VLAN device named like eth0.10, while older hardware can still use swconfig. Treat these as example names as you check Network → Interfaces → Devices against your device's OpenWrt documentation, then use the names that actually belong to your router.

For Wi-Fi clients, check whether your access point can bind an SSID to a VLAN and whether its uplink carries that tag. A guest SSID on the router may be easier if a separate AP lacks VLAN support. An untagged AP uplink can belong to one access-port VLAN. Carrying different SSIDs in different VLANs over one uplink requires the AP to apply the matching tags.

3. Draw the addressing and port map first

Here is one possible plan, using private IPv4 example subnets:

VLAN Purpose Subnet Intended traffic
10 Trusted 192.168.10.0/24 PCs and NAS; internet; selected IoT administration
20 IoT 192.168.20.0/24 Internet and router DNS/DHCP; no trusted subnet
30 Guest 192.168.30.0/24 Internet and router DNS/DHCP; no local subnets
99 Management 192.168.99.0/24 Router and switch administration from approved devices

You can choose different IDs and addresses; what matters is keeping membership consistent across the router port, switch uplink, access ports and any AP uplink. Before changing those ports, save the current router and switch configurations and record which physical port you'll use for recovery. Work out whether management will use a separate wired port or an explicitly allowed path from a trusted host, and prove that path works before moving your only administration connection to VLAN 99.

If four networks stretch the hardware or the time you have, start with Trusted and IoT. That gives you a smaller setup to configure and verify, including its firewall policy, before you take on guests and management.

4. Configure the OpenWrt side

On a DSA router, identify the switch-facing port and open Network → Interfaces → Devices, configure the bridge containing it, and select Bridge VLAN filtering. Create VLAN 10, 20, 30 and 99 as needed. Set the switch-facing port to carry the chosen VLANs tagged. Keep a documented untagged or management path while migrating if your topology requires one. Then create interfaces on the resulting VLAN devices, for example br-lan.10 and br-lan.20, and assign the planned gateway addresses. On a router with a dedicated Ethernet trunk, the corresponding devices may look like eth0.10 and eth0.20. Do not paste that syntax onto a DSA device merely because a tutorial says so.

Enable DHCP on each client VLAN for which the router should issue leases. Give the management VLAN a deliberate address plan too; static switch management is reasonable, but first confirm the administrative host can reach it. Check each interface's actual device, IP and DHCP scope before saving. OpenWrt's Save & Apply rollback helps with a lost management connection, but a local recovery method is still worth having.

Create separate firewall zones for Trusted, IoT, Guest and Management. Give the client zones forwarding to WAN only where intended. Do not add IoT→Trusted or Guest→Trusted forwarding. Allow Trusted→IoT only for specific services that a device actually needs, preferably with a narrow traffic rule rather than blanket access. Check IPv6 as well as IPv4 if your WAN and VLANs use it; an IPv4-only deny plan is incomplete when IPv6 routing is active.

When you set up those rules, keep the two traffic paths in view. Zone Input governs traffic from a client to the router itself, so setting IoT or Guest input to REJECT means adding and testing explicit exceptions for needed router services, particularly DHCP and DNS. Zone Forward and inter-zone forwarding govern traffic through the router. Keeping that distinction clear lets you restrict access between networks without accidentally stopping clients from getting an address. Router administration needs its own restrictions too: guest access to DNS should not leave LuCI or SSH reachable.

5. Configure the managed switch

Enable 802.1Q mode and create the same VLAN IDs in the switch interface. For an example five-port layout, assign port 5 as the router uplink, tagged in each VLAN carried over that link. Assign ports 1, 2, 3 and 4 as untagged members of Trusted, IoT, Guest and Management respectively. On each access port, set the PVID to that same VLAN: 10, 20, 30 or 99. The PVID controls where incoming untagged traffic goes; membership controls which VLAN's traffic leaves that port.

Choose the trunk's PVID with your management path in mind, including whether you deliberately carry an untagged management or native VLAN on that link. If every intended network is tagged, avoid relying on untagged traffic there and document how the switch handles frames without a tag; leaving PVID 1 at its default does not establish a firewall policy. As you make the change, keep the switch's management IP and access path available, then follow its manual to save the configuration to persistent storage.

Some switches also offer port isolation, which can prevent two ports in one VLAN from reaching each other. That is a different feature from 802.1Q and not universal. If you enable it for IoT devices, test services that need local peer discovery; the isolated device may no longer see another device on the same VLAN. On Wi-Fi, client isolation is configured at the access point rather than at a wired switch port.

6. Test the policy, not only the labels

Move one test client at a time. Check its address, subnet mask, gateway and DNS server. A device on the IoT port should receive an address in 192.168.20.0/24; one on the Trusted port should receive an address in 192.168.10.0/24. If the address is wrong, inspect the access port's untagged membership and PVID, the uplink tag and the matching OpenWrt interface and DHCP scope.

From IoT, test a public destination and the router's DNS service, then test a specific trusted host that should be denied. Do not use a ping to 192.168.10.1 as the sole isolation test: that is a router interface, so its result depends on router input rules, not only inter-zone forwarding. From Trusted, test the specific IoT service you intentionally allowed, if any. A failed ping to a host that blocks ICMP proves little; test the service port or a controlled host you know responds.

On the OpenWrt side, tcpdump -eni <trunk-device> vlan can help confirm tagged frames on a physical trunk when the installed tools and driver expose them. Use the actual device name. If traffic never reaches the router, check switch membership and PVID before debugging firewall rules. If it reaches the router but cannot resolve names or get a lease, check zone input and DHCP/DNS rules. If it resolves and reaches the internet but also reaches Trusted, check zone forwarding and narrow exceptions. Reboot the switch and router after saving, then repeat a short address and isolation test so you know settings persisted.

Once the first VLAN behaves as intended, you have a setup you can expand one network at a time, keeping the recovery path available as you go. The switch handles tagging while OpenWrt routes traffic and enforces the policy, so use those separate jobs to guide your checks when you add guests and management.