‘Router on a Stick’ allows routing between VLANs with only one interface. Each VLAN represents a different Subnet. In general, routers can take traffic from only one subnet and transfer it to another subnet. And we can assign only one IP Address to a router interface. ‘Router on a stick’ allows us to create sub-interfaces, and assign IP Addresses to those sub-interfaces. To make it work, we have to create a truck connection between the switch and a router so that traffic from multiple VLANs can be sent to the router.
If we create a route between VLANs without the ‘Router on a Stick’ method, then we have to waste interfaces on the switches and routers. And if we enable routing between multiple VLANs then it will become practically inefficient as the switches and the routers will use those multiple interfaces.
The image below is an alternative method for allowing routing between VLANs. As you can see, we are using two interfaces on both the router and a switch to allow routing between VLANs. We have not created a sub-interface in the below figure.
You can see that we have to use extra interfaces for each VLAN. So, it becomes practically non-efficient if we have multiple VLANs. Hence, ‘Router on a Stick’ is a perfect solution for routing between VLANs with just one router interface.
The more simple way to do routing between VLANs is by using a Layer 3 Switch. We just have to create virtual interfaces for each VLAN and assign them IP Addresses from the same network. A Layer 3 Switch will then enable routing between VLANs as it has routing capabilities as well. However, Layer 3 Switch is quite expensive so it might not be an affordable option for small office networks.
In the below lab, we will configure ‘Router on a Stick’ that would allow routing between the VLANs. Some of the important concepts in this lab are – to create sub-interfaces, use encapsulation dot1Q command to encapsulate the traffic, and mentioning the VLAN number to ascertain that for which VLAN the sub-interface should respond.
Router on a stick configuration in packet tracer.
1. Assign IP address and default gateway to the PC
2. Create Vlans and assign ports to the Vlans
3. Configure trunk connection between router and a switch
4. Create sub-interface and allow routing between the Vlans
Click on pc0 > click on desktop tab > click on IP configuration > set IP address and default gateway
Switch(config-if)#switchport access vlan 5
Switch(config-if)#switchport access vlan 10
Switch(config)#in fastethernet 0/1
Switch(config-if)#switchport mode trunk
Router(config)#in fa 0/1
Router(config)#interface fastethernet 0/1.5
Router(config-subif)#encapsulation dot1Q 5
Router(config-subif)#ip address 192.168.2.1 255.255.255.0
Router(config-subif)#in fastethernet 0/1.10
Router(config-subif)#encapsulation dot1Q 10
Router(config-subif)#ip add 192.168.3.1 255.255.255.0