In this post we are going to show you how you can implement router on a stick. You can use cisco packet tracer program as a virtual lab on your computer. Figure 1 shows the scenario that we are going to implement.
What is a Router on a stick?
A Stub router, One-armed router or router on a stick, is a router that routes traffic between virtual local area networks (VLANs). It has only a single Ethernet NIC that is part of two or more Virtual LANs, enabling them to be joined.
A switch allows multiple virtual LANs to coexist on the same physical switch. This means that two machines attached to the same switch cannot send Ethernet frames to each other. If they need to communicate, then a router must be placed between the two VLANs to forward packets between them, just as if the two LANs were physically isolated. The only difference is that the router contains only a single Ethernet NIC that is part of both VLANs. Hence we call it Router on a stick or “one-armed”.
First we are going to add a Cisco 2960 switch and 2 computers to our virtual lab and then we configure 2 VLANs on the switch that are named VLAN 10 (Accounting) and VLAN 20 (Engineering) as depicted in Figure 1.
To configure the VLANs on the switch follow these steps:
1. Switch#config t
2. Switch(config)#vlan 10
3. Switch(config-vlan)#Name Accounting
4. Switch (config-vlan)#exit
5. Switch(config)#vlan 20
6. Switch(config-vlan)#Name Engineering
7. Switch (config-vlan)#exit
With the above commands you have successfully configured the VLAN 10 and VLAN 20 on the switch and you have assigned names to them.
Now we are going to assign Fa0/1 port to Accounting (VLAN 10) and Fa0/2 port to Engineering (VLAN 20) that we made in Step 1.
To assign the ports to the VLANs follow these steps:
1. Switch(config)#interface fastEthernet 0/1
2. Switch(config-if)#switchport mode access
3. Switch(config-if)#switchport access vlan 10
5. Switch(config)#interface fastEthernet 0/2
6. Switch(config-if)#switchport mode access
7. Switch(config-if)#switchport access vlan 20
Verify the result of Step 1 and Step 2 by typing the Show vlan brief command on the switch.
Now let’s add a 2621 router and configure it to route the packets between 2 VLANs.
Configure 2 virtual interfaces on fa0/1 and assign them to VLAN 10 and VLAN 20 for the sake of making configuration understandable to everyone it is better to use the same names or numbers for the VLANs (Here we use VLAN 10 and VLAN 20 as we used them before in our switch configuration).
1. Router(config)#interface fastEthernet 0/0.10
2. Router(config-subif)#encapsulation dot1Q 10
3. Router(config-subif)#ip address 192.168.10.1 255.255.255.0
5. Router(config)#interface fastEthernet 0/0.20
6. Router(config-subif)#encapsulation dot1Q 20
7. Router(config-subif)#ip address 192.168.20.1 255.255.255.0
9. Router(config)#interface fastEthernet 0/0
10. Router(config-if)#no shutdown
On the switch we need to make the port that connects our switch to the router a trunk port to make it work. In our demonstration we are using port Fa0/24 as a trunk port. Follow below steps to make port 24 a trunk port.
1. Switch(config)#interface fastEthernet 0/24
2. Switch(config-if)#switchport trunk allowed vlan 10,20
3. Switch(config-if)#switchport mode trunk
With these 4 steps you have configured the router to route the traffic between the VLANs. You can add 2 computers to the ports that you have configured and assign them IP address to test the result. Just pay attention that the default gateway address of each computer in each VLAN is the router’s virtual interface IP address that you have configured for the same VLAN.