Week 10 · Lesson 4

Securing the Network Device

A router or switch is a Linux-like computer with a management plane — and that management plane is the way in. Hardening means removing every unnecessary way in and locking down the ones that remain. This lesson is a hands-on hardening checklist: nine controls, each with the exact IOS commands, plus the port-security rules the exam tests.

CCNA 200-301 Domain 5.3 Device Access Control Verified 2026-10-11
Part 1

What hardening means

Hardening is the process of reducing the attack surface of a device: turning off what you do not need, securing what you must keep, and making sure every action is authenticated and logged. On a Cisco device that means the management plane — console, AUX, VTY (Telnet/SSH), HTTP, SNMP, CDP, and the small services (finger, tcp-small-servers, and so on). Each one is a door; hardening is closing the ones you do not use and putting a good lock on the ones you do.

Layer 1 · Physical and management access control Layer 2 · Authentication and encryption (SSH only) Layer 3 · Service and port hardening Layer 4 · Logging and monitoring Switch / Router

Hardening is layered. Physical access is the foundation (password recovery via the configuration register proves it), SSH and strong passwords control logical access, service and port restrictions shrink the attack surface, and logging makes everything auditable.

Exam tip — the “big five”. If you can only remember five hardening facts, remember these: (1) use enable secret, not enable password; (2) transport input ssh disables Telnet; (3) SSH needs hostname + domain name + RSA keys; (4) port-security violations are protect → restrict → shutdown; (5) sync time (NTP) and ship logs (syslog) so you can prove what happened.
Part 2

Rule 1 — strong passwords, and Rule 2 — the banner

The password that protects privileged EXEC mode is the most important one on the device. Protect it with enable secret, which stores a strong one-way hash (by default MD5, type 5). The older enable password is stored in clear text or a weak, reversible type-7 form and must not be used. If both are configured, the secret takes precedence.

! Preferred: hashed privileged-EXEC password
R1(config)# enable secret Str0ngSecret!

! Optional (newer IOS): SHA-256 hash instead of MD5
R1(config)# enable algorithm-type sha256 secret Str0ngSecret!

! Encrypt other clear-text passwords stored in the configuration
R1(config)# service password-encryption
R1(config)#
Exam tip — enable secret beats enable password. enable secret = one-way hash, not reversible. enable password = clear text or weak reversible type-7. If a question shows both, the secret wins. service password-encryption only obscures the other stored passwords (console, VTY, username) with type-7 — it does not affect the already-hashed secret.
Type 7 is not encryption. The type-7 scheme applied by service password-encryption is a fixed, reversible obfuscation that offers no real protection against anyone with the config file. It only stops a shoulder-surfer reading plain text. Use it, but do not rely on it.

Rule 2 — a login banner

A message-of-the-day (motd) banner appears before login. It is a legal control: a clear warning that access is restricted to authorised users supports prosecution of intruders. The character immediately after motd is a delimiter you choose; IOS prints your text until it sees that same character again.

R1(config)# banner motd ^
Enter TEXT message. End with the character '^'.
Authorized access only. Disconnect immediately if you are not an authorized user.
^
R1(config)#
Part 3

Rule 3 — the VTY lines, and Rule 4 — SSH

The VTY (virtual terminal) lines are the remote-login doors. By default they accept Telnet, which sends everything — including the password — in cleartext. Restrict them to SSH only, authenticate against the local user database, and set an idle timeout.

Hardening commands · select one to see what it does

R1(config)# line vty 0 4
R1(config-line)# transport input ssh      ! disable Telnet; allow SSH only
R1(config-line)# login local               ! use the local username database
R1(config-line)# exec-timeout 5 0           ! log out after 5 minutes idle
R1(config-line)# exit
R1(config)#
exec-timeout syntax. exec-timeout 5 0 means 5 minutes and 0 seconds of idle time. The second value is seconds, so exec-timeout 5 30 is five and a half minutes. Setting exec-timeout 0 0 disables the timeout entirely — convenient, but insecure, so do not do it.

You can further restrict VTY access by source address with an ACL and access-class <number> in on the line, so only a management subnet may attempt SSH. You can also throttle and slow brute-force attempts:

