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
Devices and cabling
R1·2911
SW1·2960-24TT
PC1, PC2·PC-PT
From
To
Cable
R1Gi0/0
SW1Gi0/1
Straight-through
PC1Fa0
SW1Fa0/1
Straight-through
PC2Fa0
SW1Fa0/2
Straight-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
Device
Interface
Address
Mask
Default gateway
R1
G0/0.10
192.168.10.1
255.255.255.0
—
R1
G0/0.20
192.168.20.1
255.255.255.0
—
PC1
VLAN 10
192.168.10.10
255.255.255.0
192.168.10.1
PC2
VLAN 20
192.168.20.10
255.255.255.0
192.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)
PC1: IP 192.168.10.10, mask 255.255.255.0, gateway 192.168.10.1
PC2: IP 192.168.20.10, mask 255.255.255.0, gateway 192.168.20.1
Tasks
What must end up working. In the app, each one ticks itself off as soon as you get it.
SW1 G0/1 as a trunk
G0/0.10: dot1Q 10 and 192.168.10.1/24
G0/0.20: dot1Q 20 and 192.168.20.1/24
G0/0 up
PC1 reaches its default gateway
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.
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
Setting the IP before encapsulation dot1Q: IOS replies with a warning about subinterfaces without 802.1Q.
Leaving the switch port in access mode: only one VLAN would get through.
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.