Network switches come in two different flavors: managed unmanaged. Unmanaged switches are cheap but you can’t control them. Managed switches have some interface to configure and monitor the equipment, and cost much more. Watch as Jim Gibson explains why you need managed switches in your network.
For a hacker perspective you might ask how different those two switch types are, and can you convert an unmanaged switch to managed. Managing an Unmanaged Switch article tells that [Tiziano Bacocco] wanted to manage his cheap unmanaged switch, so he did what any good hacker would do: he opened it up to see what is inside. Inside the Digicom 10/100 switch he found an IP178CH controller IC and a quick search turned up a data sheet which tells how to control the switch IC.
Convert your cheap “unmanaged” switch to a VLAN capable layer 2 managed switch for just $2 posting gives the details for the conversion. The switch chip can be programmed using a synchronous serial interface at pins MDC & MDIO, on the fly with serial interface is similiar to I2C but much simpler. Now once you know how to operate communicate with the switch it’s just matter of programming an Arduino (or you could also use a Raspberry Pi to manage the switch instead of an Arduino). With this approach you can assign which ports belongs to a VLAN and onfigure how to treat untagged packet.