Learn / Stage 3: Networking and CCNA / Lesson 3.3

$ lesson 3.3 --track ccna --domain access

Switching Fundamentals and Secure Device Access

A switch quietly decides where every frame goes, and the way you log in to it decides whether an attacker can too. Learn how MAC tables really work, why most Cisco passwords in old configs are not secret at all, and how to lock management down to SSH only.

  • Stage 3 Networking and CCNA
  • Level Beginner to intermediate
  • 60 min
  • 5 sections, quiz, lab

Start the lesson Jump to the lab

By the end of this lesson you can

  • Explain learning, forwarding, filtering, flooding and aging in a MAC table
  • Give a switch a management SVI and default gateway
  • Choose secure password types and explain why type 7 is reversible
  • Configure SSH version 2 only access with local users
  • Decide where CDP and LLDP should run
3.3.01

How a switch learns, forwards, floods and filters

A switch learns source MACs, forwards known destinations out one port, and floods unknown or broadcast frames to every other port in the VLANSW1MAC tablePC1 on Fa0/1aaaa.0001PC2 on Fa0/2aaaa.0002PC3 on Fa0/3aaaa.0003PC4 on Fa0/4aaaa.00041. learns aaaa.0001 is on Fa0/1 (source MAC)2. knows the destination: forwards only to Fa0/33. unknown destination or broadcast: floods (dotted)
Every frame teaches the switch where its source lives. The destination decides where it goes: one port if known, every other port in the VLAN if unknown or broadcast.
  • Learn: the switch records the source MAC of every incoming frame against the port it arrived on.
  • Forward: a known destination MAC goes out only its port. Filter: if the destination is on the same port it came in on, the frame is dropped.
  • Flood: unknown unicast, broadcast (ff:ff:ff:ff:ff:ff, for example ARP requests) and, by default, multicast go out every port in the VLAN except the one they came in on.
  • Age: entries that are not refreshed expire, after 300 seconds by default on Catalyst switches. Many MACs can sit behind one port, for example everything learned through an uplink to another switch.
3.3.02

Managing a switch: SVI, gateway and access methods

A Layer 2 switch does not need an IP address to switch frames. It needs one only so you can manage it remotely. That address lives on a virtual interface, the SVI (switch virtual interface), such as interface vlan 1 or better, a dedicated management VLAN. Because a pure Layer 2 switch does not route, it also needs ip default-gateway to answer admins on other subnets.

SW1(config)#interface vlan 1
SW1(config-if)#ip address 192.168.1.2 255.255.255.0
SW1(config-if)#no shutdown
SW1(config-if)#exit
SW1(config)#ip default-gateway 192.168.1.1
Management access options
MethodEncrypted?Use
Console cablelocal onlyFirst setup and recovery. Protect it with a login.
Telnet (TCP 23)NoNever on production networks.
SSH (TCP 22)YesThe normal way to manage devices.
HTTP / HTTPS web UIonly HTTPSIf you do not use it, turn it off: no ip http server and no ip http secure-server.
TACACS+ / RADIUS (AAA)variesCentral logins and logging for many devices (lesson 3.12).
Cloud managedYes (TLS)Devices managed from a vendor dashboard.
3.3.03

Passwords on Cisco devices: what each type really means

Cisco password types
In the configWhat it isVerdict
enable password cisco (type 0)Plain textNever use
password 7 0822455D0A16 (type 7)Scrambled with a public algorithm, made by service password-encryptionReversible in a second: hides from shoulder surfers only
secret 5 $1$... (type 5)MD5 based hashBetter, but old and fast to crack
secret 8 / secret 9PBKDF2-SHA256 / scrypt hashes on newer IOSBest where your IOS supports them

So: always use enable secret (never enable password), create users with username NAME secret PASSWORD, and still turn on service password-encryption so any remaining line passwords are at least not readable over someone's shoulder. On real IOS 15.3 and later you can choose the strongest hash with enable algorithm-type scrypt secret ...; Packet Tracer support for that is UNVERIFIED.

Type 7 decoder: see why it is not encryption

Paste a type 7 string from a config (the part after password 7). The algorithm and its key are public, so anyone can reverse it. Only paste lab strings, never a real device's.

Plain text:

3.3.04

SSH only: the full recipe

Typing ip ssh version 2 alone does nothing useful. SSH needs all of these, in this order:

  1. A hostname that is not the default (hostname SW1) and a domain name (ip domain-name cyberwithmadhav.lab), because the RSA key is named after both.
  2. An RSA key pair: crypto key generate rsa, then answer the modulus question. Version 2 needs at least 768 bits; 2048 is a sensible modern choice.
  3. ip ssh version 2.
  4. A local user: username netadmin secret ....
  5. VTY lines that use it and refuse Telnet: line vty 0 15, login local, transport input ssh.

Do the whole baseline in the simulator. Passwords here are lab examples; never reuse them anywhere real.

console: Switch (SW1 baseline)

