I’m have a FRITZ!Box 4040 with OpenWRT. I like to have the following Solution
WAN Input, here I have VLAN 1, 5, 10 and 100 coming from a UniFi switch
LAN 1 VLAN 1
LAN 2 VLAN 5
LAN 3 VLAN 10 (no need but I thing I have to have this better if it is VLAN 5)
LAN 4 VLAN 100 (no need but I thing I have to have this better if it is VLAN 5)
The ipq4018 chip has some strange operation with VLANs. It is recommended not to use vlan tag numbers 1 or 2 for external purposes.
Create a network bridge for each VLAN. Rather than lan2 etc it makes sense to name them vlanX to keep the relation clear.
In the switch, create vlans with the numbers you want and make them tagged on both the CPU port eth0 and the port that will carry the trunk cable to the main router.
In the each bridge, set physical setting to eth0.X with X being its vlan number.
The wifi APs are attached to the bridges via the wifi configuration (do not explicitly attach wifi to a network in the physical settings). Everything is untagged at this point, since there is no provision for VLAN tagging over wifi.