Router-on-a-stick is a type of router configuration in which a single physical interface routes traffic between multiple VLANs on a network. In order to perform inter-vlan routing, the router must accept VLAN tagged traffic on the trunk interface coming from the adjacent switch and internally routing between the VLANs using the sub-interface.
Sub-interfaces are virtual interfaces that are created on a single physical interface. When a physical interface is divided into these virtual interfaces, the router still considers them to be directly connected interfaces with subnets assigned to them and can route in between them. So, in router-on-a-stick configuration, each VLAN is assigned to the different sub-interface at the router physical interface.
At router-on-a-stick diagram, you will find out that we have three virtual PC and two routers, the router “R0” is used to perform the inter-vlan routing and the router “SW0”is used as a switch. Because cisco catalyst switch can not be emulate in GNS3, so in this scenario, I used cisco c2600 router to provide the switch interfaces. By default, GNS3 does not provide the virtual PC so you must install it to your computer by yourself. My recommendation tutorials which will help you in configuring virtual PC at your computer are shown below:
In our example we will have three vlans:
VLAN 100 : 192.168.10.0/24
VLAN 200 : 184.108.40.206/24
VLAN 99 : 220.127.116.11/29
Before you run the router-on-a-stick configuration, keep in your mind that the PC1 (ip address 192.168.10.15/24) is at VLAN 100, the PC2 (ip address 18.104.22.168/24) is at VLAN 200 and the PC3 (ip address 22.214.171.124/29) is at VLAN99. In SW0, I set the IP address and default gateway for VLAN 99 for management purposes. In order to use the default gateway at SW0, we need to enter “no ip routing” command at global configuration mode at SW0.
The last thing that you must not forget is to add three vlans (vlan 99, vlan 100 and vlan 200) in both router R0 and SWO vlan database:
Example at SW0:
VLAN 99 added:
VLAN 100 added:
VLAN 200 added:
After we have finished the configuration of vlan database between two routers, now we should be able to ping PC2 from PC1 or PC3 from PC1 and also VLAN 99 from PC1 to verify the connectivity.
I enclose herewith the link to Download the router-on-a-stick configuration. I hope you enjoy this tutorial and thank you for reading it.