Each VLAN is a subnet
PC1 in VLAN 10 (192.168.10.0/24) and PC2 in VLAN 20 (192.168.20.0/24) are in different subnets, so PC1 sends anything for PC2 to its default gateway. Something has to be that gateway in each VLAN and route between them.
| Design | How | Good | Bad |
|---|---|---|---|
| Legacy | One router port per VLAN, each on an access port | Simple | Runs out of router ports fast |
| Router-on-a-stick (ROAS) | One router port on a trunk, with one subinterface per VLAN | Cheap: one link for all VLANs | All inter-VLAN traffic shares that one link, twice |
| Multilayer switch | The switch routes, with an SVI (interface vlan) per VLAN | Fast (in hardware); no extra links | Needs a layer 3 switch |
Below, the router is already set up as a router-on-a-stick. PC1's ping to PC2 goes up the trunk to R1 in VLAN 10 and comes back down in VLAN 20. TTL 63 in the reply shows it crossed one router.
In NetLab
▶ PC1 NetLab Windows-style command prompt. Type help to see the commands. C:\Users\student>ping 192.168.20.10 Pinging 192.168.20.10 with 32 bytes of data: Request timed out. Reply from 192.168.20.10: bytes=32 time<1ms TTL=63 Reply from 192.168.20.10: bytes=32 time<1ms TTL=63 Reply from 192.168.20.10: bytes=32 time<1ms TTL=63 Ping statistics for 192.168.20.10: Packets: Sent = 4, Received = 3, Lost = 1 (25% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms C:\Users\student>tracert 192.168.20.10 Tracing route to 192.168.20.10 over a maximum of 30 hops 1 <1 ms <1 ms <1 ms 192.168.10.1 2 2 ms 2 ms 2 ms 192.168.20.10 Trace complete.
Remember: The PC's default gateway is the router's address in the PC's own VLAN: a subinterface or an SVI.