Router-on-a-Stick InterVLANs Sub-Interfaces.

By | December 15, 2023

What Is Router-on-a-Stick Inter-VLANs Sub-interfaces?

Router-on-a-Stick Inter-VLANs is a network setup that enhances communication between various VLANs on a single network device. It Involves connecting a single physical interface of a router to a switch, along with configuring multiple logical sub-interfaces on the router.

This setup allows for the routing of traffic between different VLANs without the need for separate physical interfaces on the router. By using sub-interfaces, each VLAN can be assigned a unique virtual interface with its own IP address, enabling the router to route traffic between VLANs based on their respective IP subnets. Additionally, this configuration simplifies network management and reduces the need for additional hardware, making it a cost-effective solution for small to medium-sized networks.

Each sub-interface corresponds to a different VLAN.

Router-on-Stick-Subinterfaces.png

How It Works

Single Physical Connection: The router is connected to a network switch via a single Ethernet cable.

Trunking: The switch port connected to the router is configured as a trunk port to allow traffic from multiple VLANs.

Sub-Interfaces: On the router, the physical interface connected to the switch is divided into multiple virtual sub-interfaces, each tagged with a unique VLAN ID.

Configuration Steps

VLAN Setup: Configure VLANs, assign port access and names( if required) on the switch.

Example:

SW1#config t

SW1(config)#vlan 10

SW1(config-vlan)#vlan 20

SW1(config-vlan)#vlan 30

SW1(config-vlan)#exit

Assign VLANs switchport access

SW1(config)#interface fa0/8

SW1(config-if)#switchport access vlan 10

SW1(config-if)#interface fa0/4

SW1(config-if)#switchport access vlan 20

SW1(config-if)#interface fa0/11

SW1(config-if)#switchport access vlan 30

SW1(config-if)#end

Assign Names to VLANs.

In a practical scenario, a company may have separate VLANs for different departments (e.g., Sales, HR, IT). Using the Router-on-a-Stick configuration, a single router can manage traffic between these VLANs while maintaining network segmentation for security and organizational purposes.

Switch1#config t

switch1(config)#vlan 10

switch1(config-vlan)#name orbit

switch1(config-vlan)#exit

switch1(config)#vlan 20

switch1(config-vlan)#name cisco

Switch1(config-vlan)#exit

Switch1(config)#vlan 30

Switch1(config-vlan)#name student

Switch1(config-vlan)#exit

Switch1(config)#exit

Trunk Port Configuration: Set up the switch port connected to the router as a trunk port.

Router Interface Configuration:

S1#config t

S1(config)# Gi0/0

S1(config-if)#switchport mode trunk

S1(config-if)#end

Create sub-interfaces on the Router for each VLAN.

i. Assign each sub-interface a VLAN ID using the encapsulation dot1Q command (in Cisco devices).

ii. Assign IP addresses to each sub-interface. These IPs will serve as the default gateways for devices in their respective VLANs.

Below is a network topology diagram illustrating a Router-on-a-Stick Sub-interfaces configuration. This visual will aid in understanding the configuration steps with examples.

Sub-interface Configuration Steps with Examples

Step 2: Trunk Port Configuration

Objective: Set up the switch port connected to the router as a trunk port.

Example:

Configuration example:

S1#config t

S1(config)#interface Gi0/0

S1(config-if)#switchport mode trunk

S1(config-if)# switchport trunk allowed vlan 10,20,30

S1(config-if)#end

Purpose: The above configuration enabled the switch port GigabitEthernet0/0 as a trunk port and allows VLANs 10, 20, and 30 to pass through it.

Step 3: Router Interface Configuration

Objective: Create sub-interfaces on the router, one for each VLAN.

Example:

RHQ1#config t

RHQ1(config)#interface Gi0/0.10

RHQ1(config)#encapsulation dot1Q 10

RHQ1(config)#ip address 192.168.10.1 255.255.255.0

RHQ1(config)#interface Gi0/0.20

RHQ1(config)#encapsulation dot1Q 20

RHQ1(config)#ip address 192.168.20.1 255.255.255.0

RHQ1(config)#interface Gi0/0.30

RHQ1(config)#encapsulation dot1Q 30

RHQ1(config)#ip address 192.168.30.1 255.255.255.0

Purpose: These commands create sub-interfaces for each VLAN on the router’s GigabitEthernet0/0 interface. VLAN tags are assigned, and each sub-interface is given an IP address, acting as the default gateway for the VLAN.

Network Topology Explanation

The router has a single physical interface (GigabitEthernet0/0), configured with three sub-interfaces.

Each sub-interface corresponds to a different VLAN (10, 20, 30) and has an IP address that serves as the default gateway for that VLAN.

The switch is configured with the same VLANs and its port connected to the router is set up as a trunk port.

This topology enables devices in different VLANs to communicate with each other through the router, maintaining VLAN separation while allowing inter-VLAN routing.

Read More on inter-VLAN routing.