Cisco Cheatsheet

The Cisco IOS commands worth having to hand — modes, a baseline config, VLANs and trunks, and the show commands you actually reach for on site. Pairs with the Cisco config generator on the Tools page, which will build a hardened baseline for you. Switch examples use Gi1/0/1-style interfaces; adjust to whatever your kit calls them.

Getting around: the modes

IOS is a set of nested rooms, and the prompt tells you which one you are standing in. You cannot configure anything from the front door.

ModePromptHow you get there
User EXECSW01>Where you land on login. Look, barely touch.
Privileged EXECSW01#enable
Global configSW01(config)#configure terminal (conf t)
Interface configSW01(config-if)#interface Gi1/0/1
Line configSW01(config-line)#line vty 0 15
Back one levelexit
Back to privileged EXECend or Ctrl+Z

Tip

Tab completes a command and ? lists what is valid at that point — show ip ? is the fastest way out of “what was that command again”. Almost everything can be abbreviated (conf t, sh ip int br) as long as it is unambiguous. And do lets you run a privileged command without leaving config mode: do show ip int brief.

A sane baseline

TaskCommand
Name the devicehostname SW01
Set the enable password (hashed)enable secret <password>
Encrypt other plaintext passwordsservice password-encryption
Create a local adminusername admin privilege 15 secret <password>
Login bannerbanner motd #Authorised access only#
Management IP (switch SVI)interface vlan 1ip address 10.0.0.2 255.255.255.0no shutdown
Default gateway (L2 switch)ip default-gateway 10.0.0.1

Turning on SSH

StepCommand
Domain name (needed for the key)ip domain-name example.com
Generate the host keycrypto key generate rsa modulus 2048
Force SSH v2ip ssh version 2
Use local accounts on the VTY linesline vty 0 15login local
SSH only, no telnettransport input ssh
Stop console messages eating your typingline con 0logging synchronous

Interfaces

TaskCommand
Configure one portinterface Gi1/0/1
Configure many at onceinterface range Gi1/0/1-24
Label it (do this — future you will thank you)description Uplink to core
Bring it upno shutdown
Take it downshutdown
Give it an IP (router / L3)ip address 192.168.1.1 255.255.255.0
Access port in a VLANswitchport mode accessswitchport access vlan 10
Skip the spanning-tree wait on an edge portspanning-tree portfast
Shut the port if it sees a BPDUspanning-tree bpduguard enable

VLANs and trunks

TaskCommand
Create a VLANvlan 10name Staff
Put a port in itswitchport mode accessswitchport access vlan 10
Make a port a trunkswitchport mode trunk
Limit what crosses the trunkswitchport trunk allowed vlan 10,20,30
Add one VLAN to an existing trunkswitchport trunk allowed vlan add 40
Set the native VLANswitchport trunk native vlan 99
Route between VLANs (L3 switch)ip routing + an interface vlan X per VLAN

Warning

switchport trunk allowed vlan 10 replaces the allowed list with just VLAN 10 — it does not add to it. Use allowed vlan add 10 when you mean “and also”. Getting these two confused on a live uplink is one of the quicker ways to black out a floor.

Looking around: show commands

QuestionCommand
What is the whole config?show running-config (sh run)
What will it boot with?show startup-config
Which interfaces are up, and their IPs?show ip interface brief
Port status, speed, duplex, VLANshow interfaces status
What VLANs exist and which ports are in them?show vlan brief
Which trunks, carrying what?show interfaces trunk
What MAC is on which port?show mac address-table
What is plugged into me?show cdp neighbors detail / show lldp neighbors
Spanning-tree state, who is rootshow spanning-tree
Model, IOS version, uptime, serialshow version
One interface in detail (errors, drops)show interfaces Gi1/0/1
Filter any outputappend | include VLAN0010 or | begin Gi1/0/5

Diagnostics

For when the problem is on the wire rather than in the config. Most of this is about reading counters honestly: a port can sit there reporting up/up and still be quietly mangling every third frame.

