[SOLVED] How to use UCI to configure VLANs on a large installation?

Yes, you can configure the VLANs in /etc/config/network

I recently updated the wiki which should be accessible once the DNS issues are resolved. Search on "/etc/config/network"

In short, the switch configuration can be done in /etc/config/network, as is the bridging of interfaces.

Hardware switch configuration is limited by the number of distinct VLANs that the switch and driver support. As an example from an Archer C7:

jeff@office:~$ swconfig dev switch0 help
switch0: ag71xx-mdio.0(Atheros AR8327), ports: 7 (cpu @ 0), vlans: 128
     --switch
	Attribute 1 (int): enable_vlan (Enable VLAN mode)
[...]

VLAN tags outside of that range (0-127 in the Archer C7 case) need vid on the switch and pvid on the port configured. I think of the vlan config parameter as a "table entry" that happens to default vid and pvid to its value.

As an example:

config switch_vlan
        option device 'switch0'
        option vlan '3'
        option vid '1000'
        option ports '6t 1t 2 3 4 5'
# LAN 4
config switch_port
        option device 'switch0'
        option port '5'
        option pvid '3'
        option enable_eee '1'
1 Like