Inter VLAN Routing Configuration in Cisco Packet Tracer

Aisyah Aldina

Illustration of a direction signpost for a guide on inter VLAN routing in Packet Tracer

Hi everyone, in the two previous articles we created VLANs and proved that PCs in different VLANs cannot talk to each other. In practice, the admin team and the guest network are kept apart, yet they still need to reach the same server or the same internet connection. This is where inter VLAN routing comes in: a router forwards packets from one VLAN to another.

The method I use here in Cisco Packet Tracer 8.2.1 is router on a stick. You only need one cable from the router to the switch, and the router port is split into several subinterfaces, one for each VLAN. If VLANs and trunks are still new to you, start with my guides on how to configure VLANs in Cisco Packet Tracer and VLAN trunk configuration with 2 switches.

Building the Router on a Stick Topology

Add the router, switch, and PCs

Cisco Packet Tracer window showing a router on a stick topology with two VLANs

The devices I used are 1 Cisco 1941 router, 1 Cisco 2960-24TT switch, and 4 PCs. The window above shows the whole topology in Cisco Packet Tracer.

Topology with a 1941 router, 2960 switch, and four PCs in VLAN 10 and VLAN 20

The green box is VLAN 10 with the 192.168.10.0/24 network, and the yellow box is VLAN 20 with the 192.168.20.0/24 network. Unlike the earlier VLAN article, each VLAN now has its own IP network, because a router can only forward packets between different networks.

PC0 FastEthernet0      ->  Switch0 FastEthernet0/1     (straight)
PC1 FastEthernet0      ->  Switch0 FastEthernet0/2     (straight)
PC2 FastEthernet0      ->  Switch0 FastEthernet0/3     (straight)
PC3 FastEthernet0      ->  Switch0 FastEthernet0/4     (straight)
Router0 Gig0/0         ->  Switch0 GigabitEthernet0/1  (straight)

One cable from the router to the switch

Single straight cable from router Gig0/0 to switch Gig0/1 in Packet Tracer

A router and a switch are different types of devices, so the cable is Copper Straight-Through. There is only one cable, from Gig0/0 on the router to Gig0/1 on the switch. This cable will carry VLAN 10 and VLAN 20 traffic at the same time, which is why the method is called router on a stick.

Warning: When you connect the cable to the router, make sure you really pick GigabitEthernet0/0. I once clicked the wrong port, and the ping failed even though the configuration was correct. Check the port label at the end of the cable before moving on.

Set the IP and gateway on each PC

IP 192.168.10.10 and gateway 192.168.10.1 set on PC0 in Cisco Packet Tracer

Fill in IP Configuration on each PC according to the table below. The default gateway is required, because that is the address a PC sends packets to when the destination is in another VLAN.

PC0  192.168.10.10  gateway 192.168.10.1  (VLAN 10)
PC1  192.168.10.11  gateway 192.168.10.1  (VLAN 10)
PC2  192.168.20.10  gateway 192.168.20.1  (VLAN 20)
PC3  192.168.20.11  gateway 192.168.20.1  (VLAN 20)

Configuring the Switch

Create the VLANs, access ports, and the trunk to the router

Cisco switch configuration with VLANs, access ports, and a Gig0/1 trunk to the router

Open the switch CLI and type the following commands.

enable
configure terminal
vlan 10
exit
vlan 20
exit
interface range fastEthernet0/1-2
switchport mode access
switchport access vlan 10
exit
interface range fastEthernet0/3-4
switchport mode access
switchport access vlan 20
exit
interface gigabitEthernet0/1
switchport mode trunk
end
write memory

The ports facing the PCs become access ports in their VLANs, while Gig0/1, which leads to the router, becomes a trunk so it can carry VLAN 10 and VLAN 20 together.

Configuring Subinterfaces on the Router

Create a subinterface for each VLAN

Router subinterfaces Gig0/0.10 and Gig0/0.20 configured with encapsulation dot1Q

Open the router CLI, answer no to the initial configuration dialog, then type the following commands.

enable
configure terminal
interface gigabitEthernet0/0
no shutdown
exit
interface gigabitEthernet0/0.10
encapsulation dot1Q 10
ip address 192.168.10.1 255.255.255.0
exit
interface gigabitEthernet0/0.20
encapsulation dot1Q 20
ip address 192.168.20.1 255.255.255.0
end
write memory

The physical interface Gig0/0 only needs to be turned on with no shutdown, without an IP address. The IP addresses go on the subinterfaces Gig0/0.10 and Gig0/0.20. The number after the dot is just the subinterface name, and I matched it to the VLAN number so it is easy to read.

The encapsulation dot1Q 10 command is the most important part. It tells the router that this subinterface handles frames tagged with VLAN 10 coming from the trunk. The IP on each subinterface becomes the gateway for that VLAN.

Check the subinterface status

Output of show ip interface brief with the router subinterfaces up
show ip interface brief

Gig0/0, Gig0/0.10, and Gig0/0.20 should all show status up and protocol up. If the protocol is still down, check the cable again and make sure the switch port on the other end is already a trunk.

Check the routing table

Connected routing table listing the 192.168.10.0 and 192.168.20.0 networks on the router
show ip route connected

The router now knows 192.168.10.0/24 through Gig0/0.10 and 192.168.20.0/24 through Gig0/0.20. Since both networks are directly connected to the router, it can forward packets between them without any extra routing configuration.

Testing Communication Between VLANs

Ping and tracert from VLAN 10 to VLAN 20

Ping and tracert from PC0 in VLAN 10 reaching PC2 in VLAN 20 through the router

Open the Command Prompt on PC0, which sits in VLAN 10, and run the following commands.

ping 192.168.20.10
tracert 192.168.20.10

The ping to PC2 in VLAN 20 succeeds. The first reply times out because of ARP, and TTL=127 shows that the packet passed through one router. The tracert output confirms the path: the first hop is 192.168.10.1, the router subinterface for VLAN 10, and the second hop goes straight to PC2.

Common Problems and How to Fix Them

The router subinterface protocol is down

The most common cause is that the router cable is plugged into the wrong port, or the switch port facing the router has not been made a trunk yet. Check the port labels in the topology and run show interfaces trunk on the switch.

Ping to the gateway works but ping to the other VLAN fails

Check the default gateway on the destination PC. A PC in VLAN 20 must use 192.168.20.1 as its gateway. Also make sure the number in encapsulation dot1Q matches the VLAN number on the switch.

The message Configuring IP routing on a LAN subinterface is only allowed if that subinterface is already configured appears

This message shows up when you type ip address before encapsulation dot1Q. Enter encapsulation dot1Q first, then the ip address.

At this point PCs in different VLANs can talk to each other through router on a stick. In the next article we will turn this router into a DHCP server for each VLAN, so every PC gets an IP address automatically based on its VLAN. If you run into any other error while trying this, just leave a comment below.

Leave a Comment