Testing the cable itself (TDR)

Most Catalyst switches have a Time Domain Reflectometer built into their copper ports. It fires a pulse down each pair, listens for the echo, and reports whether the pair is intact — and roughly how many metres away the fault is. It will not replace a Fluke, but it answers the question you actually have on site: do I go and look at the patch panel, or at the desk?

TaskCommand
Run the testtest cable-diagnostics tdr interface Gi1/0/1
Read the result (give it a few seconds)show cable-diagnostics tdr interface Gi1/0/1
Pair resultWhat it means
NormalPair is fine end to end.
OpenBroken conductor, or nothing terminated at the far end.
ShortTwo conductors touching — usually a mangled crimp.
Impedance MismatchA bad joint, a dodgy coupler, or mixed cable types along the run.

Before you run TDR

It is copper only — no SFPs, no fibre — and on most platforms only the gigabit ports support it. More to the point, the test drops the link while it runs. Running it on the uplink you are managing the switch through is the same mistake as every other one on this page, just with a more interesting excuse. The distance figure is approximate too — expect a tolerance of a few metres — so treat it as “about that far along”, not a pinpoint.

What the error counters are telling you

Counter climbingUsually means
CRC / FCS errorsBad cable or patch lead, electrical interference — or a duplex mismatch.
Late collisionsDuplex mismatch, or a run longer than 100 m.
RuntsCollisions, or again a duplex mismatch.
GiantsMTU / jumbo-frame mismatch between the two ends.
Input errorsAn umbrella counter — read the specific ones underneath it.
Output dropsEgress congestion; classically a 1G port feeding a 100M one.
Interface resetsThe link is flapping. Suspect the cable, then the far-end NIC.

Duplex mismatch is the classic, because it presents as a slow and flaky link rather than a broken one, and people chase the application instead. The tell is asymmetric: late collisions on one side, CRC errors on the other. Both ends should be auto-negotiating, or both hard-set — never one of each.

TaskCommand
Errors on one port, in detailshow interfaces Gi1/0/1
Error counters across every portshow interfaces counters errors
Reset counters for a clean baselineclear counters Gi1/0/1
Which ports are err-disabled, and whyshow interfaces status err-disabled
What auto-recovers, and after how longshow errdisable recovery
Let a cause recover by itselferrdisable recovery cause psecure-violation + errdisable recovery interval 300

Finding things, and the rest

QuestionCommand
Where is this MAC plugged in?show mac address-table address 0011.2233.4455
Which IP maps to which MAC?show ip arp
Is the optic actually seeing light?show interfaces transceiver (dBm per lane)
Is the switch delivering PoE?show power inline
What has it been complaining about?show logging
Is it CPU-bound?show processes cpu sorted
Temperature, fans, power suppliesshow environment
Can it reach that?ping 10.0.0.1 / traceroute 10.0.0.1

If you reach for debug

debug output goes to the console by default, so over SSH you will see nothing until you run terminal monitor. Turn it off the moment you are done — undebug all. A chatty debug left running on a busy production switch can drive the CPU hard enough to take the thing off the network, which is a memorable way to turn a small fault into a large one.

Saving, and not locking yourself out

TaskCommand
Save the configcopy running-config startup-config — or write memory / wr
Safety net before a risky changereload in 10
Cancel it once you are happyreload cancel
Throw away unsaved changesreload and answer no to saving
Wipe a switch back to factoryerase startup-config + delete vlan.dat, then reload

The reload-in trick

reload in 10 schedules a reboot in ten minutes before you make a change you are not sure about. If the change locks you out, the switch reboots into the last saved config and lets you back in. If it works, reload cancel and then save. It is the network engineer’s equivalent of keeping one hand on the door — and remember that on a switch, VLAN data lives in vlan.dat separately from the startup config, which is why a “factory reset” needs both.

Access lists, briefly

