4.2.7 Packet Tracer – Configure Router-on-a-Stick Inter-VLAN Routing (Instructions Answer)

4.2.7 Packet Tracer - Configure Router-on-a-Stick Inter-VLAN Routing (Instructor Version)

Addressing Table

Device Interface IPv4 Address Subnet Mask Default Gateway
R1 G0/0.10 172.17.10.1 255.255.255.0 N/A
G0/0.30 172.17.30.1 255.255.255.0
PC1 NIC 172.17.10.10 255.255.255.0 172.17.10.1
PC3 NIC 172.17.30.10 255.255.255.0 172.17.30.1

Objectives

  • Part 1: Add VLANs to a Switch
  • Part 2: Configure Subinterfaces
  • Part 3: Test Connectivity with Inter-VLAN Routing

Scenario

In this activity, you will configure VLANs and inter-VLAN routing. You will then enable trunk interfaces and verify connectivity between VLANs.

Instructions

Part 1: Add VLANs to a Switch

Step 1: Create VLANs on S1.

Create VLAN 10 and VLAN 30 on S1.

S1(config)#vlan 10
S1(config-vlan)#vlan 30
Step 2: Assign VLANs to ports.

a. Configure interfaces F0/6 and F0/11 as access ports and assign VLANs.

  • Assign the port connected to PC1 to VLAN 10.
  • Assign the port connected to PC3 to VLAN 30.
S1(config)#interface f0/11
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 10
S1(config-if)#interface f0/6
S1(config-if)#switchport mod access
S1(config-if)#switchport access vlan 30

b. Issue the show vlan brief command to verify VLAN configuration.

S1# show vlan brief
VLAN  Name                             Status    Ports
----  -------------------------------- --------- -------------------------------
1     default                          active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                 Fa0/5, Fa0/7, Fa0/8, Fa0/9
                                                 Fa0/10, Fa0/12, Fa0/13, Fa0/14
                                                 Fa0/15, Fa0/16, Fa0/17, Fa0/18
                                                 Fa0/19, Fa0/20, Fa0/21, Fa0/22
                                                 Fa0/23, Fa0/24, Gig0/1, Gig0/2
10    VLAN0010                         active    Fa0/11
30    VLAN0030                         active    Fa0/6
1002  fddi-default                     active
1003  token-ring-default               active
1004  fddinet-default                  active
1005  trnet-default                    active
Step 3: Test connectivity between PC1 and PC3.

From PC1, ping PC3.

Were the pings successful? Why did you get this result?

The pings were not successful. The PCs are on different IP networks and require a router or a Layer 3 switch to provide communication between them.

Part 2: Configure Subinterfaces

Step 1: Configure subinterfaces on R1 using the 802.1Q encapsulation.

a. Create the subinterface G0/0.10.

  • Set the encapsulation type to 802.1Q and assign VLAN 10 to the subinterface.
  • Refer to the Address Table and assign the correct IP address to the subinterface.
R1(config)# int g0/0.10
R1(config-subif)# encapsulation dot1Q 10
R1(config-subif)# ip address 172.17.10.1 255.255.255.0

b. Repeat for the G0/0.30 subinterface.

R1(config-subif)#int g0/0.30
R1(config-subif)#encapsulation dot1Q 30
R1(config-subif)#ip address 172.17.30.1 255.255.255.0
Step 2: Verify Configuration.

a. Use the show ip interface brief command to verify subinterface configuration. Both subinterfaces are down. Subinterfaces are virtual interfaces that are associated with a physical interface. Therefore, in order to enable subinterfaces, you must enable the physical interface that they are associated with.

R1(config)#interface g0/0
R1(config-if)#no shutdown

b. Enable the G0/0 interface. Verify that the subinterfaces are now active.

Part 3: Test Connectivity with Inter-VLAN Routing

Step 1: Ping between PC1 and PC3.

From PC1, ping PC3. The pings should still fail. Explain.

The switch is not yet configured with a trunk port that is connected to the router.

Step 2: Enable trunking.

a. On S1, issue the show vlan command.

What VLAN is G0/1 assigned to? VLAN 1

b. Because the router was configured with multiple subinterfaces assigned to different VLANs, the switch port connecting to the router must be configured as a trunk. Enable trunking on interface G0/1.

S1(config)#int g0/1
S1(config-if)#switchport mode trunk

How can you determine that the interface is a trunk port using the show vlan command?

The interface is no longer listed in the command output.

c. Issue the show interface trunk command to verify that the interface is configured as a trunk.

S1#show int trunk
Port        Mode         Encapsulation  Status        Native vlan
Gig0/1      on           802.1q         trunking      1

Port        Vlans allowed on trunk
Gig0/1      1-1005

Port        Vlans allowed and active in management domain
Gig0/1      1,10,30

Port        Vlans in spanning tree forwarding state and not pruned
Gig0/1      1,10,30
Step 3: Test Connectivity

If the configurations are correct, PC1 and PC3 should be able to ping their default gateways and each other.

What addresses do PC1 and PC3 use as their default gateway addresses?

They use the address of the subinterface.

Answer scripts & Download PDF & PKA file:

Switch S1

