I've got it working. If I understand how this VLAN stuff works, VLAN 501 and 502 are isolated from each other, and since I'm keeping all my IOT stuff on 2.4G guest and using 5G guest for actual guests, I decided maintain the VLAN 501=2.4G and 502=5G topology on the AP.
Here is the core of the script. I experimented with disabling the nvram entries, Runner, and FC. Runner and FC do not need to be disabled to work on my AP. I found that one of the nvram entries was unneeded, but the others were all needed for the AP guest networks to function. So everything that's listed here is needed.
Considering how simple and logical this code is, I'm amazed that someone hadn't figured this out long ago. I suppose part of the reason is that VLAN implementation of Guest Network #1 on ASUS main routers appears to be a fairly recent change to the firmware. Perhaps another reason is that I suspect that only a few people are using ASUS routers in AP mode (which is unfortunate because AP mode appears to be way more reliable and configurable than Aimesh mode if wired backhaul is available).
Can you folks let me know if you see anything that can be improved? After that, I will create a new thread and post it there.
One question for anyone - I have my main router configured to act as an NTP server and force devices on my network to use it. Will devices on these VLAN guest networks on the AP be able to reach the main router NTP server? Is there a way to test this?
Code:
# Remove hash tags from the following lines if setting up 2.4G Guest Network #1 on the AP.
# Create VLAN 501 and link to eth0 (WAN port),
ip link add link eth0 name eth0.501 type vlan id 501
ip link set eth0.501 up
# Remove wl0.1 interface from br0.
brctl delif br0 wl0.1
# Set up br1, and then link VLAN 501 and wl0.1 (2.4G Guest Network #1) to br1.
brctl addbr br1
brctl addif br1 eth0.501
brctl addif br1 wl0.1
ip link set br1 up
# Create names in nvram.
nvram set lan1_ifnames="wl0.1 eth0.501"
nvram set lan1_ifname="br1"
nvram set br1_ifnames="wl0.1 eth0.501"
nvram set br1_ifname="br1"
# End setup of 2.4G Guest Network #1 on the AP.
# Remove hash tags from the following lines if setting up 5G Guest Network #1 on the AP.
# Create VLAN 502 and link to eth0 (WAN port),
ip link add link eth0 name eth0.502 type vlan id 502
ip link set eth0.502 up
# Remove wl1.1 interface from br0.
brctl delif br0 wl1.1
# Create br2, then link VLAN 502 and wl1.1 (5G Guest Network #1) to br2.
brctl addbr br2
brctl addif br2 eth0.502
brctl addif br2 wl1.1
ip link set br2 up
# Create names in nvram.
nvram set lan2_ifnames="wl1.1 eth0.502"
nvram set lan2_ifname="br2"
nvram set br2_ifnames="wl1.1 eth0.502"
nvram set br2_ifname="br2"
# End setup of 5G Guest Network #1 on the AP.
# eapd reads config from these.
# No need to set lan_ifname since it's already there.
nvram set lan_ifnames="eth1 eth2 eth3 eth4 eth5 eth6 eth0"
# Do NOT issue `nvram commit` here since it won't survive reboot. (Is this really true?)
# Restart eapd.
# Is there a better way to do this like `service restart eapd` ?
killall eapd
eapd