Lab 30.
Configuring a Layer 2
                 Switch
Lab Objective:
Learn how to configure layer 2 switches.
Lab Purpose:
Installing, configuring, and troubleshooting layer 2 switches will be part of
your day-to-day routine as a network engineer. In this lab we cover basic
VLAN and trunk configuration. Our two VLANs will use the trunk to
connect. To keep things simple, each switch has only one host per VLAN.
Lab Tool:
Packet Tracer
Lab Topology:
Please use the following topology to complete this lab exercise:
Lab Walkthrough:
Task 1:
Drag two Cisco switches (2960) onto the canvas and attach four PCs as per
the diagram.
Task 2:
Add IP addresses of 172.16.20.2 and .3 to the devices going into VLAN 20.
For the devices in VLAN 30 the IP addresses will be 172.16.30.2 and .3. We
are using VLSM here, so make sure you use a subnet mask of 255.255.255.0.
Here is the configuration for one of the devices:
Task 3:
Remember that all devices will be placed into VLAN1 (the native VLAN) by
default, so host 172.16.20.2 should be able to ping 172.16.20.3. This means
that whenever you install any switch, all devices will be able to reach one
another by default.
When all devices are configured, you will be able to ping devices in the same
network but not across networks, even though they may be connected to the
same VLAN. Here is a ping source from host 172.16.30.3.
This lab isn’t concerned with inter-VLAN routing though, so we will just
focus on connecting hosts in the same VLAN across switches using trunk
links. The ‘show vlan brief’ command demonstrates the fact that all ports are in
the same VLAN.
  Switch#show vlan brief
  VLAN Name Status Ports
  ---- ----------------------- -------- --------------------
  1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
  Fa0/5, Fa0/6, Fa0/7, Fa0/8
  Fa0/9, Fa0/10, Fa0/11, 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
  1002 fddi-default active
  1003 token-ring-default active
  1004 fddinet-default active
  1005 trnet-default active
Task 4:
Create VLAN 20 and 30 on the switches. Assign F0/1 on both switches to
VLAN 20 and F0/2 to VLAN 30. Set the interfaces to access. Here is the
configuration for Switch0; do the same for Switch1.
  Switch#conf t
  Enter configuration commands, one per line. End with CNTL/Z.
  Switch(config)#host Switch0
  Switch0(config)#vlan 20
  Switch0(config-vlan)#vlan 30
  Switch0(config-vlan)#int f0/1
  Switch0(config-if)#switchport mode access
  Switch0(config-if)#switchport access vlan 20
  Switch0(config-if)#int f0/2
  Switch0(config-if)#switchport mode access
  Switch0(config-if)#switchport access vlan 30
  Switch0(config-if)#
Task 5:
When you are done with this part, check the layer 2 settings for the interfaces
with the ‘show interfaces X switchport’ command. We are most interested in the
parts highlighted in bold.
  Switch1#show int f0/1 switchport
  Name: Fa0/1
  Switchport: Enabled
  Administrative Mode: static access
  Operational Mode: static access
  Administrative Trunking Encapsulation: dot1q
  Operational Trunking Encapsulation: native
  Negotiation of Trunking: Off
  Access Mode VLAN: 20 (VLAN0020)
  Trunking Native Mode VLAN: 1 (default)
  Voice VLAN: none
  Administrative private-vlan host-association: none
  Administrative private-vlan mapping: none
  Administrative private-vlan trunk native VLAN: none
  Administrative private-vlan trunk encapsulation: dot1q
  Administrative private-vlan trunk normal VLANs: none
  Administrative private-vlan trunk private VLANs: none
  Operational private-vlan: none
  Trunking VLANs Enabled: All
  Pruning VLANs Enabled: 2-1001
  Capture Mode Disabled
  Capture VLANs Allowed: ALL
  Protected: false
  Unknown unicast blocked: disabled
  Unknown multicast blocked: disabled
  Appliance trust: none
Task 6:
From 172.16.20.2 ping .3. It should fail because there is no trunk link
between Switch0 and Switch1. The link connecting the two will be at the
default setting of VLAN1 and an access port.
  Switch0#show interfaces g0/1 switchport
  Name: Gig0/1
  Switchport: Enabled
  Administrative Mode: dynamic auto
  Operational Mode: static access
  Administrative Trunking Encapsulation: dot1q
  Operational Trunking Encapsulation: native
  Negotiation of Trunking: On
  Access Mode VLAN: 1 (default)
  Trunking Native Mode VLAN: 1 (default)
  Voice VLAN: none
Task 7:
Configure Switch0 interface G0/1 as a trunk. Because the setting for these
models of switches is ‘dynamic auto’ as you can see above, the other end will
respond by becoming a trunk link. ‘Auto’ means it will passively wait to
become a trunk interface.
  Switch0(config)#int g0/1
  Switch0(config-if)#switchport mode trunk
  %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up
  Switch0#show interfaces g0/1 switchport
  Name: Gig0/1
  Switchport: Enabled
  Administrative Mode: trunk
  Operational Mode: trunk
  Administrative Trunking Encapsulation: dot1q
  Operational Trunking Encapsulation: dot1q
  Negotiation of Trunking: On
  Access Mode VLAN: 1 (default)
  Trunking Native Mode VLAN: 1 (default)
  Switch0#show interfaces 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,20,30
  Port Vlans in spanning tree forwarding state and not pruned
  Gig0/1 1,20,30
Task 8:
Finally, ping from 172.16.20.2 to .3. It should be successful.
Note:
There are many features we could go into, but we will be covering more
switching features later in the relevant sections.