If you really are serious about learning about this, I would highly recommend picking up a cheap fully managed layer 3 switch off ebay. A layer 3 switch is both a switch and a router. It will let you create multiple subnets and routing rules to reach them (as well as create VLANs which is another whole layer of "virtual networks" such that you can have multiple address spaces which are seperate from each other but can be the same exact subnet, although you will find out the inherit problems of doing something like that if you still need to have devices contained on them communicate with each other).
While a ubiquiti ER-X as suggested would work for learning, I would actually recommend a Brocade ICX6450. This is usually about $120 from ebay or the like. The benefit over the ER-X is multi-fold. First off the brocade will have 48 GB ports as well as 4 SFP+ ports capable of 10GB. It is also a full layer 3switch with IPv4+IPv6 routing, L2/L3/L4 ACL's, VRRP, OSPF, SNMP, sflow, VRFs, tunnels, and even BGP support. Additionally it has both a web management interface as well as a command line interface with that interface sharing 90-95% the same as CISCO's command line interface, so that what you are learning is directly applicable to the defacto business/industry networking standard.
There is a thread on Serve The Home forums that talks about the switch I recommend.
NOTE #1: do not PM me with switch questions, they will be ignored - post them in this public thread, where hundreds of other members can also answer, and the answer will be public for future users NOTE #2 06-22-2023: Yes, this post is still up to date and nothing has changed: in fact judging by...
forums.servethehome.com
It also has links to an excellent how to for initial setup (from wiping it, updating the firmware to the latest, and basic setup of the switch). There is also a decent web tutorial on youtube about the FastIron OS (the OS that runs on the switch) with how to set various items through the command line (but just about everything that can be done via command line can also be done in the web management, so that it makes it a much easier switch to learn on and you can then look at the configuration from the command line to see what it actually did under the hood as long as you know what to ask the switch to show you of it's configuration).