! Pcornel Finals - Skills Exam / L2 Switch ! Content version: 1.1-draft ! REFERENCE ONLY: replace every placeholder and choose the correct device/task-specific variants. ! Basic configuration is active text; all alternative sections below are commented references. ! Use Copy Section for a single relevant variant. Do not paste this entire file blindly. ! Basic configuration enable configure terminal hostname [HOSTNAME] ip domain-name [DOMAIN-NAME] enable secret [ENABLE-SECRET] username [USERNAME] privilege 15 secret [PASSWORD] line console 0 login local logging synchronous exit line vty 0 [VTY-LAST] login local exit ! no ip routing (only on supported Layer 2 devices; do not disable routing on L3 devices) end ! VLAN / Create a VLAN ! enable ! configure terminal ! vlan [VLAN-ID] ! name [VLAN-NAME] ! exit ! end ! VLAN / Assign an access interface ! enable ! configure terminal ! vlan [VLAN-ID] ! name [VLAN-NAME] ! exit ! interface [INTERFACE] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! no shutdown ! exit ! end ! VLAN / Layer 2 management SVI ! Use the default gateway only when the device is not routing IP. ! enable ! configure terminal ! vlan [VLAN-ID] ! name [VLAN-NAME] ! exit ! interface vlan [VLAN-ID] ! ip address [IP-ADDRESS] [SUBNET-MASK] ! no shutdown ! exit ! ip default-gateway [NEXT-HOP] ! end ! VLAN / Voice VLAN (only if requested) ! enable ! configure terminal ! vlan [VLAN-ID] ! exit ! vlan [VOICE-VLAN] ! exit ! interface [INTERFACE] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! switchport voice vlan [VOICE-VLAN] ! no shutdown ! exit ! end ! 802.1Q Trunking / Static 802.1Q trunk ! On a switch with fixed 802.1Q encapsulation, omit the encapsulation selection command if it is not supported. Match native VLAN and allowed VLANs at both ends. ! enable ! configure terminal ! interface [INTERFACE] ! switchport ! switchport trunk encapsulation dot1q ! switchport mode trunk ! switchport trunk native vlan [NATIVE-VLAN] ! switchport trunk allowed vlan [ALLOWED-VLANS] ! no shutdown ! exit ! end ! DTP / Dynamic desirable / auto ! On a switch with fixed 802.1Q encapsulation, omit the encapsulation selection command if it is not supported. Match native VLAN and allowed VLANs at both ends. ! enable ! configure terminal ! interface [INTERFACE] ! switchport ! switchport trunk encapsulation dot1q ! switchport mode dynamic desirable ! switchport trunk native vlan [NATIVE-VLAN] ! switchport trunk allowed vlan [ALLOWED-VLANS] ! no shutdown ! exit ! end ! DTP / Dynamic desirable / desirable ! On a switch with fixed 802.1Q encapsulation, omit the encapsulation selection command if it is not supported. Match native VLAN and allowed VLANs at both ends. ! enable ! configure terminal ! interface [INTERFACE] ! switchport ! switchport trunk encapsulation dot1q ! switchport mode dynamic desirable ! switchport trunk native vlan [NATIVE-VLAN] ! switchport trunk allowed vlan [ALLOWED-VLANS] ! no shutdown ! exit ! end ! DTP / Static trunk without DTP ! On a switch with fixed 802.1Q encapsulation, omit the encapsulation selection command if it is not supported. Match native VLAN and allowed VLANs at both ends. ! enable ! configure terminal ! interface [INTERFACE] ! switchport ! switchport trunk encapsulation dot1q ! switchport mode trunk ! switchport trunk native vlan [NATIVE-VLAN] ! switchport trunk allowed vlan [ALLOWED-VLANS] ! no shutdown ! switchport nonegotiate ! exit ! end ! EtherChannel / TRUNK – LACP active / active ! On a switch with fixed 802.1Q encapsulation, omit the encapsulation selection command if it is not supported. Match native VLAN and allowed VLANs at both ends. ! enable ! configure terminal ! interface range [INTERFACE-RANGE] ! switchport ! switchport trunk encapsulation dot1q ! switchport mode trunk ! switchport trunk native vlan [NATIVE-VLAN] ! switchport trunk allowed vlan [ALLOWED-VLANS] ! channel-group [CHANNEL-GROUP] mode active ! no shutdown ! exit ! interface port-channel [CHANNEL-GROUP] ! switchport ! switchport trunk encapsulation dot1q ! switchport mode trunk ! switchport trunk native vlan [NATIVE-VLAN] ! switchport trunk allowed vlan [ALLOWED-VLANS] ! no shutdown ! exit ! end ! EtherChannel / TRUNK – LACP active / passive ! On a switch with fixed 802.1Q encapsulation, omit the encapsulation selection command if it is not supported. Match native VLAN and allowed VLANs at both ends. ! enable ! configure terminal ! interface range [INTERFACE-RANGE] ! switchport ! switchport trunk encapsulation dot1q ! switchport mode trunk ! switchport trunk native vlan [NATIVE-VLAN] ! switchport trunk allowed vlan [ALLOWED-VLANS] ! channel-group [CHANNEL-GROUP] mode active ! no shutdown ! exit ! interface port-channel [CHANNEL-GROUP] ! switchport ! switchport trunk encapsulation dot1q ! switchport mode trunk ! switchport trunk native vlan [NATIVE-VLAN] ! switchport trunk allowed vlan [ALLOWED-VLANS] ! no shutdown ! exit ! end ! EtherChannel / TRUNK – PAgP desirable / desirable ! On a switch with fixed 802.1Q encapsulation, omit the encapsulation selection command if it is not supported. Match native VLAN and allowed VLANs at both ends. ! PAgP support is platform-dependent. ! enable ! configure terminal ! interface range [INTERFACE-RANGE] ! switchport ! switchport trunk encapsulation dot1q ! switchport mode trunk ! switchport trunk native vlan [NATIVE-VLAN] ! switchport trunk allowed vlan [ALLOWED-VLANS] ! channel-group [CHANNEL-GROUP] mode desirable ! no shutdown ! exit ! interface port-channel [CHANNEL-GROUP] ! switchport ! switchport trunk encapsulation dot1q ! switchport mode trunk ! switchport trunk native vlan [NATIVE-VLAN] ! switchport trunk allowed vlan [ALLOWED-VLANS] ! no shutdown ! exit ! end ! EtherChannel / TRUNK – PAgP desirable / auto ! On a switch with fixed 802.1Q encapsulation, omit the encapsulation selection command if it is not supported. Match native VLAN and allowed VLANs at both ends. ! PAgP support is platform-dependent. ! enable ! configure terminal ! interface range [INTERFACE-RANGE] ! switchport ! switchport trunk encapsulation dot1q ! switchport mode trunk ! switchport trunk native vlan [NATIVE-VLAN] ! switchport trunk allowed vlan [ALLOWED-VLANS] ! channel-group [CHANNEL-GROUP] mode desirable ! no shutdown ! exit ! interface port-channel [CHANNEL-GROUP] ! switchport ! switchport trunk encapsulation dot1q ! switchport mode trunk ! switchport trunk native vlan [NATIVE-VLAN] ! switchport trunk allowed vlan [ALLOWED-VLANS] ! no shutdown ! exit ! end ! EtherChannel / TRUNK – Static on / on ! On a switch with fixed 802.1Q encapsulation, omit the encapsulation selection command if it is not supported. Match native VLAN and allowed VLANs at both ends. ! Both endpoints must be explicitly configured on; incorrect static bundling can cause loops or loss of traffic. ! enable ! configure terminal ! interface range [INTERFACE-RANGE] ! switchport ! switchport trunk encapsulation dot1q ! switchport mode trunk ! switchport trunk native vlan [NATIVE-VLAN] ! switchport trunk allowed vlan [ALLOWED-VLANS] ! channel-group [CHANNEL-GROUP] mode on ! no shutdown ! exit ! interface port-channel [CHANNEL-GROUP] ! switchport ! switchport trunk encapsulation dot1q ! switchport mode trunk ! switchport trunk native vlan [NATIVE-VLAN] ! switchport trunk allowed vlan [ALLOWED-VLANS] ! no shutdown ! exit ! end ! EtherChannel / ACCESS – LACP active / active ! enable ! configure terminal ! interface range [INTERFACE-RANGE] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! channel-group [CHANNEL-GROUP] mode active ! no shutdown ! exit ! interface port-channel [CHANNEL-GROUP] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! no shutdown ! exit ! end ! EtherChannel / ACCESS – LACP active / passive ! enable ! configure terminal ! interface range [INTERFACE-RANGE] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! channel-group [CHANNEL-GROUP] mode active ! no shutdown ! exit ! interface port-channel [CHANNEL-GROUP] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! no shutdown ! exit ! end ! EtherChannel / ACCESS – PAgP desirable / desirable ! PAgP support is platform-dependent. ! enable ! configure terminal ! interface range [INTERFACE-RANGE] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! channel-group [CHANNEL-GROUP] mode desirable ! no shutdown ! exit ! interface port-channel [CHANNEL-GROUP] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! no shutdown ! exit ! end ! EtherChannel / ACCESS – PAgP desirable / auto ! PAgP support is platform-dependent. ! enable ! configure terminal ! interface range [INTERFACE-RANGE] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! channel-group [CHANNEL-GROUP] mode desirable ! no shutdown ! exit ! interface port-channel [CHANNEL-GROUP] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! no shutdown ! exit ! end ! EtherChannel / ACCESS – Static on / on ! Both endpoints must be explicitly configured on; incorrect static bundling can cause loops or loss of traffic. ! enable ! configure terminal ! interface range [INTERFACE-RANGE] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! channel-group [CHANNEL-GROUP] mode on ! no shutdown ! exit ! interface port-channel [CHANNEL-GROUP] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! no shutdown ! exit ! end ! STP / Rapid PVST+ ! enable ! configure terminal ! spanning-tree mode rapid-pvst ! end ! STP / PVST+ ! enable ! configure terminal ! spanning-tree mode pvst ! end ! STP / Root primary ! enable ! configure terminal ! spanning-tree vlan [VLAN-ID] root primary ! end ! STP / Root secondary ! enable ! configure terminal ! spanning-tree vlan [VLAN-ID] root secondary ! end ! STP / Explicit bridge priority ! Use an allowed multiple of 4096; a lower bridge ID is preferred. ! enable ! configure terminal ! spanning-tree vlan [VLAN-ID] priority [BRIDGE-PRIORITY] ! end ! STP / Explicit port cost ! enable ! configure terminal ! interface [INTERFACE] ! spanning-tree vlan [VLAN-ID] cost [STP-COST] ! exit ! end ! STP / Explicit port priority ! Port priority is an additional tie-breaker; select a supported increment. ! enable ! configure terminal ! interface [INTERFACE] ! spanning-tree vlan [VLAN-ID] port-priority [PORT-PRIORITY] ! exit ! end ! PortFast / Access edge port ! enable ! configure terminal ! interface [INTERFACE] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! spanning-tree portfast ! no shutdown ! exit ! end ! PortFast / Default on access edge ports ! Review all affected non-trunk interfaces first. ! enable ! configure terminal ! spanning-tree portfast default ! end ! PortFast / Trunk to an edge endpoint ! On a switch with fixed 802.1Q encapsulation, omit the encapsulation selection command if it is not supported. Match native VLAN and allowed VLANs at both ends. ! Use only for an explicitly intended edge trunk, never a normal switch-to-switch trunk. ! enable ! configure terminal ! interface [INTERFACE] ! switchport ! switchport trunk encapsulation dot1q ! switchport mode trunk ! switchport trunk native vlan [NATIVE-VLAN] ! switchport trunk allowed vlan [ALLOWED-VLANS] ! no shutdown ! spanning-tree portfast trunk ! exit ! end ! BPDU Guard / Interface BPDU Guard ! enable ! configure terminal ! interface [INTERFACE] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! spanning-tree portfast ! spanning-tree bpduguard enable ! no shutdown ! exit ! end ! BPDU Guard / Global PortFast BPDU Guard ! enable ! configure terminal ! spanning-tree portfast default ! spanning-tree portfast bpduguard default ! end ! BPDU Guard / Optional timed recovery ! Only enable automatic recovery if requested. A persistent BPDU source can repeatedly disable the port. ! enable ! configure terminal ! errdisable recovery cause bpduguard ! errdisable recovery interval [RECOVERY-SECONDS] ! end ! IPv4 and IPv6 Addressing / L2 switch IPv6 management SVI ! This is host management, not IPv6 routing. Use a platform that supports IPv6 host/SVI functions. Off-link traffic requires a learned IPv6 default router, normally through Router Advertisements. ! Check the exact model, IOS release, feature image and show sdm prefer before IPv6 management. On supported Catalyst 2960 LAN Base models, select sdm prefer dual-ipv4-and-ipv6 default in global configuration, then end, save the configuration and schedule a reload; verify the active template with show sdm prefer after reboot. Reload interrupts service and is a separate preparation step, not part of this script. ! Do not apply the 2960 template requirement to every switch: Cisco documents that the dual template is not required on 2960-S and is unavailable on 2960 LAN Lite. Confirm support in the matching platform guide. ! enable ! configure terminal ! vlan [VLAN-ID] ! name [VLAN-NAME] ! exit ! interface vlan [VLAN-ID] ! ipv6 address [IPV6-ADDRESS]/[PREFIX-LENGTH] ! no shutdown ! exit ! end ! IPv4 and IPv6 Addressing / L2 switch IPv4 management SVI ! Use ip default-gateway on a nonrouting switch. ! enable ! configure terminal ! vlan [VLAN-ID] ! name [VLAN-NAME] ! exit ! interface vlan [VLAN-ID] ! ip address [IP-ADDRESS] [SUBNET-MASK] ! no shutdown ! exit ! ip default-gateway [NEXT-HOP] ! end ! IPv4 and IPv6 Addressing / L2 switch IPv6 management SVI using SLAAC ! Requires IPv6 host/SVI support for the exact model, IOS release and feature image. Apply the same model-dependent SDM preparation described for the static IPv6 management SVI; do not insert template changes or reload into a Golden Script. ! ipv6 address autoconfig is an interface command for host SLAAC. The management SVI must be up/up with an active VLAN member; a router on that VLAN must advertise a /64 prefix with autonomous addressing enabled. Off-link management also needs a usable default router advertised by RA. A static IPv6 address alone does not provide a default router; ip default-gateway is IPv4 only. Do not enable ipv6 unicast-routing for this L2 host example. ! enable ! configure terminal ! vlan [VLAN-ID] ! exit ! interface vlan [VLAN-ID] ! ipv6 address autoconfig ! no shutdown ! exit ! end ! Port Security / Sticky MAC – protect ! enable ! configure terminal ! interface [INTERFACE] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! switchport port-security ! switchport port-security maximum [MAX-MAC] ! switchport port-security mac-address sticky ! switchport port-security violation protect ! no shutdown ! exit ! end ! Port Security / Sticky MAC – restrict ! enable ! configure terminal ! interface [INTERFACE] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! switchport port-security ! switchport port-security maximum [MAX-MAC] ! switchport port-security mac-address sticky ! switchport port-security violation restrict ! no shutdown ! exit ! end ! Port Security / Sticky MAC – shutdown ! enable ! configure terminal ! interface [INTERFACE] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! switchport port-security ! switchport port-security maximum [MAX-MAC] ! switchport port-security mac-address sticky ! switchport port-security violation shutdown ! no shutdown ! exit ! end ! Port Security / Statically allowed MAC ! enable ! configure terminal ! interface [INTERFACE] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! switchport port-security ! switchport port-security maximum [MAX-MAC] ! switchport port-security mac-address [MAC-ADDRESS] ! no shutdown ! exit ! end ! Port Security / Dynamic secure MAC learning ! enable ! configure terminal ! interface [INTERFACE] ! switchport ! switchport mode access ! switchport access vlan [VLAN-ID] ! switchport port-security ! switchport port-security maximum [MAX-MAC] ! no shutdown ! exit ! end ! Password Hashing Algorithms / Generate type 9 (scrypt) local secret ! enable ! configure terminal ! username [USERNAME] algorithm-type scrypt secret [PASSWORD] ! enable algorithm-type scrypt secret [ENABLE-SECRET] ! end ! Password Hashing Algorithms / Generate type 8 (PBKDF2-SHA256) secret ! enable ! configure terminal ! username [USERNAME] algorithm-type sha256 secret [PASSWORD] ! enable algorithm-type sha256 secret [ENABLE-SECRET] ! end ! Password Hashing Algorithms / Generate legacy type 5 (MD5) secret ! Legacy exam compatibility only; modern platforms may reject or convert type 5. ! enable ! configure terminal ! username [USERNAME] algorithm-type md5 secret [PASSWORD] ! enable algorithm-type md5 secret [ENABLE-SECRET] ! end ! Password Hashing Algorithms / Explicit type 0 line password ! Plaintext input and storage unless password encryption is enabled. ! enable ! configure terminal ! line console 0 ! password 0 [PASSWORD] ! login ! exit ! end ! Password Hashing Algorithms / Legacy service password encryption ! Obfuscates applicable plaintext line passwords as type 7. It does not create a strong hash. ! enable ! configure terminal ! service password-encryption ! end ! Password Hashing Algorithms / Import an already encoded type 9 secret ! The value must already be a valid encoded type 9 secret, not a plaintext password. ! enable ! configure terminal ! username [USERNAME] secret 9 [ENCODED-TYPE9-SECRET] ! end ! Local User Authentication / Local user with secret ! enable ! configure terminal ! username [USERNAME] privilege [PRIVILEGE] secret [PASSWORD] ! end ! Local User Authentication / Console local authentication ! enable ! configure terminal ! username [USERNAME] privilege 15 secret [PASSWORD] ! line console 0 ! login local ! exit ! end ! Local User Authentication / VTY local authentication ! enable ! configure terminal ! username [USERNAME] privilege 15 secret [PASSWORD] ! line vty 0 [VTY-LAST] ! login local ! exit ! end ! SSH / SSH version 2 with local authentication ! Key generation may prompt or reject replacement if a key already exists. Do not overwrite an existing working key unnecessarily. ! enable ! configure terminal ! hostname [HOSTNAME] ! ip domain-name [DOMAIN-NAME] ! username [USERNAME] privilege 15 secret [PASSWORD] ! crypto key generate rsa modulus 2048 ! ip ssh version 2 ! line vty 0 [VTY-LAST] ! login local ! transport input ssh ! exit ! end ! SSH / Optional SSH and VTY timeouts ! enable ! configure terminal ! ip ssh time-out [SSH-TIMEOUT-SECONDS] ! ip ssh authentication-retries [RETRY-COUNT] ! line vty 0 [VTY-LAST] ! exec-timeout [IDLE-MINUTES] [IDLE-SECONDS] ! exit ! end ! Telnet / Telnet with local user ! enable ! configure terminal ! username [USERNAME] privilege 15 secret [PASSWORD] ! line vty 0 [VTY-LAST] ! login local ! transport input telnet ! exit ! end ! Telnet / Telnet with line password ! enable ! configure terminal ! line vty 0 [VTY-LAST] ! password [PASSWORD] ! login ! transport input telnet ! exit ! end ! Telnet / Allow both SSH and Telnet ! SSH prerequisites must already be configured. ! enable ! configure terminal ! line vty 0 [VTY-LAST] ! login local ! transport input ssh telnet ! exit ! end ! Save only after reviewing and verifying the configuration: ! copy running-config startup-config ! Confirm the destination filename if prompted.