! Restrict VTY logins to the management subnet
R1(config)# access-list 20 permit 192.168.1.0 0.0.0.255
R1(config)# line vty 0 4
R1(config-line)# access-class 20 in
R1(config-line)# exit

! Optional: block the source for 60s after 3 failed logins in 120s
R1(config)# login block-for 60 attempts 3 within 120

SSH setup

SSH encrypts the whole management session. IOS needs three things before it can generate keys: a hostname, a domain name, and a local username with a secret. Then generate the RSA key pair and force version 2.

R1(config)# hostname R1
R1(config)# ip domain-name example.com
R1(config)# username admin privilege 15 secret cisco12345

! Generate the RSA key pair. Minimum is 768 bits; use 1024 or more.
R1(config)# crypto key generate rsa
The name for the keys will be: R1.example.com
How many bits in the modulus [512]: 2048
% Generating 2048 bit RSA keys, keys will be non-exportable...[OK]

R1(config)# ip ssh version 2
R1(config)# line vty 0 4
R1(config-line)# transport input ssh
R1(config-line)# login local
R1(config-line)# exit
Exam tip. crypto key generate rsa fails if the hostname is still the default (“Router”) or no domain name is set — the keys are named hostname.domain. The old minimum was 768 bits; 1024 is the practical minimum and 2048 is recommended. SSH version 1 is insecure — disable it with no ip ssh version 1 or force version 2. To delete the keys, use crypto key zeroize rsa.
Part 4

Rule 5 — console and AUX, Rule 6 — unneeded services

The console is local but still a door: anyone at the device can attach a cable. Protect it with a password and a timeout. logging synchronous is not security — it re-prints your typed line after a log message interrupts it — but it belongs in a standard device template.

R1(config)# line console 0
R1(config-line)# password cisco12345
R1(config-line)# login
R1(config-line)# logging synchronous
R1(config-line)# exec-timeout 5 0
R1(config-line)# exit

! AUX line: used for out-of-band modem access. Disable it if unused.
R1(config)# line aux 0
R1(config-line)# password cisco12345
R1(config-line)# login
R1(config-line)# exec-timeout 5 0
R1(config-line)# no exec                  ! disable remote EXEC on AUX
R1(config-line)# transport input none
R1(config-line)# exit
Note on no exec. no exec prevents an interactive EXEC session on that line. Applying it to AUX (if no modem is attached) closes an often-forgotten remote door. Do not apply it to the console if you need local sessions.

Every running service is potential attack surface. Turn off the ones you do not use. Availability varies by platform, so treat this as “where applicable”:

R1(config)# no ip http server          ! disable the web (GUI) server
R1(config)# no ip http secure-server   ! disable HTTPS GUI as well
R1(config)# no service tcp-small-servers
R1(config)# no service udp-small-servers
R1(config)# no ip finger               ! older IOS: no service finger
R1(config)# no ip bootp server
R1(config)# no service config          ! stop loading config from the network
R1(config)# no cdp run                 ! or: no cdp enable per interface
R1(config)# no ip domain-lookup        ! avoid name leaks and lookup delays
R1(config)#

On a switch, unused access ports are just as important. Move them to an unused VLAN and shut them down so a rogue device cannot plug in:

S1(config)# vlan 999
S1(config-vlan)# name UNUSED
S1(config-vlan)# exit
S1(config)# interface range fastethernet0/10 - 24
S1(config-if-range)# switchport mode access
S1(config-if-range)# switchport access vlan 999
S1(config-if-range)# shutdown
S1(config-if-range)# exit
CDP trade-off. CDP (Cisco Discovery Protocol) is useful for discovering neighbours, but it leaks device names, platforms, and IOS versions to anyone on the link. Keep it on trusted internal links; disable it on interfaces facing untrusted networks.
Part 5

Rule 7 — port security

Port security limits which MAC addresses may use a switch access port. It stops a rogue device from joining, and it blunts MAC-flooding attacks by capping how many addresses a port can learn. It applies to access ports only, so set the mode first.

Port-security violation modes · select one
PC1 Switch port PC2 (rogue) port state rogue frames

