From point A to point B
Point A: You have a new switch with no name, no IP and no passwords, and you know plugging it into the network like that is a risk. You are not sure in what order to configure access, Spanning Tree and VTP. Point B: When you finish you can leave a switch ready: with an identity, encrypted passwords, SSH v2-only access filtered by an ACL, a decided root bridge and a consistent VTP domain. And you know how to verify it with show.
First console access and base configuration
A switch fresh out of the box has no IP address, no passwords and no name of its own. The first cable is always the console cable: from your PC to the device's console port. In the terminal program use the Cisco defaults: 9600 baud, 8 data bits, no parity, 1 stop bit and no flow control (9600 8N1). Some models use 115200; the documentation in the box says so.
The first job is to name the device and give it a management address. A layer 2 switch does not route, so its IP lives on an SVI (Switch Virtual Interface), the virtual interface of VLAN 1, which is the default VLAN and also the native VLAN of trunks (it travels untagged). Because the switch does not route, it also needs an ip default-gateway to answer anyone on another network.
enable
configure terminal
hostname SW01
interface vlan 1
description MGMT
ip address 192.168.1.10 255.255.255.0
no shutdown
exit
ip default-gateway 192.168.1.1
Name, management SVI and gateway
Next you protect the lines you enter through: the console and the VTY lines (virtual sessions over the network; 0 15 means 16 simultaneous sessions). The four commands worth always adding:
login: asks whoever connects for the password set on the line. It is the key left in the door; without it (or withno login) anyone gets in.exec-timeout 10 0: closes the session after 10 idle minutes (minutes and seconds). It is the default;0 0disables it and leaves sessions open forever.logging synchronous: when a syslog message lands in the middle of what you are typing, it redraws your command line below instead of splitting it.transport input: sets which protocols the line accepts. By default it accepts several; the safe policy is to leave only SSH.
line vty 0 15
password Tor123
login
exec-timeout 10 0
logging synchronous
transport input ssh telnet
line console 0
password Tor123
login
exec-timeout 10 0
logging synchronous
end
copy running-config startup-config
VTY and console lines (Telnet stays temporarily open for the lab)
copy running-config startup-config saves the active configuration (RAM) to NVRAM; without that step a reboot erases it. To review only part of it use the filter: show running-config | begin line jumps straight to the lines.
Tor123) are for practice. On a real network use long, unique passwords.Passwords: plain text, type 7 and enable secret
With show running-config you will see that the console and VTY passwords appear exactly as you typed them. Anyone looking over your shoulder, or who receives a backup of the configuration, can read them. The first security command is:
configure terminal
service password-encryption
end
show running-config | begin line
service password-encryption converts plain-text passwords to type 7. It is weak, reversible encryption: public tools decode it in a second. It stops people reading a password at a glance; it does not protect against someone who holds the configuration. Removing it later with no service password-encryption does not decode what was already encrypted.
To move from user mode (>) to privileged mode (#) there are two commands, and they are not equivalent:
| Command | How it is stored | Detail |
|---|---|---|
| enable password | Plain text (type 0); type 7 if service password-encryption is on | Reversible. Avoid it. |
| enable secret | Hash (type 5, MD5, by default); recent IOS also supports type 8/9 | Cannot be reversed. Wins if both exist. |
enable secret Tor2021
no enable password
service password-encryption
Keep only enable secret and encrypt the rest
Entering through the console you pass two doors: first the line password (login) and then, when you type enable, the enable secret. Over Telnet or SSH the same happens with the VTY line. If a line has no login, that door is open: the lab shows this by getting in over Telnet without being asked for anything.
enable secret and service password-encryption all belong here.Spanning Tree when a port comes up, and PortFast
Connect a PC to FastEthernet0/1 with a straight-through cable (different device types: PC and switch) and you will see an amber LED for a while. That is Spanning Tree at work: the port does not forward traffic until it is sure it forms no loop. With classic 802.1D the port walks through these states:
From Listening to Forwarding takes about 30 s (up to 50 s if the port came from Blocking because of the 20 s Max Age).
For a PC that delay is pointless: it sends no BPDUs and cannot form a loop. PortFast takes the port straight to Forwarding. Enable it only on access ports facing end devices:
interface fastEthernet 0/1
switchport mode access
spanning-tree portfast
spanning-tree bpduguard enable
exit
show spanning-tree vlan 1
bpduguard shuts the port down (err-disabled) as soon as it receives a BPDU. In Rapid PVST+ the equivalent of PortFast is called an edge port.The original 802.1D standard uses a single tree instance for the whole network. Cisco evolved it into PVST+: same 802.1D rules but one instance per VLAN. That lets you place each VLAN's root bridge on a different switch and spread traffic over different paths (layer 2 traffic engineering). The Bridge ID is priority + VLAN (extended system ID) + MAC, and the default priority is 32768:
| VLAN | Configured priority | Priority shown by show |
|---|---|---|
| 1 | 32768 | 32769 |
| 10 | 32768 | 32778 |
| 100 | 32768 | 32868 |
SW01# show spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 0001.6338.5A12
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Interface Role Sts Cost Prio.Nbr Type
Fa0/1 Desg FWD 19 128.1 P2p
Typical output: a lone switch is root of its own VLAN 1
Restricting who gets in: a standard ACL on the VTY lines
Before trying Telnet, check connectivity: the PC needs an IP on the same network (for example 192.168.1.100/24) and the first ping loses a packet because the host is resolving the MAC with ARP (arp -a shows the table). With connectivity, telnet 192.168.1.10 asks for the VTY password. Now close the door to one specific source with a standard ACL:
access-list 1 remark Bloquear gestion desde PC1
access-list 1 deny host 192.168.1.100
access-list 1 permit any
line vty 0 15
access-class 1 in
end
show access-lists
ACL 1 applied inbound on the VTY lines
- Standard ACLs filter only by source IP and use numbers 1–99 and 1300–1999 (or a name). That is why they are placed as close to the destination as possible.
- On a VTY line it is applied with
access-class, notip access-group(which is for interfaces).inmeans connections arriving at the switch. - Every ACL ends with an implicit
deny any. If you write only thedenyline you block everyone, yourself included. That is why apermit anyis here; in production it is better to permit only the admin host and let everything else hit the implicit deny.
From the blocked PC, telnet 192.168.1.10 answers Connection refused by remote host, while ping keeps working: the line ACL filters only management sessions, not traffic in general.
The other way to close Telnet is by protocol: transport input ssh on the VTY lines. It works even with no ACL, because the switch refuses any attempt on TCP port 23 and answers only on 22. The best design combines both layers: who (ACL) and how (SSH).
SSH version 2 with local users
Telnet sends the username and password in clear text over TCP port 23: anyone capturing the traffic reads them. SSH (TCP 22) encrypts the whole session and authenticates the server with an RSA key. To enable it on a switch you need, in this order:
- A hostname different from the factory one (
Switch). - An IP domain name (
ip domain-name), because the RSA key is named hostname.domain. - A local user database (
username ... secret): a directory of accounts inside the device itself. - An RSA key pair (
crypto key generate rsa). ip ssh version 2, and on the VTY lineslogin localandtransport input ssh.
hostname SW01
ip domain-name lab.local
username admin privilege 15 secret Tor123456
username carolina secret Tor678
crypto key generate rsa modulus 2048
ip ssh version 2
line vty 0 15
login local
no password
transport input ssh
no access-class 1 in
end
show ip ssh
Complete SSH v2 setup (remove ACL 1 or permit your management host in it)
login local changes where authentication comes from: the VTY no longer uses the line password but the user list, so the line password is redundant. From the PC you connect with ssh -l admin 192.168.1.10. Try the negative case: a user that does not exist in the local database (for example carlitos) is rejected even if you type a valid password of another account; and telnet is now refused because the line accepts only SSH.
| Telnet | SSH | |
|---|---|---|
| TCP port | 23 | 22 |
| Session encryption | No | Yes |
| Server authentication | No | Yes (RSA key) |
Lab topology and the STP root bridge
The next lab grows out of this LAN: four switches (SW01 to SW04), PCs, a services server (later running TFTP and syslog), a border router GW01 that will do NAT, and another router standing for the provider (ISP). The devices come out of the box and empty. Before plugging in a single cable, each switch must already have its VTP domain and its Spanning Tree mode and root decided; otherwise the network picks a root on its own by MAC address, and it usually picks badly.
The election is simple: the lowest Bridge ID wins, meaning the lowest priority and, on a tie, the lowest MAC. Since an old switch with a low MAC can win without anyone deciding it, you set the root on purpose:
configure terminal
spanning-tree mode pvst
spanning-tree vlan 1 root primary
end
show spanning-tree vlan 1
On SW02, as a backup, you would use root secondary
| Setting | Priority | Seen on VLAN 1 |
|---|---|---|
| Default | 32768 | 32769 |
| root primary | 24576 | 24577 |
| root secondary | 28672 | 28673 |
root primary is a macro: it computes a priority that makes the switch root (24576 if the current root has 32768; if a lower one already exists, it subtracts 4096 from that) and writes it into the configuration as spanning-tree vlan 1 priority 24576. Priorities are always multiples of 4096. Note that the macro locks nothing: another switch with a lower priority can still beat it. For a deterministic outcome set an explicit priority (spanning-tree vlan 1 priority 4096) or add root guard on ports facing switches that must never become root.
A root bridge has all its ports in the designated role and Forwarding state, and announces its Bridge ID in every BPDU (Hello every 2 s). When you connect the other switches, the lowest-cost path toward it is the one that stays active on each.
spanning-tree mode rapid-pvst.VTP: domain, mode and version
VTP (VLAN Trunking Protocol) spreads the VLAN database between switches over trunks. VTP governs where VLANs can be created in a domain, which is why you check it before creating the first one. A new switch ships with an empty domain (NULL) and server mode. Look at it:
SW01# show vtp status
VTP Version : 2
Configuration Revision : 0
Maximum VLANs supported locally : 255
Number of existing VLANs : 5
VTP Operating Mode : Server
VTP Domain Name :
SW01# show vlan brief
The 5 existing VLANs are VLAN 1 and 1002 to 1005 (legacy FDDI and Token Ring, unused). The factory version depends on model and IOS: confirm it with show vtp status
Four commands configure everything:
vtp domain THOR
vtp mode server
vtp version 2
vtp password Tor2021
Domain, mode, version and (optional) domain password
| Mode | Creates/deletes VLANs | Advertises to the domain | Applies what it receives |
|---|---|---|---|
| server | Yes | Yes | Yes |
| client | No | Relays | Yes |
| transparent | Yes, local only | No | No (relays adverts in v2) |
- Consistency: domain, version and password must match on every switch of the domain. A switch with another domain or password ignores the advertisements, and your VLANs never reach it.
- Revision number: every VLAN change increments it; switches adopt the database with the highest revision. A switch with a higher revision, plugged in by mistake, can wipe the VLANs of the whole network. Before adding a used one, set it to transparent mode or change its domain and change it back to return to revision 0.
- Trunks only: VTP travels only over trunk links. Version 3 adds extended VLAN support, the primary server and an
offmode.
Working order: a new-switch checklist
Everything above is a field recipe that works the same in a lab as in a real wiring closet. It is an engineering recommendation, not an exam question: there is a VTP domain, a Spanning Tree model and an initial hardening of the device, and all three are settled before you scale the network with trunks and more switches.
After this come trunks, access ports with PortFast and shutting down unused ports.
The last security step is hygiene: ports you will not use must not stay open. Shut them down and, for an extra layer, move them to a VLAN with no traffic (a quarantine VLAN) so that if someone turns one on it lands in a dead-end segment:
interface range fastEthernet 0/10 - 24
switchport mode access
switchport access vlan 999
shutdown
Unused ports 10 to 24 (VLAN 999 must exist and have no SVI)
Class videos
- Day 1 · Part 6.1Initial configurationWatch video
- Day 1 · Part 6.2Secure access: SSH, ACLsWatch video
- Day 1 · Part 6.3Topology and STP rootWatch video
- Day 1 · Part 6.4VTP configurationWatch video
Recorded live in 2021; Spanish audio with Spanish, English, French and Portuguese subtitles. When you play it, the video loads from YouTube. Day 1 playlist on YouTube
Test what you learned
1. A switch with the default STP priority has VLAN 10 active. What priority does show spanning-tree vlan 10 display, and why?
Answer. 32778. PVST+ adds the VLAN ID (extended system ID) to the configured priority of 32768; on VLAN 1 it would be 32769 and on VLAN 100, 32868.
2. A switch has enable password Tor1 and enable secret Tor2, plus service password-encryption. Which password does it ask for when you type enable, and which one is stored irreversibly?
Answer. It asks for Tor2: enable secret takes priority over enable password. Only the secret is stored as a hash (not reversible); the enable password ends up as type 7, which is easily decoded.
3. You want the VTY lines to accept only SSH with users from the local database. Which line commands do you need, and which prerequisites does SSH demand?
Answer. On the VTY lines: login local and transport input ssh. Beforehand: a non-default hostname, ip domain-name, a user with username ... secret, crypto key generate rsa (768-bit modulus or more for v2) and ip ssh version 2.
4. You apply a numbered standard ACL with access-class 1 in on the VTY lines, and the ACL only contains access-list 1 deny host 192.168.1.100. What happens to the other hosts?
Answer. They are blocked too, because every ACL ends with an implicit deny any. You must add a permit (for example permit any or only the management host).
5. In one case, a VTP client switch, domain THOR, version 2, receives a database with revision 5 but its local revision is 7, in the same domain. In another, you plug a used switch with revision 20 into that domain (which is at revision 7). What happens in each case, and what should you do beforehand?
Answer. In the first, revision 5 is lower, so the advertisement is ignored and the local database is kept. In the second, revision 20 is higher: everyone else adopts its database and may lose VLANs. Before connecting it, set it to transparent mode or change its domain and change it back to reset the revision to 0.
Key takeaways
- A new switch is configured over the console (9600 8N1) with a hostname, the VLAN 1 SVI and
ip default-gateway. - Protect the lines with
login,exec-timeoutandlogging synchronous; save withcopy running-config startup-config. service password-encryptionis type 7 and reversible;enable secretuses a hash and takes priority overenable password.- PortFast skips Listening and Learning, but only on host-facing access ports, ideally with BPDU guard.
- A standard ACL filters by source, uses 1–99 and 1300–1999, ends in an implicit deny and is applied to the VTY lines with
access-class. - SSH v2 requires a hostname, a domain, a local user, RSA keys (2048 bits recommended),
login localandtransport input ssh. - STP priority = configured value + VLAN ID;
root primarylowers it to 24576 androot secondaryto 28672. - In VTP the domain, version and password must match; watch the revision number before plugging in a used switch.
Official resources
- Cisco: CCNA 200-301 examcisco.com
- Cisco: 200-301 v1.1 exam topics (PDF)learningcontent.cisco.com
- Cisco: Configure SSH on Routerscisco.com
- Cisco: Understand VLAN Trunk Protocol (VTP)cisco.com
- Cisco: Understand Rapid Spanning Tree Protocol (802.1w)cisco.com
- RFC 4251: The Secure Shell (SSH) Protocol Architecturerfc-editor.org
Source and credits. Chapter written from the CCNA 200-301 Bootcamp that Jesús Espinoza recorded live in 2021, on the v1.0 syllabus; the current exam is v1.1. Text drafted with AI assistance and reviewed; original diagrams by The House of Routing. Technical data and configuration were checked against Cisco's official documentation, IETF RFCs and IEEE standards.