So I read about a dozen or so threads with different advise and finally put together a script to create vlans on boot that seems to work as intended. Unlike many of the examples out there, my script relies solely on brctl and ip link to create simple bridges. I'm open to feedback if I setup something wrong. I'm using OPNSense => ASUS AX92u (AP Mode) LAN4 (eth1) => WAN (eth0) Asus AX92u (AP Mode) / non-ai-mesh. Non-tagged traffic works fine when plugging into ethernet ports, but tagged traffic also gets distributed via the eth0 trunk back to OPNsense. I've created 4 guest networks and assigned each to a separate vlan. The code below is what I run on the first AX92u connected directly to OPNSense. The second AP shouldn't need the eth1.vNN sub interfaces added to each bridge (br1-br4) as it doesn't have another AP hooked up to it's LAN4 port. You can search for how to get scripts to auto start from a shell script e.g. /jffs/scripts/myvlanscript.sh called by /jfffs/scripts/services-start (you may need to enable jffs scripts in the webui => admin section > enable jffs scripts, and I think I had to install a usb disk, format it, then install packages by logging into AP via ssh then running amtm, then ep and selecting the formatted disk.
Code:
#!/bin/sh
set -x
# multi SSID with VLAN script, for ASUS AX92u with gnuton/merlin
# RT-AX92U interface layout
# eth0 -> WAN
# eth1 -> LAN4
# eth2 -> LAN3
# eth3 -> LAN2
# eth4 -> LAN1
# eth5 -> WLAN 2.4 GHz (but not used?)
# eth6 -> WLAN 5-1 GHz (but not used?)
# eth7 -> WLAN 5-2 GHz (but not used?)
# wl0.1 -> WLAN 2.4 GHz - 1st guest 2.4Ghz radio
# wl0.2 -> Wireless - 2nd guest 2.4Ghz radio
# wl1.1 -> WLAN 5Ghz - 1st guest 5Ghz-1 radio
# wl2.1 -> WLAN 5Ghz - 1st guest 5Ghz-2 radio
# wl1.2 -> WLAN 5Ghz - 2nd guest 5Ghz-1 radio
# wl2.2 -> WLAN 5Ghz - 2nd guest 5Ghz-2 radio
# echo "============== START 1 $(date) ==================" >> /jffs/scripts/log
# ip a >> /jffs/scripts/log
# ip r >> /jffs/scripts/log
# brctl show >> /jffs/scripts/log
# echo "============== END 1 $(date) ==================" >> /jffs/scripts/log
brctl show
# echo $PATH > /tmp/script_debug
# remove eth0 which will be reconfigured as a tagged port
#brctl delif br0 eth0 eth1 eth6 eth7
brctl delif br0 eth0 eth1 eth2 eth3 eth4 eth5 eth6 eth7
# remove guest wifi interfaces we're gonna move to other bridges
brctl delif br0 wl0.1 wl0.2 wl1.1 wl2.1
# simple for loop
for int in eth0 eth1 eth2 eth3 eth4 eth5 eth6 eth7;
do
ip link add link ${int} name ${int}.v20 type vlan id 20
ip link add link ${int} name ${int}.v40 type vlan id 40
ip link add link ${int} name ${int}.v80 type vlan id 80
ip link add link ${int} name ${int}.v100 type vlan id 100
ip link set ${int}.v20 up
ip link set ${int}.v40 up
ip link set ${int}.v80 up
ip link set ${int}.v100 up
done
# brctl stp br0 on # STP to prevent bridge loops
brctl addif br0 eth0 eth1 eth2 eth3 eth4 eth5 eth6 eth7
# set up br1, guest LAN
brctl addbr br1
brctl stp br1 on # STP to prevent bridge loops
brctl addif br1 eth0.v20
brctl addif br1 eth1.v20
brctl addif br1 wl0.1
ifconfig br1 192.168.20.2 netmask 255.255.255.0
ip link set br1 up
brctl addbr br2
brctl stp br2 on # STP to prevent bridge loops
brctl addif br2 eth0.v40
brctl addif br2 eth1.v40
brctl addif br2 wl0.2
ip link set br2 up
brctl addbr br3
brctl stp br3 on # STP to prevent bridge loops
brctl addif br3 eth0.v80
brctl addif br3 eth1.v80
brctl addif br3 wl1.1
ip link set br3 up
brctl addbr br4
brctl stp br4 on # STP to prevent bridge loops
brctl addif br4 eth0.v100
brctl addif br4 eth1.v100
brctl addif br4 wl2.1
ip link set br4 up
# seems like eapd reads config from these
# no need to set lan_ifname since it's already there
nvram set lan_ifnames="eth0 eth1 eth2 eth3 eth4 eth5 eth6 eth7"
nvram set br0_ifnames="eth0 eth1 eth2 eth3 eth4 eth5 eth6 eth7"
nvram set lan1_ifnames="wl0.1 eth1.v20 eth0.v20"
nvram set lan1_ifname="br1"
nvram set br1_ifnames="wl0.1 eth1.v20 eth0.v20"
nvram set br1_ifname="br1"
nvram set lan2_ifnames="wl0.2 eth1.v40 eth0.v40"
nvram set lan2_ifname="br2"
nvram set br2_ifnames="wl0.2 eth1.v40 eth0.v40"
nvram set br2_ifname="br2"
nvram set lan3_ifnames="wl1.1 eth1.v80 eth0.v80"
nvram set lan3_ifname="br3"
nvram set br3_ifnames="wl1.1 eth1.v80 eth0.v80"
nvram set br3_ifname="br3"
nvram set lan4_ifnames="wl2.1 eth1.v100 eth0.v100"
nvram set lan4_ifname="br4"
nvram set br4_ifnames="wl2.1 eth1.v100 eth0.v100"
nvram set br4_ifname="br4"
# doesn't seem to affect anything, just make it align
# we do NOT issue `nvram commit` here since it won't survive reboot anyway
# Disable hardware switching (increases CPU load) but threads say it's required
#ethswctl -c hw-switching -o disable #NOTE: in my testing this is not necessary. Here for reference.
# is there a better way to do this like `service restart eapd` ?
killall eapd
eapd