Router on Stick Configuration Explained

Router-on-stick is a router feature. It allows you to configure and use a single router interface as many interfaces as you want. It transforms a physical interface into multiple virtual interfaces.

A router routes data packets between different logical subnets. By default, you can configure only one logical subnet per router interface. For example, if you want to configure five logical subnets, you need five router interfaces.

logical subnets

A logical subnet is also called an IP subnet or VLAN.

VLANs

Devices in different VLANs can not communicate directly. They can only communicate through a router. You must configure one router interface in each VLAN to provide connectivity between different VLANs. For example, if you want to connect 10 VLANs, you need 10 router interfaces, one for each.

Router interfaces

Ethernet interfaces connects VLANs. Routers have limited Ethernet interfaces. Most routers have two or four Ethernet interfaces. Usually, you configure numerous VLANs. To provide connectivity between these VLANs, you need many Ethernet interfaces. For example, you need 25 routers with two Ethernet ports on each router to connect 50 VLANs. Virtualization solves this problem. It turns a physical interface into multiple virtual interfaces. Each virtual interface works as a separate interface. It is called Router-on-Stick.

Ethernet interfaces

Router-on-Stick (Packet Tracer example)

Create a packet tracer lab, as shown in the following figure.

Packet Tracer lab

This lab has two PCs. You will configure both PCs using different VLANs. Each VLAN represents an individual IP subnet on a local network. For two VLANs, you need two IP subnets. I will use IP subnets 10 and 20. You can choose the IP subnets of your choice. If you pick different IP subnets, ensure the IP address you assign to the PC and the IP address you configure on the router's interface belong to the same IP subnet.

VLAN configuration

Access the switch's command line interface and create two VLANs. The vlan command in global configuration mode creates VLANs. It accepts the VLAN ID as an argument. It creates the specified VLAN and enters the sub-configuration mode. The sub-configuration mode allows you to configure additional parameters. You do not need further configuration for this exercise. Exit the sub-configuration mode.

CommandDescription
Switch>enable Start privileged-exec mode
Switch#configure terminal Start global configuration mode
Switch(config)#vlan 10 Create VLAN 10 and enter VLAN configuration mode
Switch(config-vlan)# exit Exit VLAN configuration mode
Switch(config)#vlan 20 Create VLAN 10 and enter VLAN configuration mode
Switch(config-vlan)# exit Exit VLAN configuration mode

After creating both VLANs, assign them to the interfaces. The switchport access VLAN command in the interface configuration mode assigns a VLAN to the interface. Assign the first VLAN to the interface connected to the first PC and the second VLAN to the interface connected to the second PC.

CommandDescription
Switch(config)#interface fastethernet 0/1 Enter interface configuration mode of fastethernet 0/1 interface
Switch(config-if)#switchport access vlan 10 Attach VLAN10 to the interface
Switch(config-if)#exit Exit interface configuration mode
Switch(config)#interface fastethernet 0/2 Enter interface configuration mode of fastethernet 0/2 interface
Switch(config-if)#switchport access vlan 20 Attach VLAN20 to the interface
Switch(config-if)#exit Exit interface configuration mode
Switch(config)# Global configuration mode

A switch port can work in two modes: access and trunk. In the access mode, it works in a single VLAN. It removes VLAN information from frames before forwarding them. It is the default mode. By default, all ports work in this mode. In the trunk mode, it belongs to all VLANs. It forwards frames with the VLAN information. The switchport mode trunk command in the interface configuration mode changes the port's mode to trunk. Run this command on the port connected to the router.

CommandDescription
Switch(config)#interface gigabitinterface 0/1 Enter interface configuration mode of gigabitinterface 0/1 interface
Switch(config-if)#switchport mode trunk Change default mode to trunk
Switch(config-if)#exit Exit interface configuration mode
Switch(config)# Global configuration mode

VLAN configuration

The show vlan command in privileged exec mode shows all VLANs and the interfaces on which they are active.

CommandDescription
Switch#show vlan Show all VLANs

The show vlan command

That's all the configuration you need on the switch for this exercise.

Router-on-Stick configuration

This configuration needs two router interfaces, one in each VLAN. You can use two physical interfaces or convert one into two logical interfaces. The second method is called router-on-stick. You will use it in this exercise.

Physical and logical interfaces

Access the CLI interface of the router and enter the interface configuration mode of the interface connected to the switch.

CommandDescription
Router>enable Start privileged-exec mode
Router#configure terminal Enter global configuration mode
Router(config)#interface fastethernet 0/0 Access interface configuration mode of the interface Fastethernet 0/0

In the interface configuration mode, run the no ip address and no shutdown command. The no ip address command runs this interface without an ip configuration. Since you will create sub-interfaces from this interface, you cannot assign an IP configuration to this interface. You will assign the IP configuration to sub-interfaces. The no shutdown command keeps this interface active. Since all sub-interfaces depend on it, it must be running constantly. If you shut it down, it shuts down all sub-interfaces.

