I started to go down the road of setting up my network to isolate some devices from each others (e.g. guests from authenticated, risky IoT & media devices from regular devices), while allowing some supervised communications between the groups (e.g. regular devices can control and present on media devices, but risky IoT devices cannot start probing my network).
I also have the requirement that most devices are wired if possible, but I also have 4 APs to properly cover wireless devices (thanks plaster on wire mesh for creating faraday cages).
While I haven't yet decided on the solution to isolate the devices from each other (bridge with filters or selective routing+broadcast relay), both would require setting up VLANs, sharing those over tagged ethernet, and bridging the VLANs with their respective virtual wireless interfaces.
In a nutshell, the required steps are
- configure the switch to offer the tagged VLANs on the physical port and CPU port.
- create a virtual interface for VLAN ID
- bring the interface up
- create a bridge if none already exists for that network (e.g. bridge guest wireless with guest vlan, but isolate through routing instead of bridge filters)
- add interface to the bridge
- configure network and services on the interface/bridge, e.g. IPv4, IPv6 from prefix delegation and sla-id, Dnsmasq
- setup firewall rules and/or bridge filters
There seem to be a lot variations in suggestions on how to performs these steps.
Most of them are user script based, optionally leveraging of builtin features through nvram configs.
Ultimately, I'd like to have a solution where each step is performed at the right time (init, service start, lan up/down etc), with scripts containing as little configuration as possible, leveraging nvram for settings, in a way that doesn't conflict too much with GUI operations hopefully leverages builtin features.
When digging through the firmware source, I realized some code exists for a lot of the vlan operations above, but it seems to be mostly behind the RTCONFIG_PORT_BASED_VLAN config flag, which seems to have been introduced in the code base when merging GPL code 380_2345 (
https://github.com/RMerl/asuswrt-merlin/commit/c19e98a5072455965867004b3f07fb78d7b3bffe).
From what I understand, when the config is enabled, 3 new pages are available (Advanced_VLAN_Content.asp, Advanced_VLAN_DHCP_Content.asp and Advanced_VLAN_Group_Content.asp), and a bunch of nvram settings control the VLAN operations:
- vlan_rulelist to list the different vlans, their state, which ports and wireless interfaces are included.
- lan%d_* to control the parameters of each lan, derived from vlan_ruleset it seems.
- vlan_index to indicate the last lan index in use.
- Some other related to filters, etc.
It would seem that the vlan created are automatically numbered starting at vlan4, which is a bit of a bummer. I'm not sure if ports carry the vlans tagged or not.
Has anyone tried to build a version of the firmware with this feature enabled to see how it works in real life?
It would seem some limitations could be vlan ids and ipv6 prefix delegation subnets.
At the very least, it should be a good source of inspiration for how to setup VLANs, especially everything in the following file:
https://github.com/RMerl/asuswrt-merlin/blob/master/release/src/router/rc/vlan.c