Netgear has a cheap 5 port switch (GS105e, IIRC) that can do VLANs and trunking. There also have larger models.
You'd configure the switch port that the router is plugged into as a trunk, and then configure the other 4 switch ports as untagged in different VLANs (say, 101 for port 1, 102 for port 2, and so on).
On the router side, you can use vconfig to create VLAN subinterfaces for each VLAN. You'd end up with eth0.101, eth0.102, and so on.
You then just ignore eth0 on the router, and use eth0.# interfaces as stand-ins for the various switch ports. You can put them in Linux bridges, route to and from them, and so on.
This is internally how most cheap wireless routers work. The CPU has only 1 or 2 ethernet interfaces, and an small onboard switch chip.
Link level things like LLDP and STP may or may not work right with this config, depending on exactly how the switch chip (on board on a cheap wireless router, in the netgear switch for this DIY version). But most home and small business routers don't support LLDP and STP anyway.
You'd configure the switch port that the router is plugged into as a trunk, and then configure the other 4 switch ports as untagged in different VLANs (say, 101 for port 1, 102 for port 2, and so on).
On the router side, you can use vconfig to create VLAN subinterfaces for each VLAN. You'd end up with eth0.101, eth0.102, and so on.
You then just ignore eth0 on the router, and use eth0.# interfaces as stand-ins for the various switch ports. You can put them in Linux bridges, route to and from them, and so on.
This is internally how most cheap wireless routers work. The CPU has only 1 or 2 ethernet interfaces, and an small onboard switch chip.
Link level things like LLDP and STP may or may not work right with this config, depending on exactly how the switch chip (on board on a cheap wireless router, in the netgear switch for this DIY version). But most home and small business routers don't support LLDP and STP anyway.