CommandDescription
Router(config-if)#no ip address Remove IP configuration from the physical interface
Router(config-if)#no shutdown Start the physical interface and keep it running
Router(config-if)#exit Exit the interface configuration mode

Creating an interface without an IP configuration

To create a sub-interface, you use the same command you use to enter interface configuration mode. The only difference is that you provide a number with the interface number to make the sub-interface. You specify this number after a dot. Generally, administrators pick a number matching the VLAN ID. It helps them to identify the interface belonging to the VLAN. Creates a sub-interface for VLAN-10 and enters interface configuration mode.

CommandDescription
Router(config)interface fastethernet 0/0.10 Create a virtual interface (0/0.10) and enter sub-interface configuration mode

By default, a router interface accepts and forwards frames without VLAN information. If it receives frames with VLAN information, it discards them. If you want an interface to process frames containing VLAN information, you must change its encapsulation type to dot1Q. The encapsulation command changes the encapsulation type. It needs two arguments: encapsulation type and VLAN number. Change the encapsulation type to dot1Q and specify the VLAN ID 10. After changing the encapsulation, assign the IP address from the IP subnet belonging to the connected VLAN. You do not need any other setting. Exit the sub-interface configuration mode.

CommandDescription
Router(config-subif)#encapsulation dot1Q 10 Change the default encapsulation to dot1Q for VLAN-10
Router(config-subif)#ip address 10.0.0.1 255.0.0.0 Assign the IP address 10.0.0.1 255.0.0.0
Router(config-subif)#exit Exit the sub-interface configuration mode

Creating the first sub-interface

Create the second sub-interface for VLAN-20. Change its encapsulation to dot1Q and assign an IP address that belongs to the second VLAN.

CommandDescription
Router(config)interface fastethernet 0/0.20 Create a virtual interface (0/0.20) and enter sub-interface configuration mode
Router(config-subif)#encapsulation dot1Q 20 Change the default encapsulation to dot1Q for VLAN-20
Router(config-subif)#ip address 20.0.0.1 255.0.0.0 Assign the IP address 20.0.0.1 255.0.0.0
Router(config-subif)#exit Exit the sub-interface configuration mode
Router(config)# Global configuration mode

Creating the second interface

Specify the encapsulation type only on the interface receiving frames with VLAN information. Configuring is unnecessary if it gets frames from an end device, another router, or a switch port working in a single VLAN. However, you must change the encapsulation type if it receives frames from a switch port working in multiple VLANs.

Verifying Routing-on-Stick

To verify the router-on-stick configuration, you check connectivity between both PCs. Open the command prompt of the first PC and send ping requests to the second PC.

Pinging in different VLANs

  • PC generates ICMP echo messages and sends them to the switch.
  • The switch receives them on port one. Port one belongs to VLAN 10. Switch forwards incoming frames from all ports working in the same VLAN. Another port in this VLAN is the Gigabit port. Switch forwards incoming frames from this port.
  • Since this port works in the trunk mode, the switch attaches the VLAN ID to frames before forwarding them.
  • The router receives these frames on the FastEthernet interface. Since this interface has sub-interfaces, the router uses the VLAN ID to identify the incoming sub-interface.
  • The first sub-interface receives these frames, converts them into packets, reads their destination network address, and finds it in the routing table.
  • The destination address is available on the second sub-interface. It gives packets to the second sub-interface.
  • The second sub-interface converts packets into frames, attaches VLAN ID 20, and forwards them. The tagged frames reach the Gigabit port of the switch.
  • The switch reads the VLAN ID of each frame and finds the ports that belong to it. Another port in VLAN 20 is port two.
  • Since port two works in access mode, the switch removes vlan information from all frames. After removing VLAN information, it forwards them.
  • If the second PC replies, frames take the same path in the reverse order.
  • The switch receives frames on the port running in VLAN 20 and forwards them to the router from the trunk port. The router gets them on the second virtual interface and forwards them from the first virtual interface after updating the VLAN ID to 10. The switch receives them on the trunk port. The switch reads their VLAN ID. The frames belong to VLAN 10. It forwards them from all ports belonging to VLAN 10. The frames reach the first PC from the port connected to VLAN 10.
  • Successful reply messages verify the router-on-stick configuration.

This way, the router-on-stick feature enables communication between different VLANs using only a single router interface.

Video version

This tutorial is also available in video format. You can watch it to understand the concepts and configuration steps explained in this tutorial in more detail.

Youtube

Conclusion

The Router-on-Stick feature allows you to convert and use a physical Ethernet port into multiple logical Ethernet ports. Each logical port works as an individual Ethernet port. This tutorial explained how to implement this feature on a router through a Packet Tracer example.

ComputerNetworkingNotes CCNA Study Guide Router on Stick Configuration Explained

We do not accept any kind of Guest Post. Except Guest post submission, for any other query (such as adverting opportunity, product advertisement, feedback, suggestion, error reporting and technical issue) or simply just say to hello mail us ComputerNetworkingNotes@gmail.com