Pcornel
Browse topics
Options
Recent
Favorites
Networking · Technical reference

Port Security

Direct answer

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.

When to use this

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.

First 30 seconds

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.

Operational verification

MAC learned → count/allowed checked → violation action

Evidence · next step

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
Platform / version applicability
Cisco IOS / IOS XE
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformCisco IOS / IOS XE · Cisco IOS XE
Key commandswitchport mode access
Scope / prerequisiteUse it when the design or fault is specifically about the access-port source-MAC admission boundary, including secure M…
Show · 3Reference · 11
What next?3 suggested next steps
Catalog command links14
Evidence4
On this pageJump to a specific section
Cisco IOS / IOS XE first

Primary Commands

Configuration and operational commands for this Topic.

Verification

Show Commands

Read-only Cisco show commands for confirming state, narrowing a fault and interpreting the current boundary.

Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

6 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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 protect drops silently; restrict at least counts and logs.
  • switchport port-security maximum is configured but nothing is enforced. The plain switchport port-security command 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-up and 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 references

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.

command output · 3other · 1
Command lookup Jump straight to Cisco syntax
Key points

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.

Key checks
  • show port-security — secure ports, violations
  • show port-security interface <interface> — max MACs, violation mode
  • show 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 access first.
  • 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: protect drops silently, restrict drops and logs and counts, shutdown err-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 shutdown or 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)

ModeDrops unknown sourcesNotificationPort
protectYesNone, no counterStays up
restrictYesSyslog, SNMP trap, counterStays up
shutdown (default)Whole portCounter (the guide is inconsistent about syslog)Err-disabled
shutdown vlanThat VLAN onlySyslog, counterVLAN err-disabled

Secure address types

TypeStored in
StaticAddress table and running config
DynamicAddress table only; gone after restart
StickyAddress 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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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 modeAction
shutdown (default)Err-disable port
restrictDrop and log/count
protectDrop silently

Allow at least two MACs on ports with an IP phone and PC. 802.1X is the stronger, identity-based alternative.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docCisco IOS / IOS XE Current documentation reviewed 2026-09-14

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%
Technical changelog & impact

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.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Embedded reference data

Quick lookup tables

Port Security violation modes

Fast comparison of Cisco violation actions

ModeViolating framesCounter/reportingPort stateOperational use
protectdroppedlimited visibility compared with restrictremains upleast disruptive filtering
restrictdroppedviolation counter/reporting on common platformsremains upenforce while retaining visibility
shutdowndroppedviolation recordedcommonly err-disabled/security shutdownstrongest/default-style enforcement on many platforms

Secure MAC learning modes

How secure identities enter the port-security table

MethodHow learnedPersistence/intentCheck
Staticexplicitly configured MACdeterministic endpoint identityconfig + show port-security address
Dynamic securelearned while port security operatesruntime learned stateshow port-security address
Stickylearned and represented as sticky secure state/config on supported IOS/IOS XEconvenient learning with configurable persistence workflowrunning config + secure-address output

Port Security · operational reference

Compact state and interpretation boundaries for fast lookup.

Violation modeForwarding effectOperational meaning
protectViolating sources droppedLow visibility, port stays up
restrictViolating sources droppedCounter/log visibility, port stays up
shutdownPort can become error-disabledExplicit recovery may be required
secure MAC presentSource admitted by MAC policyDoes not authenticate user/device identity

Port Security operational reference

Topic-specific bounded interpretation: known-good state, suspicious signatures and the next technical proof boundary.

BoundaryKnown-good for Port SecuritySuspicious signatureNext proof
IntentMatches the access-port source-MAC admission boundary, including secure MAC learning, maximum counts, violation mode and recovery designConfiguration differs from design/peerCompare effective configuration
Control/security stateStable expected neighbor/database/binding/election stateunexpected 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 upInspect protocol/security detail and adjacent state
ForwardingExpected Layer-2 or RIB/FIB/gateway pathControl state exists but traffic path disagreesMAC/ARP/RIB/FIB/CEF proof
ClosureOriginal test passes for explained reasonSymptom moved, was bypassed or protection disabledRegression test
Confirmation

Confirm action

Continue?