When defining a VLAN, what is the difference between fields vlan & vid?

https://openwrt.org/docs/guide-user/network/vlan/switch_configuration says that vid is the "vlan ID" but does not mention a field called vlan.

config switch_vlan
option device 'switch0'
option ports '6t 3'
option vlan '5'
option vid '5'

1 Like

vlan is an index into the chip's VLAN configuration table. Older chips only accept numbers less than 128 or 16 here. vid is the tag number from 1-4094 that goes out on the wire. If you don't specify vid, the same number as vlan is used. If you need tag numbers higher than the chip's table size you have to use both with different numbers, e.g. option vlan 3 option vid 803.

This isn't an issue on newer gigabit chips which have a 4096 entry table. On those you can specify any vlan and not need to explicitly set vid. The command swconfig dev switch0 help will show the table size.


A maybe related question: I have defined them vlans from the command line, but they seem to appear unsorted in the gui. What do I need to do to get them to show sorted in the gui?

Rearrange them in /etc/config/network

I am defining them from the command line using uci, and can't manually edit the /etc/config/network file.

Realize that all that uci set does is add or modify lines in an /etc/config file.

1 Like