---
title: "Cisco Switching Basics and SSH Hardening | CyberWithMadhav"
description: "Free CCNA lesson: how switches learn, forward and flood, management SVIs, Cisco password types, SSH version 2 only, CDP and LLDP, with a simulator and lab."
url: https://www.cyberwithmadhav.com/learn-ccna-switching-secure-access.html
source_format: markdown rendering of the HTML page
---

[Learn](https://www.cyberwithmadhav.com/learn.html) / [Stage 3: Networking and CCNA](https://www.cyberwithmadhav.com/learn.html#stage-3) / 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

## In this lesson

1. How a switch learns, forwards, floods and filters
2. Managing a switch: SVI, gateway and access methods
3. Passwords on Cisco devices: what each type really means
4. SSH only: the full recipe
5. CDP and LLDP: useful maps, useful to attackers too
6. Flashcards
7. Quick quiz
8. Hands-on lab
9. Key takeaways

## 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

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.

How attackers abuse this

**MAC flooding** (CAM table overflow): a tool sends thousands of frames with random fake source MACs until the table is full. The switch can no longer learn real addresses, floods traffic like a hub, and the attacker's port now sees other people's frames.
Defender move

Port security limits how many MACs a port may learn and shuts or restricts the port when the limit is hit (lesson 3.12). Watch logs for MAC flapping, where the same MAC jumps between ports.

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
```

| Method | Encrypted? | Use |
| --- | --- | --- |
| Console cable | local only | First setup and recovery. Protect it with a login. |
| Telnet (TCP 23) | No | Never on production networks. |
| SSH (TCP 22) | Yes | The normal way to manage devices. |
| HTTP / HTTPS web UI | only HTTPS | If you do not use it, turn it off: `no ip http server` and `no ip http secure-server`. |
| TACACS+ / RADIUS (AAA) | varies | Central logins and logging for many devices (lesson 3.12). |
| Cloud managed | Yes (TLS) | Devices managed from a vendor dashboard. |

Defender move

Keep management on its own VLAN and subnet, reachable only from admin machines, and restrict the VTY lines with an access list (`access-class`, lesson 3.9). Many attacks on network gear start with a management interface that was reachable from everywhere.

3.3.03

## Passwords on Cisco devices: what each type really means

| In the config | What it is | Verdict |
| --- | --- | --- |
| `enable password cisco` (type 0) | Plain text | Never use |
| `password 7 0822455D0A16` (type 7) | Scrambled with a public algorithm, made by `service password-encryption` | Reversible in a second: hides from shoulder surfers only |
| `secret 5 $1$...` (type 5) | MD5 based hash | Better, but old and fast to crack |
| `secret 8` / `secret 9` | PBKDF2-SHA256 / scrypt hashes on newer IOS | Best 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.

Type 7 string

Plain text:
How attackers abuse this

Config files get shared in tickets, emailed to vendors and posted on forums for help. Any type 7 password in them can be decoded instantly, as the widget shows, and weak type 5 hashes can be cracked offline.
Defender move

Treat a config file as a secret. Strip passwords before sharing, prefer AAA with central accounts and MFA (lesson 3.12), and choose long passphrases over short complex ones: length beats complexity rules, never reuse, and use MFA, certificates or biometrics where possible.

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
```
How attackers abuse this

Anyone plugged into a user port receives these advertisements: the switch model, its exact IOS version (handy for finding known vulnerabilities), management IPs and VLAN details. Reconnaissance for free.
Defender move

Keep CDP or LLDP on infrastructure links where they help you, and turn them off on user facing ports: `no cdp enable` per interface (or `no cdp run` globally) and `no lldp transmit` plus `no lldp receive`.

## 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.

### Q1 A switch receives a frame for a MAC it has never seen. What does it do?

### Q2 Which line is safest?

### Q3 You typed `ip ssh version 2` and SSH still fails. Most likely missing?

### Q4 Why add `no cdp enable` on user ports?

### Q5 An attacker fills the MAC table with fake addresses. Which feature stops it?

### Q6 What does `service password-encryption` really protect against?

**0 / 6**

## Hands-on lab

Cisco Packet Tracer lab  40 minutes  simulated 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.

**Simulator lab, zero risk.** This lab runs inside Cisco Packet Tracer, so it touches no real network. Packet Tracer is free with a Cisco Networking Academy account (netacad.com). It simulates a subset of Cisco IOS, so where support for a feature is uncertain we say so instead of promising it works.

#### Topology and addressing

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.

| Device | Interface | IPv4 address / prefix | Default gateway or note |
| --- | --- | --- | --- |
| R1 | Gi0/0/0 | 192.168.1.1/24 |  |
| SW1 | VLAN 1 | 192.168.1.2/24 | gw 192.168.1.1 |
| SW2 | VLAN 1 | 192.168.1.3/24 | gw 192.168.1.1 |
| PC1 to PC4 | Fa0 | 192.168.1.11 to .14/24 | gw 192.168.1.1 |
| Admin-PC | Fa0 | 192.168.1.50/24 | gw 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.  Done
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`  Done
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`  Done
4. Test from Admin-PCIn 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.  Done
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`  Done
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`  Done

**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)](https://www.cyberwithmadhav.com/assets/learn/learn-ccna-switching-secure-access-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.

[Previous 3.2 IP Addressing: IPv4 Subnetting, VLSM, Private Ranges, IPv6 Basics](https://www.cyberwithmadhav.com/learn-ccna-ip-addressing-subnetting.html)[Next 3.4 VLANs and Trunks: 802.1Q, Native VLAN, DTP, Voice VLAN](https://www.cyberwithmadhav.com/learn-ccna-vlans-trunks.html)