! ==============================================================
!--- 4.2.7 Packet Tracer - Configure Router-on-a-Stick Inter-VLAN Routing
!--- ANSWER SCRIPT FOR SWITCH S1
!--- Usage: from the console or a Telnet/SSH session to S1, enter privileged EXEC mode with "enable", then paste this whole file. Every line beginning with "!" is a comment; IOS ignores it, so pasting a comment by accident is harmless.
!--- S1 starts with no VLANs beyond the default. This script creates VLAN 10 and VLAN 30, assigns the access ports facing PC1 and PC3, and later trunks the uplink to R1 (G0/1) so the router can route between the two VLANs.
! ==============================================================

enable
configure terminal

! --------------------------------------------------------------
!--- Part 1, Step 1: Create VLANs on S1
! --------------------------------------------------------------

!--- Create the two VLANs used in this activity; the lab does not require custom names, so they keep their default VLAN0010 / VLAN0030 names.
vlan 10
vlan 30

! --------------------------------------------------------------
!--- Part 1, Step 2: Assign VLANs to ports
! --------------------------------------------------------------

!--- F0/11 faces PC1 (VLAN 10) and F0/6 faces PC3 (VLAN 30 - see the naming note in the discrepancy summary). Both become access ports in their respective VLAN.
interface FastEthernet0/11
 switchport mode access
 switchport access vlan 10

interface FastEthernet0/6
 switchport mode access
 switchport access vlan 30

! --------------------------------------------------------------
!--- Part 3, Step 2: Enable trunking on the uplink to R1
! --------------------------------------------------------------

!--- G0/1 must carry both VLAN 10 and VLAN 30 to R1's subinterfaces, so it becomes a trunk. Before this command "show vlan" lists G0/1 under VLAN 1; afterwards the interface drops out of that per-VLAN listing entirely (trunk ports aren't shown there).
interface GigabitEthernet0/1
 switchport mode trunk

end

! --------------------------------------------------------------
!--- Operational habit (not explicitly required by this lab): save to NVRAM. (Press Enter when prompted for the destination filename.)
! --------------------------------------------------------------
copy running-config startup-config

! ==============================================================
!--- Verification (Parts 1-3, from S1 and from the PCs):
!---   S1# show vlan brief         -> VLAN 10 shows Fa0/11, VLAN 30 shows Fa0/6
!---   S1# show vlan               -> G0/1 no longer appears under any VLAN once trunked
!---   S1# show interfaces trunk   -> G0/1 trunking, allowed VLANs 10, 30
!---   From PC1, ping 172.17.10.1  -> success (default gateway)
!---   From PC3, ping 172.17.30.1  -> success (default gateway)
!---   From PC1, ping PC3          -> fails until R1's subinterfaces are also configured and up; succeeds once the whole topology is in place
! ==============================================================

Router R1

! ==============================================================
!--- 4.2.7 Packet Tracer - Configure Router-on-a-Stick Inter-VLAN Routing
!--- ANSWER SCRIPT FOR ROUTER R1
!--- Usage: from the console or a Telnet/SSH session to R1, enter privileged EXEC mode with "enable", then paste this whole file. Every line beginning with "!" is a comment; IOS ignores it, so pasting a comment by accident is harmless.
!--- R1's G0/0 physical interface starts shut down and has no subinterfaces yet. This script builds the two 802.1Q subinterfaces for VLAN 10 and VLAN 30 (the "router-on-a-stick") and brings the physical interface up so both come online.
! ==============================================================

enable
configure terminal

! --------------------------------------------------------------
!--- Part 2, Step 1: Configure subinterfaces on R1 using 802.1Q encapsulation
! --------------------------------------------------------------

!--- Subinterface .10 tags traffic for VLAN 10 and takes the gateway address PC1 expects, straight from the Addressing Table.
interface GigabitEthernet0/0.10
 encapsulation dot1Q 10
 ip address 172.17.10.1 255.255.255.0

!--- Subinterface .30 tags traffic for VLAN 30 and takes the gateway address PC3 expects.
interface GigabitEthernet0/0.30
 encapsulation dot1Q 30
 ip address 172.17.30.1 255.255.255.0

! --------------------------------------------------------------
!--- Part 2, Step 2: Enable the physical interface so the subinterfaces come up
! --------------------------------------------------------------

!--- Subinterfaces are virtual and inherit their up/down state from the parent physical interface - before this command "show ip interface brief" shows both G0/0.10 and G0/0.30 as down. A single "no shutdown" on the physical G0/0 brings both subinterfaces up together; no per-subinterface shutdown toggling is needed.
interface GigabitEthernet0/0
 no shutdown

end

! --------------------------------------------------------------
!--- Operational habit (not explicitly required by this lab): save to NVRAM. (Press Enter when prompted for the destination filename.)
! --------------------------------------------------------------
copy running-config startup-config

! ==============================================================
!--- Verification (Parts 2-3, from R1 and from the PCs):
!---   R1# show ip interface brief -> G0/0, G0/0.10, G0/0.30 all up/up
!---   From PC1, ping 172.17.10.1  -> success (default gateway)
!---   From PC3, ping 172.17.30.1  -> success (default gateway)
!---   From PC1, ping PC3          -> success once S1's G0/1 is also trunked
! ==============================================================

Download Packet Tracer (.pka) file:

Subscribe
Notify of
guest

7 Corrections & Clarifications