TaskCommand
Named extended ACLip access-list extended GUEST-IN
A permit rulepermit tcp 10.10.0.0 0.0.255.255 any eq 443
A deny ruledeny ip 10.10.0.0 0.0.255.255 10.0.0.0 0.255.255.255
Apply it to an interfaceinterface Vlan10ip access-group GUEST-IN in
See hit countsshow access-lists

Note the wildcard masks — they are the inverse of a subnet mask (0.0.255.255 where a mask would read 255.255.0.0), and there is an invisible deny ip any any at the end of every ACL. The access list generator will write these for you, and the wildcard converter flips masks either way.

Hardening the switch

An access switch sitting in an unlocked comms cupboard is a row of live network sockets. These are the things worth doing beyond setting a password.

Port security

TaskCommand
Turn it on (access ports only)switchport port-security
Limit how many MACs may appearswitchport port-security maximum 2
Learn the MAC and keep itswitchport port-security mac-address sticky
What to do about a violationswitchport port-security violation restrict
Check itshow port-security interface Gi1/0/1
Violation modeBehaviour
protectSilently drops the offending traffic.
restrictDrops it, and logs and counts it.
shutdown (default)Err-disables the whole port.

shutdown being the default catches people out: one unexpected MAC and the port is dead until somebody bounces it or errdisable recovery picks it up. On a desk port with a phone and a PC daisy-chained behind it, maximum 2 paired with restrict is usually the kinder arrangement.

The classic layer-2 attacks

ThreatDefence
Someone plugs in a rogue DHCP serverip dhcp snooping + ip dhcp snooping vlan 10,20, then ip dhcp snooping trust on the uplink only
ARP spoofing / poisoningip arp inspection vlan 10,20 + ip arp inspection trust on uplinks
A rogue switch grabbing the spanning-tree rootspanning-tree guard root on downstream ports
Any switch plugged into a desk portspanning-tree bpduguard enable on edge ports
See what snooping has learnedshow ip dhcp snooping binding

Dynamic ARP Inspection leans on the DHCP snooping binding table, so snooping has to come first — DAI on its own has nothing to check against.

Trust the uplink, or break DHCP for everyone

Enabling DHCP snooping marks every port untrusted by default, and an untrusted port drops inbound DHCP offers. Turn it on without adding ip dhcp snooping trust to the uplink and you have just blocked the replies from your real DHCP server — the whole VLAN stops getting addresses as leases expire, on a delay long enough that nobody connects it to the change you made. Trust the uplink in the same maintenance window you enable snooping.

The management plane

TaskCommand
Restrict who may even reach VTYline vty 0 15access-class MGMT-ONLY in
Slow down brute forcelogin block-for 120 attempts 3 within 60
Time out idle sessionsexec-timeout 10 0
Turn off the web serverno ip http server + no ip http secure-server
Stop advertising yourself to untrusted portsno cdp enable (per interface)
SSH only on the VTY linestransport input ssh

secret, not password

Always enable secret, never enable password. The latter is stored with a type-7 cipher that is trivially reversible — there are decoders in the browser. And be clear about what service password-encryption buys you: it applies that same weak type-7 encoding to the remaining plaintext passwords in the config. It defeats shoulder-surfing, not anybody who walks away with a copy of the config file.

Unused ports and VLAN hygiene

PracticeWhy
shutdown unused ports, and park them in an unused VLANAn unpatched live port is a free network connection for anyone in the building.
Do not leave user ports in VLAN 1It is the default everywhere, which makes it everyone’s first guess.
Set the trunk native VLAN to something unusedUntagged traffic on a trunk lands in the native VLAN — reduces VLAN-hopping exposure.
Prune trunks to only the VLANs they carrySmaller blast radius, and less flooding across the uplink.

Mind the branch you are sitting on

The same rule as anywhere else: do not shutdown the port, VLAN or uplink you are managing the device through, and think hard before applying an ACL to the interface your session arrives on. On a switch in a comms room two hours away, that is the difference between a quick change and a long drive.