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
How a switch learns, forwards, floods and filters
- 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.
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. |
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.
SSH only: the full recipe
Typing ip ssh version 2 alone does nothing useful. SSH needs all of these, in this order:
- 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. - 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. ip ssh version 2.- A local user:
username netadmin secret .... - 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.
Missions 0/11
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 neighborsFlashcards: 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?
Unknown unicast is flooded.
Q2Which line is safest?
enable secret stores a hash; type 7 and plain passwords are reversible.
Q3You typed ip ssh version 2 and SSH still fails. Most likely missing?
Without keys nothing listens; without transport input ssh the VTYs may not accept it.
Q4Why add no cdp enable on user ports?
Reconnaissance risk.
Q5An attacker fills the MAC table with fake addresses. Which feature stops it?
Port security limits learned MACs per port.
Q6What does service password-encryption really protect against?
Type 7 only hides passwords from casual viewing.
Hands-on lab
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
| 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 |
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-tablePC3 and PC4 appear against Gi0/1: many MACs behind one port.
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.1SSH 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 sshTest from Admin-PC
In Admin-PC's Command Prompt:
ssh -l netadmin 192.168.1.2should log in. Thentelnet 192.168.1.2should be refused or closed.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)#shutdownVerify 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 15on switches andline vty 0 4on 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-forexists 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.