DD-WRT:Reconfigure VLANs for 802.1q Compatibility

Introduction
VLAN trunking allows you to connect VLAN's across multiple devices without having to use a cable for each VLAN. For instance, if you had VLAN 1 and VLAN 3 on two different devices then you can create a trunk port on both devices to tag the Ethernet frames with an 802.1q header. Then devices in VLAN 1 on router 1 can communicate with devices in VLAN 1 on router 2 and devices in VLAN 3 on router 1 can communicate with devices in VLAN 3 on router 2.

Broadcom's 100mbit switches use VLAN 0 as the default LAN VLAN but 802.1q specifies that a tag of "0" means that the frame doesn't belong to any VLAN. ie. the sending device is using the 802.1q header to indicate a priority for QoS but does not know which VLAN it belongs to and the switch should put it in the default VLAN for that port. This is the reason Broadcom's gigabit switches use VLAN 1 for their LAN and you should avoid using VLAN 0 in a 802.1q trunk to be compatible with others devices. This guide will explain how to reconfigure a device with a Broadcom 100mbit switch to use VLAN 1 for the LAN ports and VLAN 2 for the WAN port to lay the foundation for further configuration of 802.1q tagged ports.

Reassign the WAN Port
Note: If you have a BCM4704 based device which have a separate internal interface for the WAN port (eth1 instead of vlan1) then you can skip this section.


 * 1) Open the Web Interface in a web browser.
 * 2) Navigate to the Setup -> VLAN page and move the WAN port (W) to VLAN 2. [[Image:Reconfigure VLANs 1.png]]
 * 3) Press the Apply button and wait one minute before continuing.
 * 4) Navigate to the Setup -> Networking page and change the WAN Port Assignment from 'vlan1' to 'vlan2'. If there is no 'vlan2' in the list then reboot the router and try again.
 * 5) Press the Apply button.

Reassign the LAN Ports

 * 1) Navigate to the Setup -> VLAN page and move each of the LAN ports (1-4) from VLAN 0 to VLAN 1.
 * 2) Change the Assigned To Bridge setting for VLAN 0 to 'none' to remove it from the LAN bridge (br0).
 * 3) Change the Assigned To Bridge setting for VLAN 1 to 'LAN' to add it to the LAN bridge (br0). [[Image:Reconfigure VLANs 2.png]]
 * 4) Press the Apply button and wait one minute before continuing.
 * 5) Navigate to the Setup -> Networking page and verify that the vlan1 interface is assigned to the br0 bridge. [[Image:Reconfigure VLANs 3.png]]

Finishing Up
Before you go running off thinking that your configuration is fine, reboot the router to ensure that the settings all persist through a reboot. The DD-WRT firmware has some 'sanity checks' to restore VLAN settings to their default values when they are configured certain ways.

In my experience, DD-WRT will revert the WAN Port Assignment on some hardware. I've worked around this problem by navigating to the Administration -> Commands page and saving the script below to the Startup Script.

nvram set wan_ifname=vlan2 startservice wan