Since there’s some doubt on whether the configurations I tried were sane, here goes:
This is just for demonstrative purposes (and posterity in case someone owning the same device – a TP-Link Archer C2 AC750 V1 – would find this useful):
Default “factory” configuration (redacted a bit for brevity):
config device
option name 'br-lan'
option type 'bridge'
list ports 'eth0.1'
config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
config device
option name 'eth0.2'
option macaddr 'xx:xx:xx:xx:xx:xx'
config interface 'wan'
option device 'eth0.2'
option proto 'dhcp'
config interface 'wan6'
option device 'eth0.2'
option proto 'dhcpv6'
config switch
option name 'switch1'
option reset '1'
option enable_vlan '1'
config switch_vlan
option device 'switch1'
option vlan '1'
option ports '1 2 3 4 6t'
config switch_vlan
option device 'switch1'
option vlan '2'
option ports '0 6t'
The above works as expected: eth0.2
(the wan
device) gets an IP address via DHCP from the WAN port (port 0), which is connected to “the Internet” through an upstream managed switch.
Altered configuration #1 (showing only the relevant sections from now on):
config device
option name 'eth0.31'
option macaddr 'xx:xx:xx:xx:xx:xx'
config interface 'wan'
option device 'eth0.31'
option proto 'dhcp'
config interface 'wan6'
option device 'eth0.31'
option proto 'dhcpv6'
config switch
option name 'switch1'
option reset '1'
option enable_vlan '1'
config switch_vlan
option device 'switch1'
option vlan '31'
option ports '0 6t'
The above works as well. eth0.31
(which is now the wan
device) gets an IP address via DHCP from the WAN port (port 0). In fact, the option vlan
indices 1 – 31 all seem to be usable.
Altered configuration #2:
config device
option name 'eth0.32'
option macaddr 'xx:xx:xx:xx:xx:xx'
config interface 'wan'
option device 'eth0.32'
option proto 'dhcp'
config interface 'wan6'
option device 'eth0.32'
option proto 'dhcpv6'
config switch
option name 'switch1'
option reset '1'
option enable_vlan '1'
config switch_vlan
option device 'switch1'
option vlan '32'
option ports '0 6t'
The above no longer works. eth0.32
does not get an IP address and swconfig dev switch1 show
only displays VLAN 1 as configured. In fact, option vlan
indices above 31 all seem to be unusable.
Altered configuration #3 (adding option enable_vlan4k '1'
to the switch1
configuration):
config device
option name 'eth0.32'
option macaddr 'xx:xx:xx:xx:xx:xx'
config interface 'wan'
option device 'eth0.32'
option proto 'dhcp'
config interface 'wan6'
option device 'eth0.32'
option proto 'dhcpv6'
config switch
option name 'switch1'
option reset '1'
option enable_vlan '1'
option enable_vlan4k '1'
config switch_vlan
option device 'switch1'
option vlan '32'
option ports '0 6t'
Now the VLAN 32 works. I can freely use option vlan
indices above 31 (and therefore also get the VLANs use the corresponding 802.1Q VLAN IDs by default.)
Altered configuration #4 (making the WAN port a member of 802.1Q VLAN 500 in tagged mode):
config device
option name 'eth0.500'
option macaddr 'xx:xx:xx:xx:xx:xx'
config interface 'wan'
option device 'eth0.500'
option proto 'dhcp'
config interface 'wan6'
option device 'eth0.500'
option proto 'dhcpv6'
config switch
option name 'switch1'
option reset '1'
option enable_vlan '1'
option enable_vlan4k '1'
config switch_vlan
option device 'switch1'
option vlan '500'
option ports '0t 6t'
Note the 0t
above. The upstream switch port has been configured in trunk mode with “the Internet” being provided via a tagged 802.1Q VLAN 500 (I commonly connect switches and routers in trunk mode with several VLANs carried in the trunk). Works fine, eth0.500
gets an IP address from the ISP’s DHCP server as expected.
Altered configuration #5 (trying the same with the original VLAN index 2 and an explicit option vid '500'
to set the VID separately; also removing the enable_vlan4k
option from the switch settings):
config device
option name 'eth0.500'
option macaddr 'xx:xx:xx:xx:xx:xx'
config interface 'wan'
option device 'eth0.500'
option proto 'dhcp'
config interface 'wan6'
option device 'eth0.500'
option proto 'dhcpv6'
config switch
option name 'switch1'
option reset '1'
option enable_vlan '1'
config switch_vlan
option device 'switch1'
option vlan '2'
option vid '500'
option ports '0t 6t'
The above does not work – eth0.500
does not get an IP address from the tagged VLAN provided by the uplink switch. Also, swconfig dev switch1 show
gives no indication of the 802.1Q VLAN ID 500 having been configured:
VLAN 1:
info: VLAN 1: Ports: '12346t', members=005e, untag=001e, fid=0
ports: 1 2 3 4 6t
VLAN 2:
info: VLAN 2: Ports: '0t6t', members=0041, untag=0000, fid=0
ports: 0t 6t
I tried lower VID numbers as well, such as option vid '10'
(configuring the upstream switch port with a matching tagged VLAN) just to see if the 802.1Q ID range itself is somehow limited in the non-vlan4k
mode – but no dice; the explicit option vid
setting does not seem to have effect on this switch/router.
Maybe there’s something wrong with the above simple option vid
line but whatever it is, I cannot figure it out.
It is fortunate that enable_vlan4k
unlocks access to 802.1Q VLAN IDs above 31 via the implicit option vlan 'x'
VID setting mechanism, though, since otherwise it seems I could not have used higher-numbered 802.1Q VLAN IDs on this device at all.
So now you can probably see why I was curious about the swconfig
architecture and the logic behind this whole thing.
Previously, I’ve only used OpenWrt on routers whose switch configuration is already DSA-based and where option vlan '1050'
(in the bridge-vlan
sections) configures a 802.1Q VLAN 1050 straight away with no extra configuration gymnastics needed on top of that. This TP-Link was a bit older gear, though, and got me wondering, especially as the default config does not include the required enable_vlan4k
(so I only found out about it accidentally), and enable_vlan4k
is not listed or documented among the available switch configuration options in the Wiki.