Configuring Router-on-a-stick (ROAS) for VLANs

Nerd Cafe

In this guide, we will configure Router-on-a-Stick (ROAS) to allow inter-VLAN communication using a Cisco Router and a Layer 2 Switch in GNS3.

Scenario

A company has two departments: Sales and HR, each in a separate VLAN. The company uses a single router to enable communication between VLANs.

  • VLAN 10 (Sales)192.168.10.0/24

  • VLAN 20 (HR)192.168.20.0/24

  • Router-on-a-stick is implemented on a Cisco Router

  • Cisco Switch is used

  • Two PCs for testing

Topology

  1. Cisco Router (R1)

  2. Cisco Switch (SW1)

  3. Two PCs:

    • PC1 (Sales) → VLAN 10

    • PC2 (HR) → VLAN 20

  4. Trunk Link between SW1 and R1 using FasrEthernet 0/0

🖧 Topology Diagram:

Topology

Step 2: Configure VLANs on the Switch (SW1)

💻 Switch Configuration

/Sw1#configure terminal
Sw1(config)#vlan 10
Sw1(config-vlan)#name Sales
Sw1(config-vlan)#exit
Sw1(config)#vlan 20
Sw1(config-vlan)#name HR
Sw1(config-vlan)#exit
Sw1(config)#interface ethernet 0/1
Sw1(config-if)#switchport mode access
Sw1(config-if)#switchport access vlan 10
Sw1(config-if)#exit
Sw1(config)#interface ethernet 0/2
Sw1(config-if)#switchport mode access
Sw1(config-if)#switchport access vlan 20
Sw1(config-if)#exit
Sw1(config)#interface ethernet 0/0
Sw1(config-if)#switchport trunk encapsulation dot1q
Sw1(config-if)#switchport mode trunk                                                                                      0, changed state to up
Sw1(config-if)#exit
Sw1(config)#exit
Sw1#write memory
Warning: Attempting to overwrite an NVRAM configuration previously written
by a different version of the system image.
Overwrite the previous NVRAM configuration?[confirm]
Building configuration...
Compressed configuration from 1513 bytes to 904 bytes[OK]
Sw1#

Step 3: Configure the Router for Inter-VLAN Routing

💻 Router Configuration

R1#configure terminal
R1(config)#interface fastEthernet 0/0.10
R1(config-subif)#encapsulation dot1Q 10
R1(config-subif)#ip address 192.168.10.1 255.255.255.0
R1(config-subif)#exit
R1(config)#interface fastEthernet 0/0.20
R1(config-subif)#encapsulation dot1Q 20
R1(config-subif)#ip address 192.168.20.1 255.255.255.0
R1(config-subif)#exit
R1(config)#interface fastEthernet 0/0
R1(config-if)#no shutdown                                                                                        et0/0, changed state to up
R1(config-if)#^Z
R1#write memory
Warning: Attempting to overwrite an NVRAM configuration previously written
by a different version of the system image.
Overwrite the previous NVRAM configuration?[confirm]
Building configuration...
[OK]
R1#

Step 4: Assign IPs to PCs

💻 PC1 (Sales Department)

PC1> ip 192.168.10.100/24 192.168.10.1
Checking for duplicate address...
PC1 : 192.168.10.100 255.255.255.0 gateway 192.168.10.1

PC1> show ip

NAME        : PC1[1]
IP/MASK     : 192.168.10.100/24
GATEWAY     : 192.168.10.1
DNS         :
MAC         : 00:50:79:66:68:00
LPORT       : 20008
RHOST:PORT  : 127.0.0.1:20009
MTU         : 1500

PC1> save
Saving startup configuration to startup.vpc
.  done

PC1>

💻 PC2 (HR Department)

PC2> ip 192.168.20.100/24 192.168.20.1
Checking for duplicate address...
PC2 : 192.168.20.100 255.255.255.0 gateway 192.168.20.1

PC2> show ip

NAME        : PC2[1]
IP/MASK     : 192.168.20.100/24
GATEWAY     : 192.168.20.1
DNS         :
MAC         : 00:50:79:66:68:05
LPORT       : 20010
RHOST:PORT  : 127.0.0.1:20011
MTU         : 1500

PC2> save
Saving startup configuration to startup.vpc
.  done

PC2>

Step 5: Test Connectivity

🔹 PC1 → Ping Router (192.168.10.1)

PC1> ping 192.168.10.1

84 bytes from 192.168.10.1 icmp_seq=1 ttl=255 time=60.945 ms
84 bytes from 192.168.10.1 icmp_seq=2 ttl=255 time=13.229 ms
^C
PC1>

🔹 PC2 → Ping Router (192.168.20.1)

PC1> ping 192.168.20.1

84 bytes from 192.168.20.1 icmp_seq=1 ttl=255 time=4.773 ms
84 bytes from 192.168.20.1 icmp_seq=2 ttl=255 time=4.761 ms
^C
PC1>

🔹 PC1 → Ping PC2 (192.168.20.2)

PC1> ping 192.168.20.100

84 bytes from 192.168.20.100 icmp_seq=1 ttl=63 time=32.970 ms
84 bytes from 192.168.20.100 icmp_seq=2 ttl=63 time=19.624 ms
^C
PC1>

Keywords

Router-on-a-Stick, VLAN configuration, Cisco Packet Tracer, inter-VLAN routing, Cisco 2960 switch, Cisco 2911 router, subinterfaces, trunk port, encapsulation dot1Q, VLAN 10, VLAN 20, access ports, network topology, IP addressing, default gateway, network simulation, switch configuration, router configuration, network troubleshooting, ping test, سیسکو

Last updated