← All labs Lab 5 · Packet Tracer

Router-on-a-stick

802.1Q subinterfaces to route between VLANs

Level: Intermediate Time: 30 min Domain 2.0 Network Access

Scenario

PC1 is on VLAN 10 and PC2 on VLAN 20 of the same switch. They're on different networks and need a router to talk, but R1 only has one cable to SW1 (G0/0).

Make SW1's G0/1 a trunk and create one subinterface per VLAN on R1: G0/0.10 with 192.168.10.1/24 and G0/0.20 with 192.168.20.1/24, each with its encapsulation dot1Q. Don't forget to bring up the physical interface.

Topology

R1SW1PC1PC2Gi0/0Gi0/1Fa0Fa0/1Fa0Fa0/2

Devices and cabling

FromToCable
R1 Gi0/0SW1 Gi0/1Straight-through
PC1 Fa0SW1 Fa0/1Straight-through
PC2 Fa0SW1 Fa0/2Straight-through

If in doubt, the automatic connection cable (the lightning bolt) picks the right one. Rule: straight-through between different devices (PC or router to switch) and crossover between alike ones.

Addressing

DeviceInterfaceAddressMaskDefault gateway
R1G0/0.10192.168.10.1255.255.255.0—
R1G0/0.20192.168.20.1255.255.255.0—
PC1VLAN 10192.168.10.10255.255.255.0192.168.10.1
PC2VLAN 20192.168.20.10255.255.255.0192.168.20.1

Starting configuration

In the app this is already done. In Packet Tracer, before you start, enter each device with enable and configure terminal and type (or paste) these lines.

R1hostname R1 no ip domain-lookup
SW1hostname SW1 no ip domain-lookup vlan 10 name VENTAS vlan 20 name RRHH interface fa0/1 switchport mode access switchport access vlan 10 interface fa0/2 switchport mode access switchport access vlan 20

PCs and servers (Desktop › IP Configuration)

Tasks

What must end up working. In the app, each one ticks itself off as soon as you get it.

  1. SW1 G0/1 as a trunk
  2. G0/0.10: dot1Q 10 and 192.168.10.1/24
  3. G0/0.20: dot1Q 20 and 192.168.20.1/24
  4. G0/0 up
  5. PC1 reaches its default gateway
  6. PC1 reaches PC2 (VLAN 10 to VLAN 20)
In Packet Tracer
  • Router to switch and PC to switch, with straight-through cables.
  • First do SW1's starting configuration (VLANs and access ports).
Hints
  • SW1 G0/1 as a trunk: On SW1: interface g0/1 → switchport mode trunk
  • G0/0.10: dot1Q 10 and 192.168.10.1/24: interface g0/0.10 → encapsulation dot1Q 10 → ip address … (encapsulation goes before the IP)
  • G0/0.20: dot1Q 20 and 192.168.20.1/24: interface g0/0.20 → encapsulation dot1Q 20 → ip address 192.168.20.1 255.255.255.0
  • G0/0 up: Subinterfaces depend on the physical one: interface g0/0 → no shutdown
  • PC1 reaches its default gateway: From PC1: ping 192.168.10.1
  • PC1 reaches PC2 (VLAN 10 to VLAN 20): From PC1: ping 192.168.20.10

Step-by-step solution

Try it on your own first: you learn much more by typing the commands yourself.

Show the solution

1Make the port to the router a trunk SW1

Both VLANs travel over that cable, tagged with 802.1Q.

SW1enable configure terminal interface g0/1 switchport mode trunk end

2Create the VLAN 10 subinterface R1

Each subinterface serves one VLAN. Encapsulation goes before the IP: without it, IOS won't accept the address.

R1enable configure terminal interface g0/0.10 encapsulation dot1Q 10 ip address 192.168.10.1 255.255.255.0

3Create the VLAN 20 subinterface R1

R1interface g0/0.20 encapsulation dot1Q 20 ip address 192.168.20.1 255.255.255.0

4Bring up the physical interface R1

Subinterfaces depend on G0/0: if it's shut down, none of them work.

R1interface g0/0 no shutdown end

Verification

G0/0, G0/0.10 and G0/0.20 must show up/up with their addresses.

R1R1#show ip interface brief Interface IP-Address OK? Method Status Protocol GigabitEthernet0/0 unassigned YES unset up up GigabitEthernet0/0.10 192.168.10.1 YES manual up up GigabitEthernet0/0.20 192.168.20.1 YES manual up up GigabitEthernet0/1 unassigned YES unset administratively down down GigabitEthernet0/2 unassigned YES unset administratively down down

PC1 (VLAN 10) reaches PC2 (VLAN 20) through the router. The TTL of 127 gives away the hop.

PC1C:\>ping 192.168.20.10 Pinging 192.168.20.10 with 32 bytes of data: Reply from 192.168.20.10: bytes=32 time<1ms TTL=127 Reply from 192.168.20.10: bytes=32 time<1ms TTL=127 Reply from 192.168.20.10: bytes=32 time<1ms TTL=127 Reply from 192.168.20.10: bytes=32 time<1ms TTL=127 Ping statistics for 192.168.20.10: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms

Common mistakes

Practice this lab on your phone

RoutingLab has this lab with a simulated IOS terminal: abbreviations, ? help, the same error messages and objectives that check themselves. The first two labs are free.

Get RoutingLab