Missions 0/11

    Simplified IOS simulator in your browser. It teaches the commands; Packet Tracer and real gear have many more.
    3.3.05

    CDP and LLDP: useful maps, useful to attackers too

    CDP (Cisco Discovery Protocol) is Cisco proprietary and on by default on Cisco gear. Every 60 seconds each device tells its neighbours its name, model, IOS version, port and management address. LLDP (IEEE 802.1AB) does the same across vendors and is usually off on Cisco IOS until you type lldp run.

    SW1#show cdp neighbors
    Device ID        Local Intrfce   Holdtme    Capability   Platform    Port ID
    SW2              Gig 0/1         150        S I          2960        Gig 0/1
    R1               Fas 0/24        140        R B S I      ISR4331     Gig 0/0/0
    SW1#show cdp neighbors detail
    SW1(config)#lldp run
    SW1#show lldp neighbors

    Flashcards: do you remember?

    Tap a card to flip it. Try to answer in your head first; recalling is what makes it stick.

    Quick quiz

    Instant feedback on every answer. Score 70% or more to pass this lesson's quiz.

    Q1A switch receives a frame for a MAC it has never seen. What does it do?

    Q2Which line is safest?

    Q3You typed ip ssh version 2 and SSH still fails. Most likely missing?

    Q4Why add no cdp enable on user ports?

    Q5An attacker fills the MAC table with fake addresses. Which feature stops it?

    Q6What does service password-encryption really protect against?

    0 / 6

    Hands-on lab

    Cisco Packet Tracer lab40 minutessimulated network

    Packet Tracer lab 3.3: baseline hardening and a MAC table study

    You need: Cisco Packet Tracer (free with a Cisco Networking Academy account; version 9.0.1 was the current download on the NetAcad Resource Hub when this lesson was written). Devices: 2 x 2960-24TT, 1 x ISR4331, 5 x PC-PT. Everything stays in VLAN 1 for now; VLANs arrive in lesson 3.4.

    Topology and addressing

    Lab 3.3 topology: SW1 and SW2 joined on Gi0/1, R1 on SW1 Fa0/24, all in 192.168.1.0/24Fa0/1Fa0/2Fa0/3Gi0/1Gi0/1Fa0/1Fa0/2Fa0/24Gi0/0/0PC1.11PC2.12Admin-PC.50SW1VLAN 1 .2SW2VLAN 1 .3PC3.13PC4.14R1.1
    PC1, PC2 and Admin-PC on SW1; PC3 and PC4 on SW2; SW1 Gi0/1 to SW2 Gi0/1; R1 Gi0/0/0 to SW1 Fa0/24.
    Addressing table
    DeviceInterfaceIPv4 address / prefixDefault gateway or note
    R1Gi0/0/0192.168.1.1/24
    SW1VLAN 1192.168.1.2/24gw 192.168.1.1
    SW2VLAN 1192.168.1.3/24gw 192.168.1.1
    PC1 to PC4Fa0192.168.1.11 to .14/24gw 192.168.1.1
    Admin-PCFa0192.168.1.50/24gw 192.168.1.1
    1. Watch the MAC table fill

      SW1#clear mac address-table dynamic
      SW1#show mac address-table
      ! ping PC3 from PC1, then look again
      SW1#show mac address-table

      PC3 and PC4 appear against Gi0/1: many MACs behind one port.

    2. Baseline SW1 (repeat on SW2 and R1 with their own names and addresses)

      SW1(config)#hostname SW1
      SW1(config)#no ip domain-lookup
      SW1(config)#enable secret Cwm#Enable2026
      SW1(config)#service password-encryption
      SW1(config)#banner motd # Authorised access only. Activity is logged. #
      SW1(config)#username netadmin secret Cwm#Admin2026
      SW1(config)#line console 0
      SW1(config-line)#login local
      SW1(config-line)#exec-timeout 5 0
      SW1(config-line)#exit
      SW1(config)#interface vlan 1
      SW1(config-if)#ip address 192.168.1.2 255.255.255.0
      SW1(config-if)#no shutdown
      SW1(config-if)#exit
      SW1(config)#ip default-gateway 192.168.1.1
    3. SSH only

      SW1(config)#ip domain-name cyberwithmadhav.lab
      SW1(config)#crypto key generate rsa
      How many bits in the modulus [512]: 2048
      SW1(config)#ip ssh version 2
      SW1(config)#line vty 0 15
      SW1(config-line)#login local
      SW1(config-line)#transport input ssh
    4. Test from Admin-PC

      In Admin-PC's Command Prompt: ssh -l netadmin 192.168.1.2 should log in. Then telnet 192.168.1.2 should be refused or closed.

    5. Neighbours and unused ports

      SW1#show cdp neighbors
      SW1(config)#lldp run
      SW1#show lldp neighbors
      SW1(config)#interface range Fa0/1 - 3
      SW1(config-if-range)#no cdp enable
      SW1(config-if-range)#interface range Fa0/4 - 23
      SW1(config-if-range)#shutdown
    6. Verify and save

      SW1#show ip ssh
      SW1#show ssh
      SW1#show running-config | section line vty
      SW1#show interfaces status
      SW1#copy running-config startup-config

    You are done when: SSH from Admin-PC works and Telnet fails, show ip ssh reports version 2.0, unused ports show disabled, and the MAC table shows PC3 and PC4 behind Gi0/1.

    Packet Tracer limits and notes

    • Some Packet Tracer images accept only line vty 0 15 on switches and line vty 0 4 on some routers. Use what the device accepts. UNVERIFIED for every model.
    • An RSA modulus of 2048 is accepted by recent Packet Tracer versions in common lab guides, but this is UNVERIFIED for every image. If rejected, use the largest value offered (at least 1024).
    • LLDP on Packet Tracer's 2960 and ISR models: UNVERIFIED for every build. login block-for exists in IOS; Packet Tracer support UNVERIFIED.
    • enable algorithm-type scrypt secret (type 9) is real IOS; Packet Tracer support UNVERIFIED.

    Download the lab checklist (.txt) Print it or keep it open beside Packet Tracer.

    Key takeaways

    • Switches learn from source MACs and flood the unknown.
    • Management needs an SVI and, on a Layer 2 switch, a default gateway.
    • enable secret and username secret; type 7 is not encryption.
    • SSH needs hostname, domain, keys, a user and transport input ssh.
    • CDP and LLDP belong on infrastructure links, not user ports.

    Finished the sections, quiz and lab? Mark the lesson complete. Progress is saved only in this browser.