Use it when the design or fault is specifically about the access-port source-MAC admission boundary, including secure MAC learning, maximum counts, violation mode and recovery. Stay on that boundary until configuration intent, live control/security state and the adjacent dependency agree.
Port Security
Port security limits which and how many MAC addresses can use a switch access port. Addresses can be static, learned dynamically or sticky (saved to config); a violation either shuts the port down (default), restricts or protects.
1. Port security limits MACs per port.
2. Violation modes: shutdown (default), restrict, protect.
3. Sticky MACs save learned addresses.
4. Err-disabled ports need recovery.
5. Set max for phones+PCs.
MAC learned → count/allowed checked → violation action
Compare secure MAC entries and the endpoint MAC, then check interface err-disable/state if violations occurred.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
switchport mode accessPrimary Commands
Configuration and operational commands for this Topic.
switchport mode accessReferenceMake the port a static access port.
Use when: Make an endpoint-facing port a predictable non-trunking access port.
Quick note: Pair with switchport access vlan <id> and verify operational mode.
switchport port-securityReferenceEnable port security on the interface.
Use when: Enforce secure-MAC admission on an intended access edge.
Quick note: Verify interface role and current endpoint MAC population first.
Cisco IOS / IOS XE · mixedswitchport port-security maximum <number>ReferenceSet the maximum number of secure MAC addresses.
Use when: Size the allowed endpoint identity set deliberately.
Quick note: Account for IP phones, downstream devices, virtualization and other legitimate multi-MAC cases.
Cisco IOS / IOS XE · mixedswitchport port-security mac-address <mac>ReferenceConfigure a static secure MAC address.
Use when: Bind a known endpoint MAC explicitly to the access port.
Quick note: Confirm normalized MAC and physical port ownership.
Cisco IOS / IOS XE · mixedswitchport port-security mac-address stickyReferenceLearn secure MAC addresses dynamically and keep them in the running configuration.
Use when: Learn observed endpoint MACs into sticky secure state/config on supported IOS/IOS XE.
Quick note: Inspect running config and show port-security address; follow a deliberate save/replacement workflow.
switchport port-security violation protectReferenceOn violation, drop traffic from unknown addresses without logging.
Use when: Drop unauthorized source traffic while keeping the port operational with minimal disruption.
Quick note: Use show state/counters supported by the target platform and monitor endpoint behavior.
Cisco IOS / IOS XE · mixedswitchport port-security violation restrictReferenceOn violation, drop traffic and log/count the violation.
Use when: Drop unauthorized source traffic while retaining violation visibility/counters and keeping the port up.
Quick note: Correlate violation count with secure-address table and observed endpoint MACs.
Cisco IOS / IOS XE · mixedswitchport port-security violation shutdownReferenceOn violation, put the port into err-disabled state (default).
Use when: Use disruptive enforcement where an unexpected secure-MAC violation should disable the interface.
Quick note: Capture violation evidence first, correct cause, then recover the interface.
Cisco IOS / IOS XE · mixedswitchport port-security aging time <minutes>ReferenceSet how long secure addresses are kept.
Use when: Age learned secure identities when endpoint mobility or lifecycle requires it.
Quick note: Verify aging mode/type and which entries are eligible on the target platform.
Cisco IOS / IOS XE · mixedswitchport port-security aging type absoluteReferenceRemove secure addresses after the aging time, regardless of activity.
Use when: Use time-based expiry independent of activity when policy requires periodic relearning.
Quick note: Confirm platform treatment of sticky/static entries and timer units.
Cisco IOS / IOS XE · mixedswitchport port-security aging type inactivityReferenceRemove secure addresses after they are inactive for the aging time.
Use when: Retain active identities while removing stale learned endpoints after inactivity.
Quick note: Verify actual aging behavior and secure-address table over time.
Cisco IOS / IOS XE · mixedShow Commands
Read-only Cisco show commands for confirming state, narrowing a fault and interpreting the current boundary.
show port-securityShowDisplay port security status per interface.
Use when: Quickly identify interfaces participating in Port Security and violation status.
Quick note: Drill into the affected interface and secure-address table.
Cisco IOS / IOS XE · mixedshow port-security addressShowDisplay secure MAC addresses.
Use when: Identify which MAC addresses are currently considered secure and where they are bound.
Quick note: Compare with show mac address-table, endpoint MAC and intended port.
show port-security interface {{interface}}ShowShows secure MAC state, maximum addresses and violation counters.
Use when: Use after confirming the Network Hardening target and before changing state.
Quick note: Cross-platform security / Cisco / Linux / Windows. A control being configured does not prove enforcement, visibility, containment or acceptable residual risk.
Cisco IOS XE · mixedVerification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 First 30 seconds Verify boundary
Immediate answer: Read secure MAC learning, maximum, violation mode and violation counters on the exact access port before clearing state.
Verification chain: link/access VLAN → secure-MAC learning → maximum/sticky policy → violation action → interface state → endpoint traffic
Stop condition: A secure MAC entry does not show the endpoint is authorized beyond this switchport policy or that upstream service is healthy.
Step 2 Operational verification and known-good state Verify boundary
show port-security
show port-security interface GigabitEthernet1/0/10
show port-security address
show interfaces status err-disabled
The summary lists every secured port with maximum, current count, violation count and action. The interface view adds port status (Secure-up or Secure-shutdown) and the last source address seen with its VLAN — the address that caused the most recent violation, if there was one. The address table shows each secure address, its type and its port.
Known-good: the port is Secure-up, the current count is within the maximum, the listed addresses belong to the expected devices, and the violation counter is not rising.
Step 3 Verification and output interpretation Verify boundary
Use show port-security interface <interface> to inspect whether the feature is enabled, the configured maximum, current secure-address count, violation mode, violation counter and operational status. Use show port-security address when you need to see which MAC addresses are considered secure and where they are bound. Correlate with show interfaces status, interface counters and the switch MAC table to distinguish a physical/link problem from a policy rejection. If a port is error-disabled, confirm the reason rather than assuming every errdisable event came from Port Security. After an intended endpoint replacement, verify that the secure-address state reflects the new design and that violation counters are not continuing to increment. Collect the secure-address and violation state before clearing/reconfiguring it if you need evidence of what triggered the policy.
Step 4 Verification & troubleshooting Narrow the fault
1. show port-security interface <interface> → enabled, port status, violation mode, maximum, current count, last source address and violation count.
2. show port-security address → the secure addresses and the ports they belong to.
3. show interfaces status err-disabled → whether the port was shut down, and why.
4. Decide whether the last source address is a device that should be allowed.
5. Correct the cause — remove the stale address or raise the maximum — and only then bring the port back with shutdown and no shutdown.
Step 5 Failure signatures and troubleshooting branches Narrow the fault
- The port is down, err-disabled, after a device was replaced. The old address is still secure — typically a sticky entry — and the new device violated the limit. Remove the old entry, then re-enable the port.
- A phone and a PC share the port and it shuts down. The maximum of 1 is too low.
- The port was re-enabled and went down again at once. The offending device is still connected and the cause was not corrected.
- Sticky addresses are gone after a reload. The running configuration was not saved.
- Users lose connectivity with no log message. Mode
protectdrops silently;restrictat least counts and logs. switchport port-security maximumis configured but nothing is enforced. The plainswitchport port-securitycommand is missing.- A device works on one port but not after moving to another. Its address is still secure on the first port.
Step 6 When the problem is really fixed Narrow the fault
- The port is
Secure-upand the device has connectivity. - The secure addresses listed are the intended devices and the count is within the maximum.
- The violation counter no longer increases.
- If sticky entries are used, the configuration has been saved.
Evidence · 4 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
The official Cisco source documents this command in a bounded Cisco product/release or feature context.
command output · Evidence referencePort Security violation counter increasesThe interface violation count increases while the unexpected source MAC sends traffic.
command output · Evidence referencePort Security shutdown / err-disabled boundaryThe protected interface shows a security-violation shutdown/disabled condition after a violation.
command output · Evidence referenceUnexpected sticky secure MACA sticky secure MAC is bound to the access port but does not match the intended endpoint.
Do not infer service health from one command. For Port Security, distinguish configured intent, protocol/security state, installed forwarding state and the original workload result.
show port-security— secure ports, violationsshow port-security interface <interface>— max MACs, violation modeshow interfaces status err-disabled— shutdown ports
ReferenceWhat it is1 section · depth on demand
What it is
Port security limits which devices may use a switch access port. The switch counts the source MAC addresses it sees on the port, allows up to a configured maximum, and takes a configured action when another address appears.
ReferenceWhy it matters1 section · depth on demand
Why it matters
It stops the simplest forms of misuse at the edge: someone plugging in their own switch or access point, and attacks that flood the switch with thousands of fake MAC addresses. In daily operation it matters mostly for another reason — it is one of the commonest causes of a port being err-disabled, usually after a legitimate change such as a replaced PC or a new docking station.
ReferenceImportant terms & boundaries8 sections · depth on demand
Key points
- Works on ports that are statically access or trunk; not on ports left in dynamic mode. Set
switchport mode accessfirst. - Enable with
switchport port-security; the other port-security commands do nothing without it. - Default maximum is 1 address; default violation mode is shutdown.
- Secure addresses can be typed in (static), learned automatically (dynamic) or learned and written to the configuration (sticky).
- Violation modes:
protectdrops silently,restrictdrops and logs and counts,shutdownerr-disables the port. - A port with an IP phone and a PC needs a maximum of at least 2, often 3.
- An err-disabled port stays down until
shutdown/no shutdownor errdisable recovery.
Violation modes
Protect drops violating source traffic silently from a port-security perspective; restrict drops and increments/report violations; shutdown places the interface into a security-violation shutdown/err-disabled condition on common IOS/IOS XE behavior. Exact logging/SNMP details vary by platform/release.
In depth
Port security limits which MAC addresses a port accepts
The Catalyst 9300 port security guide gives the defaults: disabled on each port, a maximum of one secure MAC address, violation mode shutdown, sticky learning off, and aging off.
C9300(config)# interface GigabitEthernet1/0/10
C9300(config-if)# switchport mode access
C9300(config-if)# switchport access vlan 20
C9300(config-if)# switchport voice vlan 120
C9300(config-if)# switchport port-security maximum 3
C9300(config-if)# switchport port-security mac-address sticky
C9300(config-if)# switchport port-security violation restrict
C9300(config-if)# switchport port-security aging time 60
C9300(config-if)# switchport port-security aging type inactivity
C9300(config-if)# switchport port-security
C9300# show port-security interface GigabitEthernet1/0/10
Port Security : Enabled
Port Status : Secure-up
Violation Mode : Restrict
Aging Time : 60 mins
Aging Type : Inactivity
Maximum MAC Addresses : 3
Sticky MAC Addresses : 2
Last Source Address:Vlan : 0050.b61a.2b3c:20
Security Violation Count : 0
Violation modes (documented)
| Mode | Drops unknown sources | Notification | Port |
|---|---|---|---|
| protect | Yes | None, no counter | Stays up |
| restrict | Yes | Syslog, SNMP trap, counter | Stays up |
| shutdown (default) | Whole port | Counter (the guide is inconsistent about syslog) | Err-disabled |
| shutdown vlan | That VLAN only | Syslog, counter | VLAN err-disabled |
Secure address types
| Type | Stored in |
|---|---|
| Static | Address table and running config |
| Dynamic | Address table only; gone after restart |
| Sticky | Address table and running config; survives a reload only if the config is saved |
The guide notes that sticky addresses don't age.
Documented restrictions
- Not supported on EtherChannel or private VLAN ports, and not recommended on 802.1X authenticator ports.
- Only static access or trunk ports; not on ports in dynamic DTP mode.
- With a voice VLAN, set the maximum to at least two plus the access VLAN's maximum.
Recovery
errdisable recovery cause psecure-violation brings shut-down ports back automatically. Manually, use shutdown then no shutdown.
Documented example, not captured output.
Sticky learning
Sticky learning converts dynamically observed secure MAC addresses into sticky secure entries in the running configuration/state on supported Cisco platforms. Treat persistence across reload/save workflows deliberately and verify what is actually stored on the target release.
Quick reference
Port security limits which MAC addresses may use a switch access port and how many. When an unauthorised MAC appears, the violation action applies.
interface Gi1/0/10
switchport mode access
switchport port-security
switchport port-security maximum 2
switchport port-security mac-address sticky
switchport port-security violation restrict
show port-security interface Gi1/0/10
Documented example, not captured output.
| Violation mode | Action |
|---|---|
| shutdown (default) | Err-disable port |
| restrict | Drop and log/count |
| protect | Drop silently |
Allow at least two MACs on ports with an IP phone and PC. 802.1X is the stronger, identity-based alternative.
Mechanics and state ownership
Once enabled, the port keeps a list of secure MAC addresses, up to the maximum. Entries get onto the list in three ways. Static entries are configured by hand. Dynamic entries are learned from the first frames seen and are forgotten when the port goes down or the switch reloads. Sticky entries are learned the same way but written into the running configuration, so they survive a link flap — and a reload too, if the configuration is saved.
A violation occurs when a frame arrives from an address that is not on the list while the list is full, or when an address that is secure on one port shows up on another secure port in the same VLAN.
What happens next depends on the mode. protect drops the frames and says nothing. restrict drops them, raises the violation counter and sends a log message. shutdown, the default, puts the port in err-disabled state: the link goes down for everyone on the port, including the legitimate device.
Dynamic entries do not time out by default. With switchport port-security aging time <minutes> they can, which suits ports where devices change often.
State model and protocol mechanics
Port Security attaches a secure-MAC policy to a switchport. Secure addresses can be statically configured, dynamically learned, or learned with sticky behavior that converts observed addresses into configuration-style secure entries. The maximum count defines how many secure source MAC addresses the port may accept, while the violation mode determines what happens when a new source exceeds the policy or conflicts with a secure address seen elsewhere. Protect and restrict generally discard violating traffic with different visibility behavior; shutdown commonly drives the port into an error-disabled state after a violation. The key state is therefore not merely physical link-up: it includes port-security enabled state, secure-address count, violation count, last source involved and whether the interface remains forwarding. A phone-plus-PC edge port can legitimately require more than one secure MAC and must be designed with the voice/data topology in mind.
Limits and common misconceptions
Port Security does not authenticate a human or show device legitimacy; MAC addresses can change and can be spoofed. A port that is forwarding with the expected secure MAC does not show correct IP addressing, DHCP, VLAN reachability or application health. A violation counter shows the switch observed traffic conflicting with the configured secure-MAC policy, not necessarily malicious behavior—legitimate endpoint moves or an undersized maximum can trigger the same state. Sticky addresses are configuration state and can outlive the endpoint that caused them to be learned. Do not use Port Security as a substitute for loop prevention, DHCP Snooping/DAI, NAC or firewall policy. Interpret it as one Layer 2 edge-control boundary within the larger access design.
ReferenceConfiguration & state1 section · depth on demand
Design and configuration model
Use Port Security only on interfaces whose endpoint population is sufficiently predictable. Configure the intended access/voice VLAN behavior first, then enable port security, choose an explicit maximum, decide whether secure addresses are static/dynamic/sticky and select the violation action appropriate to the operational policy. Sticky learning can simplify deployment but it changes the configuration state as endpoints are learned, so replacement procedures need to account for old secure addresses. Avoid blindly setting maximum one on every access port because IP phones, hypervisors, downstream unmanaged devices or legitimate endpoint transitions can require different counts. Pair the feature with clear errdisable recovery policy if shutdown mode is used. For stronger identity-based access decisions, use mechanisms such as 802.1X/MAB rather than interpreting a MAC-address allowlist as cryptographic user or device identity.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Switching → Layer 2 Security → Port Security. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.cisco.com/c/en/us/support/ios-nx-os-software/ios-xe-17/series.html · confidence 94%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Quick lookup tables
Port Security violation modes
Fast comparison of Cisco violation actions
| Mode | Violating frames | Counter/reporting | Port state | Operational use |
|---|---|---|---|---|
| protect | dropped | limited visibility compared with restrict | remains up | least disruptive filtering |
| restrict | dropped | violation counter/reporting on common platforms | remains up | enforce while retaining visibility |
| shutdown | dropped | violation recorded | commonly err-disabled/security shutdown | strongest/default-style enforcement on many platforms |
Secure MAC learning modes
How secure identities enter the port-security table
| Method | How learned | Persistence/intent | Check |
|---|---|---|---|
| Static | explicitly configured MAC | deterministic endpoint identity | config + show port-security address |
| Dynamic secure | learned while port security operates | runtime learned state | show port-security address |
| Sticky | learned and represented as sticky secure state/config on supported IOS/IOS XE | convenient learning with configurable persistence workflow | running config + secure-address output |
Port Security · operational reference
Compact state and interpretation boundaries for fast lookup.
| Violation mode | Forwarding effect | Operational meaning |
|---|---|---|
| protect | Violating sources dropped | Low visibility, port stays up |
| restrict | Violating sources dropped | Counter/log visibility, port stays up |
| shutdown | Port can become error-disabled | Explicit recovery may be required |
| secure MAC present | Source admitted by MAC policy | Does not authenticate user/device identity |
Port Security operational reference
Topic-specific bounded interpretation: known-good state, suspicious signatures and the next technical proof boundary.
| Boundary | Known-good for Port Security | Suspicious signature | Next proof |
|---|---|---|---|
| Intent | Matches the access-port source-MAC admission boundary, including secure MAC learning, maximum counts, violation mode and recovery design | Configuration differs from design/peer | Compare effective configuration |
| Control/security state | Stable expected neighbor/database/binding/election state | unexpected secure MAC after a device move, maximum count reached by phone/PC/hypervisor combinations, shutdown violation causing err-disable, sticky learning preserving an obsolete address, or protect/restrict silently dropping traffic while link state remains up | Inspect protocol/security detail and adjacent state |
| Forwarding | Expected Layer-2 or RIB/FIB/gateway path | Control state exists but traffic path disagrees | MAC/ARP/RIB/FIB/CEF proof |
| Closure | Original test passes for explained reason | Symptom moved, was bypassed or protection disabled | Regression test |