VLANs on OpenWrt are not just a matter of adding .106 to an interface name. First identify whether the device uses a legacy hardware switch, driver-created VLANs, or DSA; since the OpenWrt 21.02 transition, the syntax and port mapping can differ substantially. This guide keeps all three paths from the official documentation.1
Warning: A wrong tagged/untagged state or CPU port can remove the entire LAN. Back up the configuration and keep a console path before editing
/etc/config/network. Never copy a port map from another model.1
VLAN, tagged, untagged, and off
OpenWrt supports IEEE 802.1Q and IEEE 802.1ad (QinQ). In the common router example, the internal switch uses VLAN 1 for LAN and VLAN 2 for WAN; the CPU receives both as tagged data while end-device ports are usually untagged. Tagged ports normally form trunks between switches or routers, while untagged ports normally connect end devices.1
- Tagged on the CPU port means frames carry a VLAN tag to the CPU; the peer must understand VLANs.
- Untagged accepts untagged frames and removes the tag when sending them out; one untagged port has one VLAN ID and can use a PVID.
- Off means that VLAN does not reach the port.
- Traffic crossing the LAN/WAN boundary must pass through the CPU/firewall when the VLANs do not share external ports; a switch can also be configured to bypass the CPU.1
Identify the hardware and driver
Read the model's hardware page first. On the router, inspect interfaces with:
| |
A second source example for a device with one physical interface and switch-created VLANs is:
| |
A single physical interface accompanied by eth0.1 and eth0.2 may indicate a VLAN-capable switch or driver VLANs. DSA exposes switch ports as independent interfaces; not every device migrated from swconfig to DSA. Because migration changes the configuration syntax, applying an old example to a DSA device can leave the network down.1
Path 1: legacy swconfig hardware switch
This is the source's example for a system not using DSA. switch stores common properties, switch_vlan assigns VLANs to the switch device, and switch_port sets a PVID. A port with the t suffix is tagged; the example's CPU port is 5.
| |
In this example an untagged frame entering port 0 is assigned VLAN 1, leaves port 1 untagged, leaves port 3 and the CPU tagged, and appears to Linux as eth0.1. VLAN 2 traffic entering port 2 goes to port 4 and the CPU tagged and appears as eth0.2. An untagged port cannot carry several VLAN IDs at the same time.1
Path 2: driver-level VLANs
On a device with one NIC, such as a CPE, a VLAN can be described with a parent interface and VLAN ID. The source allows explicit config device sections using type '8021q', ifname, vid, and name; type can be 8021q or 8021ad, while name, ifname, and vid are required.
Explicit VLAN 106 and 204 configuration:
| |
The equivalent shorthand lets netifd infer the parent and VID from dot notation:
| |
If a tagged frame arrives on eth1 without a corresponding VLAN interface, it may be dropped; untagged frames arrive on the parent interface as usual. When a VLAN interface is bridged with a non-VLAN interface, the kernel adds and removes tags at that boundary. This is separate from hardware-switch configuration.1
Path 3: DSA on a one-port device
The following is the source's full working example. It creates br-lan, places VLAN 1 untagged on lan, places VLANs 2 and 3 tagged, and assigns iot to br-lan.2 and guest to br-lan.3. For WLAN to work, wireless networks must bridge to the correct iot or guest interface.
| |
Inspect the bridge and VLANs after reloading:
| |
If the supporting package is installed, inspect the VLAN table with:
| |
If bridge v is unavailable, the source notes that ip-full may be required. The DSA example also assumes another device provides DHCP for untagged LAN and tagged VLANs 2 and 3 on the same link; do not enable extra DHCP servers until the topology is understood.1
Final checks
After every change, compare the physical port, VLAN ID, tag state, parent interface, bridge, and firewall zone. Test each segment with a wired client and an SSID, confirm the expected DHCP lease, and confirm that forbidden segments are not reachable. If the result is wrong, restore the backed-up /etc/config/network through the console; do not apply a complete file from another model.1


Góp Ý / Bình Luận / Đánh giá