S1(config)# interface fastethernet0/1
S1(config-if)# switchport mode access            ! port security needs an access port
S1(config-if)# switchport port-security
S1(config-if)# switchport port-security maximum 1
S1(config-if)# switchport port-security mac-address sticky
S1(config-if)# switchport port-security violation restrict
S1(config-if)# end
S1# show port-security interface fastethernet0/1
Exam tip — severity order. protect → restrict → shutdown, from least to most severe. shutdown is the default. If a question mentions logging or a counter, it is restrict; if it mentions silence, it is protect; if it mentions err-disable, it is shutdown.

To recover a port that was err-disabled by port security, you can bounce it manually, or enable automatic recovery:

! Manual recovery
S1(config)# interface fastethernet0/1
S1(config-if)# shutdown
S1(config-if)# no shutdown
S1(config-if)# exit

! Or let IOS recover the port automatically after 300 seconds
S1(config)# errdisable recovery cause psecure-violation
S1(config)# errdisable recovery interval 300
Part 6

Rules 8 and 9 — NTP and syslog — and the checklist

Secure devices must agree on the time. Accurate timestamps make logs, security events, and forensic correlation meaningful — and a device with a wrong clock can fail certificate validation or produce useless audit trails. NTP (Network Time Protocol) keeps clocks aligned to a trusted source.

R1(config)# ntp server 192.168.1.1
R1(config)# clock timezone UTC 0
R1(config)# service timestamps log datetime msec localtime show-timezone
R1# show ntp status
R1# show ntp associations

! Optional: authenticated NTP so a rogue time server cannot spoof it
R1(config)# ntp authenticate
R1(config)# ntp authentication-key 1 md5 NtpKey123
R1(config)# ntp trusted-key 1
R1(config)# ntp server 192.168.1.1 key 1
NTP spoofing. Plain NTP is unauthenticated, so an attacker who can reach the device can feed it a false time. Use NTP authentication (ntp authenticate) and pick servers inside your trusted management network.

Local logs are lost when a device reboots or is replaced, and an attacker who owns the device can erase them. Send logs to a central syslog server so there is an independent copy that supports auditing and incident response.

Syslog severity levels · pick a level

R1(config)# logging host 192.168.1.50        ! older IOS: logging 192.168.1.50
R1(config)# logging trap informational     ! send severity 0-6 to the server
R1(config)# logging source-interface GigabitEthernet0/0
R1(config)# logging buffered 16384           ! keep a local ring buffer too
R1# show logging

The hardening checklist

This table is the whole lesson on one screen. Reproduce it from memory before the exam.

AreaKey command(s)Purpose
Privileged EXECenable secret <pw>Hash the enable password (beats enable password).
Stored passwordsservice password-encryptionObscure other clear-text passwords (type 7).
Bannerbanner motd ^Legal warning before login.
VTY linestransport input ssh, login local, exec-timeout 5 0SSH only, authenticate locally, auto-logout.
SSHhostname, ip domain-name, crypto key generate rsa, ip ssh version 2Encrypted management access.
Console / AUXpassword, login, exec-timeout, no exec (AUX)Protect local and out-of-band ports.
Servicesno ip http server, no cdp run, no service tcp-small-serversShrink the attack surface.
Unused portsswitchport access vlan 999 + shutdownStop rogue device connections.
Port securityswitchport port-security + maximum + sticky + violationControl which MACs may connect.
Timentp server <ip>Accurate, correlatable logs.
Logginglogging host <ip>, logging trapIndependent audit trail.
Part 7 · Your turn

Review

Check what you have learned with these review questions.

Review · 6 questions

Sources

Sources & references

  1. Cisco. CCNA (200-301) Exam Topics, Domain 5.3 (Configure device access control) and Domain 5.5 (describe security program elements). cisco.com.
  2. Cisco. Cisco Guide to Harden Cisco IOS Devices (security configuration guide). cisco.com.
  3. Cisco. Configuring Port Security (Catalyst switch security configuration guide). cisco.com.
  4. Cisco. Configuring NTP and Configuring System Message Logging (IOS configuration guides). cisco.com.
  5. Cisco. Configuring Secure Shell (SSH) on IOS (tech note). cisco.com.
  6. NIST. SP 800-123: Guide to General Server Security and SP 800-53 access control controls. csrc.nist.gov.

Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.