show mac address-table – CAM Table, MAC Learning, Port Security & Attacks
1. What Is the MAC Address Table (CAM Table)?
The MAC address table — also called the CAM table (Content Addressable Memory table) — is the switch's forwarding database. It maps Layer 2 MAC addresses to the physical switch ports (and VLANs) where those devices were last seen. The switch uses this table to make intelligent forwarding decisions: rather than flooding every frame out every port, it sends frames only out the specific port where the destination device lives.
Without MAC address table (switch behaviour on first frame): PC-A sends frame to PC-B. Switch has never seen PC-B's MAC. Switch FLOODS the frame out ALL ports except the incoming port. PC-B receives it and replies. Switch learns PC-B's port from the reply. With MAC address table (subsequent frames): PC-A sends frame to PC-B. Switch looks up PC-B's MAC: found on Gi0/3. Switch UNICASTS the frame ONLY out Gi0/3. All other ports are silent. This is the fundamental difference between a HUB (always floods) and a SWITCH (forwards intelligently using the CAM table). CAM table structure: +--------+-------------------+----------+------------+ | VLAN | MAC Address | Type | Port | +--------+-------------------+----------+------------+ | 1 | 0001.63ab.cd22 | DYNAMIC | Gi0/1 | | 10 | 0050.56be.325c | STATIC | Gi0/2 | | 20 | 0090.abcd.1234 | SECURE | Gi0/10 | | 100 | aabb.ccdd.eeff | DYNAMIC | Gi0/24 | +--------+-------------------+----------+------------+
Related pages: MAC Address Table | VLANs & Trunk Ports | PortFast & BPDU Guard | ACL Overview | Port Security & Sticky MAC Lab | VLAN Creation & Management Lab
2. How MAC Address Learning Works — Step by Step
MAC learning process:
Initial state: CAM table is empty.
Step 1 — Frame arrives on port Gi0/1 from PC-A (MAC: 0011.AAAA.AAAA):
Source MAC 0011.AAAA.AAAA seen on Gi0/1, VLAN 10
-> ADD to table: VLAN 10 | 0011.AAAA.AAAA | DYNAMIC | Gi0/1
Aging timer: RESET to 300 seconds for this entry
Step 2 — Destination lookup (PC-B: 0022.BBBB.BBBB):
Not in table -> UNKNOWN UNICAST
-> FLOOD frame out ALL ports in VLAN 10 EXCEPT Gi0/1 (ingress)
Step 3 — PC-B replies from port Gi0/3:
Source MAC 0022.BBBB.BBBB seen on Gi0/3, VLAN 10
-> ADD to table: VLAN 10 | 0022.BBBB.BBBB | DYNAMIC | Gi0/3
Step 4 — PC-A sends second frame to PC-B:
Destination 0022.BBBB.BBBB -> FOUND in table on Gi0/3
-> UNICAST frame directly out Gi0/3 only
-> RESET aging timer for 0011.AAAA.AAAA (entry refreshed)
Step 5 — PC-A is silent for 300 seconds:
Aging timer for 0011.AAAA.AAAA reaches zero
-> REMOVE entry from table
Next frame from PC-A will trigger a new learn + flood cycle
3. show mac address-table — Full Command Reference
! ── Full table ────────────────────────────────────────────────────────────
Switch# show mac address-table
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- ---- -----
1 0001.63ab.cd22 DYNAMIC Gi0/1
10 0050.56be.325c STATIC Gi0/2
20 0090.abcd.1234 SECURE Gi0/10
100 aabb.ccdd.eeff DYNAMIC Gi0/24
100 aabb.ccdd.1111 DYNAMIC Gi0/24 <-- two MACs on same port (trunk or hub)
Total Mac Addresses for this criterion: 5
! ── Filter by VLAN ────────────────────────────────────────────────────────
Switch# show mac address-table vlan 10
! Shows only MAC entries in VLAN 10 -- useful when investigating a specific VLAN
! ── Filter by interface ───────────────────────────────────────────────────
Switch# show mac address-table interface GigabitEthernet0/24
! Shows only MACs learned on Gi0/24 -- useful to confirm what's connected
! ── Filter by MAC address ─────────────────────────────────────────────────
Switch# show mac address-table address aabb.ccdd.eeff
! Find which port a specific MAC is connected to
! ── Show only dynamic entries ─────────────────────────────────────────────
Switch# show mac address-table dynamic
! Excludes static and secure entries -- shows only auto-learned MACs
! ── Show table count ──────────────────────────────────────────────────────
Switch# show mac address-table count
Mac Entries for all vlans:
Dynamic Address Count : 4842
Static Address Count : 3
Secure Address Count : 12
System Address Count : 0
Total Mac Address Space Available: 3196
! ── Show aging time ───────────────────────────────────────────────────────
Switch# show mac address-table aging-time
Global Aging Time: 300
! ── Clear dynamic entries ─────────────────────────────────────────────────
Switch# clear mac address-table dynamic
Switch# clear mac address-table dynamic vlan 10
Switch# clear mac address-table dynamic interface GigabitEthernet0/1
Switch# clear mac address-table dynamic address 0011.AAAA.AAAA
4. Output Fields — Field-by-Field Explanation
| Field | Description | Details |
|---|---|---|
| VLAN | VLAN ID the MAC address belongs to | Each VLAN maintains its own separate MAC table. The same MAC address can exist in different VLANs simultaneously (e.g., same MAC on a trunk port carrying multiple VLANs). MAC entries in VLAN 1 are for the native/management VLAN. |
| MAC Address | The 48-bit Layer 2 hardware address of the device | Displayed in Cisco dotted notation (xxxx.xxxx.xxxx). First 24 bits = OUI (Organizationally Unique Identifier — identifies the manufacturer). Last 24 bits = device-specific identifier. OUI lookup can identify device manufacturer. |
| Type | How the MAC address entry was created | DYNAMIC: auto-learned from incoming frames, subject to aging. STATIC: manually configured, permanent, no aging. SECURE: learned or configured via port security, may be sticky. |
| Ports | The switch port where the MAC address was last seen | For access ports: typically one MAC per port (end device). For trunk ports: many MACs (traffic from multiple downstream devices). "CPU" appears for control-plane traffic (STP BPDUs, CDP, etc.). |
MAC Address Format — Notation Styles
| Format | Example | Used By |
|---|---|---|
| Cisco dotted notation | 0011.2233.4455 | Cisco IOS (show mac address-table) |
| Colon-separated | 00:11:22:33:44:55 | Linux, macOS, most non-Cisco equipment |
| Hyphen-separated | 00-11-22-33-44-55 | Windows (ipconfig /all), IEEE standard |
5. Entry Types — Dynamic, Static, Secure, and Sticky
| Type | How Created | Ages Out? | Survives Reload? | Typical Use |
|---|---|---|---|---|
| DYNAMIC | Automatically learned from source MAC of incoming frames | Yes — removed after aging timer (default 300 sec inactivity) | No — lost on reload or link down | Standard end-user devices; the vast majority of MAC entries |
| STATIC | Manually configured by administrator | No — permanent until manually removed | Yes (if in running-config and saved) | Critical servers/printers; prevent MAC-based attacks on specific devices; permanent forwarding for infrastructure |
| SECURE | Learned or manually configured via port security | Depends on port security config | Only if sticky (saved to running-config) | Access ports with port security — restrict which MACs can use a port |
| STICKY (Secure) | Dynamically learned AND saved to running-config by port security | No — written to config, persists across reloads if saved | Yes — written to running-config, survives reload if copied to startup-config | Best of both worlds: auto-learn the first device connected, then lock that port permanently to that MAC |
Configuring Static MAC Entries
! Add a static MAC entry — permanent, no aging: Switch(config)# mac address-table static 0050.56BE.325C vlan 10 interface Gi0/2 ! Verify: Switch# show mac address-table address 0050.56BE.325C Vlan Mac Address Type Ports ---- ----------- ---- ----- 10 0050.56be.325c STATIC Gi0/2 ! Remove a static entry: Switch(config)# no mac address-table static 0050.56BE.325C vlan 10 interface Gi0/2
6. Aging Timer — Management and Tuning
The aging timer controls how long a dynamic MAC entry remains in the table without being refreshed. Every time a frame arrives from a MAC address, its aging timer resets to the full value. If the timer reaches zero (no frames received), the entry is removed.
! Check current aging time: Switch# show mac address-table aging-time Global Aging Time: 300 <-- 300 seconds = 5 minutes (default) ! Change global aging time: Switch(config)# mac address-table aging-time 600 ! Range: 10–1000000 seconds; 0 = disable aging (entries never removed) ! Change aging time per VLAN: Switch(config)# mac address-table aging-time 120 vlan 10 ! VLAN 10 entries age out in 120 seconds; other VLANs use global setting ! Disable aging completely (not recommended for production): Switch(config)# mac address-table aging-time 0 ! Entries only removed manually or on link down
| Aging Time Setting | Effect | When to Use |
|---|---|---|
| Very short (10–60 sec) | Entries age out quickly; more flooding of returning devices; table stays small | Environments with very mobile devices; testing; high security where stale entries are a risk |
| Default (300 sec) | Balance between table freshness and re-learning overhead | Standard enterprise environments — recommended |
| Longer (600–1000 sec) | Entries persist longer; less re-flooding for infrequently communicating devices | Environments with devices that communicate infrequently (e.g., backup servers, printers) |
| Disabled (0) | Entries never age out; table grows until full; stale entries for disconnected devices remain | Rarely appropriate; only for special static-like environments |
7. VLANs, Trunk Ports, and MAC Table Entries
Each VLAN maintains a logically separate MAC address table. A MAC address is always associated with a specific VLAN — the same physical MAC can appear in the table multiple times if it communicates across multiple VLANs (typically on a trunk port).
Multi-VLAN MAC address table example:
Switch# show mac address-table
Vlan Mac Address Type Ports
---- ----------- ---- -----
10 00A1.B2C3.D4E5 DYNAMIC Gi0/12 <-- PC in VLAN 10
10 00BB.CCDD.EE01 DYNAMIC Gi0/1 <-- another PC in VLAN 10
20 0050.56BE.325C DYNAMIC Gi0/12 <-- same port Gi0/12, VLAN 20
20 00F6.12AB.3456 DYNAMIC Gi0/15 <-- PC in VLAN 20
30 0011.2233.4455 DYNAMIC Gi0/12 <-- same port Gi0/12, VLAN 30
1 aabb.ccdd.0001 DYNAMIC Gi0/24 <-- management VLAN
1 0100.0CCC.CCCC STATIC CPU <-- Cisco CDP/VTP multicast
Interpretation:
Gi0/12 has MACs in VLAN 10, 20, and 30 -> this is a TRUNK PORT
(carries tagged frames for multiple VLANs)
Gi0/1, Gi0/15, Gi0/24 each have MACs in only one VLAN -> ACCESS PORTS
CPU entry -> control-plane MAC (used for STP, CDP, VTP, LLDP)
Key rules:
- Broadcast/unknown unicast within VLAN 10 is flooded ONLY to VLAN 10 ports
- VLAN 20 traffic never reaches VLAN 10 ports (Layer 2 isolation)
- The trunk port (Gi0/12) carries ALL VLANs and appears in all VLAN entries
8. Port Security — Restricting MAC Addresses Per Port
Port security allows an administrator to limit the number and identity of MAC addresses that can use a switch port. When a violation occurs (an unauthorised MAC is detected), the switch can take one of three configurable actions.
Port Security Violation Modes
| Mode | Frames from Violating MAC | Port Status | Syslog / Trap | Violation Counter | Recovery |
|---|---|---|---|---|---|
| Shutdown (default) |
Dropped | err-disabled (effectively shut down) | Yes — syslog + SNMP trap | Incremented | Manual: shutdown then no shutdown,
OR auto-recovery timer |
| Restrict | Dropped | Remains UP — allows permitted MACs to continue | Yes — syslog + SNMP trap | Incremented | Automatic — port stays up; only offending frames dropped |
| Protect | Dropped silently | Remains UP | No — silent drop; no notification | Not incremented | Automatic — port stays up; violation invisible unless proactively checked |
Port Security Configuration
! ── Basic port security (max 1 MAC, shutdown on violation) ───────────────
Switch(config)# interface GigabitEthernet0/1
Switch(config-if)# switchport mode access ! Port security requires access mode
Switch(config-if)# switchport port-security ! Enable port security
Switch(config-if)# switchport port-security maximum 1 ! Allow only 1 MAC address
Switch(config-if)# switchport port-security violation shutdown ! Default mode
! ── Sticky MAC — auto-learn first device, lock permanently ───────────────
Switch(config-if)# switchport port-security mac-address sticky
! Switch learns the first MAC that connects and saves it to running-config as:
! switchport port-security mac-address sticky 0011.AAAA.AAAA
! This MAC is now "sticky" -- persists across reloads if config saved
! ── Manually specify allowed MAC ─────────────────────────────────────────
Switch(config-if)# switchport port-security mac-address 0050.56BE.325C
! Only this specific MAC is allowed on this port; all others trigger violation
! ── Set violation mode to restrict instead of shutdown ───────────────────
Switch(config-if)# switchport port-security violation restrict
! ── Auto-recovery from err-disabled ──────────────────────────────────────
Switch(config)# errdisable recovery cause psecure-violation
Switch(config)# errdisable recovery interval 300
! Port automatically re-enables after 300 seconds
! ── Verify port security ──────────────────────────────────────────────────
Switch# show port-security interface GigabitEthernet0/1
Port Security : Enabled
Port Status : Secure-up <-- or Secure-shutdown if violated
Violation Mode : Shutdown
Aging Time : 0 mins
Aging Type : Absolute
SecureStatic Address Aging : Disabled
Maximum MAC Addresses : 1
Total MAC Addresses : 1
Configured MAC Addresses : 0
Sticky MAC Addresses : 1 <-- sticky entry learned and saved
Last Source Address:Vlan : 0011.AAAA.AAAA:10
Security Violation Count : 0
! ── Show all ports with port security ────────────────────────────────────
Switch# show port-security
Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action
- ------------- ----------- ----------------- ---------------
Gi0/1 1 1 0 Shutdown
Gi0/10 2 1 0 Restrict
9. MAC Flooding Attack
A MAC flooding attack (also called a CAM table overflow attack) is a Layer 2 attack where a malicious device sends millions of frames with spoofed, random source MAC addresses. This intentionally fills the switch's CAM table, forcing it into a "fail-open" state where it floods all frames out every port — turning the switch into a hub.
MAC flooding attack: Attacker sends frames with random MACs: Frame 1: src=AAAA.0001.0001 dst=... Frame 2: src=AAAA.0001.0002 dst=... Frame 3: src=AAAA.0001.0003 dst=... ... (thousands per second) Switch CAM table fills up (e.g., all 8K entries occupied): Legitimate MAC for PC-B ages out and cannot be re-learned (table full) New frame destined for PC-B -> UNKNOWN UNICAST -> FLOODED to all ports Attacker on Gi0/5 now RECEIVES ALL frames including: - Banking website sessions of PC-A (VLAN 10) - Corporate email of PC-C (VLAN 10) - Any unencrypted traffic in the VLAN This is equivalent to a network tap -- attacker can capture credentials
Mitigations
- Port security with MAC limit:
switchport port-security maximum 5— limits how many MACs any one port can learn; attacker's flood is contained to the maximum on their port - Dynamic ARP Inspection (DAI): validates ARP packets against DHCP snooping binding table — reduces the effectiveness of attacks that follow CAM overflow
- DHCP snooping: limits which ports can act as DHCP servers; builds a binding table used by DAI
- 802.1X port authentication: requires devices to authenticate before the port becomes active — prevents unauthenticated attackers from connecting at all
10. MAC Flapping — Diagnosis and Resolution
MAC flapping occurs when the switch sees the same source MAC address arriving on different ports in rapid succession. The switch keeps updating the MAC table entry to point to alternating ports, causing the flapping. This typically indicates a Layer 2 loop.
MAC flapping caused by a Layer 2 loop: PC-A (MAC: 0011.AAAA.AAAA) is connected to SW1-Gi0/1. There is a loop: SW1-Gi0/3 --> SW2 --> SW1-Gi0/4 (no STP blocking) PC-A sends a frame: SW1 learns: 0011.AAAA.AAAA on Gi0/1 Frame loops around: arrives at SW1 Gi0/4 (via SW2) SW1 re-learns: 0011.AAAA.AAAA on Gi0/4 <-- FLAP! Frame loops again: arrives at SW1 Gi0/3 SW1 re-learns: 0011.AAAA.AAAA on Gi0/3 <-- FLAP! (continues until STP converges or network collapses) Syslog messages indicating flapping: %SW_MATM-4-MACFLAP_NOTIF: Host 0011.AAAA.AAAA in vlan 10 is flapping between port Gi0/1 and port Gi0/4 Other causes of MAC flapping: - Unmanaged switches (no STP) connected creating loops - EtherChannel misconfiguration (LACP/PAgP mismatch) - VM mobility (virtual MAC moving between hypervisor hosts) - Dual-homed server with two active uplinks in the same VLAN
Diagnosing MAC Flapping
! Check syslog for flapping messages: Switch# show logging | include MACFLAP %SW_MATM-4-MACFLAP_NOTIF: Host 0011.aaaa.aaaa in vlan 10 is flapping between port Gi0/1 and port Gi0/4 ! Check MAC address table for the flapping MAC: Switch# show mac address-table address 0011.AAAA.AAAA Vlan Mac Address Type Ports 10 0011.aaaa.aaaa DYNAMIC Gi0/4 <-- currently on Gi0/4 (was Gi0/1) ! Check if STP is active on both ports (should be blocking one): Switch# show spanning-tree vlan 10 interface Gi0/4 Vlan Role Sts Cost Prio.Nbr Type ------------------- ---- --- --------- -------- ---- VLAN0010 Altn BLK 4 128.4 P2p <-- should be blocking ! If this shows FWD (forwarding) for both Gi0/1 and Gi0/4 -> STP not blocking = loop ! Check for physical loop (CDP neighbors): Switch# show cdp neighbors ! Look for unexpected neighbour connections forming a loop
11. MAC Spoofing
MAC spoofing is when an attacker changes their device's MAC address to impersonate another device. Against the CAM table, this causes the switch to point the victim's MAC entry to the attacker's port — redirecting the victim's traffic to the attacker.
MAC spoofing attack: Normal state: Switch CAM: 0011.AAAA.AAAA -> Gi0/1 (PC-A's legitimate port) Attacker on Gi0/5 changes their MAC to 0011.AAAA.AAAA and sends a frame: Switch sees source MAC 0011.AAAA.AAAA on Gi0/5 -> Updates CAM: 0011.AAAA.AAAA -> Gi0/5 (now points to attacker!) Traffic intended for PC-A (0011.AAAA.AAAA) is now forwarded to Gi0/5 Attacker intercepts the traffic. PC-A receives nothing.
Mitigations against MAC spoofing:
- Port security with sticky MAC: once the legitimate MAC is locked to a port, another port claiming the same MAC triggers a violation
- Dynamic ARP Inspection: validates IP-to-MAC bindings using the DHCP snooping table — prevents ARP spoofing which often accompanies MAC spoofing
- 802.1X: requires cryptographic authentication before any traffic is allowed — the MAC address alone cannot grant access
12. CAM Table Overflow — Size Limits and Consequences
Every switch has a finite CAM table determined by its ASIC hardware. Understanding the limits and what happens at overflow is critical for both design and security.
! Check current table utilisation: Switch# show mac address-table count Mac Entries for all vlans: Dynamic Address Count : 7841 Static Address Count : 3 Secure Address Count : 12 System Address Count : 6 Total Mac Address Space Available: 161 <-- ONLY 161 ENTRIES LEFT! ! This switch is nearly at capacity -- MAC flooding risk is high
| Switch Family | Typical CAM Size | Notes |
|---|---|---|
| Cisco Catalyst 2960 | 8,192 entries | Small enterprise / access layer |
| Cisco Catalyst 3750/3850 | 12,288–32,768 entries | Distribution / aggregation layer |
| Cisco Catalyst 9300 | 32,768+ entries | Modern access / distribution |
| Cisco Catalyst 9500 | 128,000+ entries | Core / data centre aggregation |
13. Troubleshooting Scenarios
| Symptom | Likely Cause | Diagnostic Command | Fix |
|---|---|---|---|
| Expected device MAC not in table | Device not sending frames; port shut down; cable disconnected; entry aged out | show mac address-table,
show interfaces Gi0/x status |
Verify physical connection; confirm port is up/up; have device send traffic to trigger MAC learning |
| Same MAC appearing on multiple ports | Layer 2 loop (STP not blocking); MAC spoofing attack; VM migration | show logging | include MACFLAP,
show spanning-tree |
Identify and break the loop; verify STP is blocking redundant ports; investigate spoofing |
| Rapid growth of MAC table entries | MAC flooding attack; device with misconfigured MAC randomisation | show mac address-table count,
show mac address-table dynamic |
Enable port security with MAC limits on access ports; identify attacking port and isolate it |
| Port in err-disabled state | Port security violation (too many MACs or unauthorised MAC detected) | show interfaces status err-disabled,
show port-security interface Gi0/x |
Identify and remove unauthorized device;
shutdown then no shutdown
to restore port |
| Intermittent connectivity for specific device | MAC entry timing out and device not sending enough traffic to maintain entry; aging time too short | show mac address-table address <MAC> |
Increase aging time for the VLAN; or configure a static MAC entry for the device |
14. Key Points & Exam Tips
- The MAC address table (CAM table) maps MAC addresses to switch ports and VLANs. Switches forward frames to the specific port of the destination MAC; when unknown, they flood out all ports in the same VLAN.
- Learning process: Switch reads the SOURCE MAC of every incoming frame and records it against the incoming port and VLAN. Destination lookup uses this learned data for forwarding.
- Entry types: DYNAMIC (auto-learned, ages out after default 300 sec), STATIC (manually configured, permanent), SECURE (port security), STICKY (auto-learned but saved to config, persists across reloads if saved).
- Aging timer: Default 300 seconds. Resets to full value every time a frame arrives from that MAC. Reaches zero with no traffic → entry removed → next frame causes re-learn + unknown unicast flood.
- Port security violation modes: Shutdown (err-disables port, logs — default), Restrict (drops violating frames, logs, port stays up), Protect (drops silently, no log, port stays up).
- Sticky MAC: combines auto-learning with persistence — learned MAC
is written to running-config as a secure static entry. Survives reload
if
copy running startupis performed. - MAC flooding attack: fills CAM table with random spoofed MACs → switch floods all frames → attacker sees all traffic. Mitigate with port security MAC limits.
- MAC flapping: same MAC seen on multiple ports rapidly → indicates
Layer 2 loop or MAC spoofing. Check
show loggingfor MACFLAP messages; verify STP is blocking redundant paths. - Table overflow: switch cannot learn new MACs → all unknown unicast flooded → performance degradation and security risk (all traffic visible to all ports in VLAN).
- Key commands:
show mac address-table,show mac address-table vlan [id],show mac address-table interface [int],show mac address-table count,show port-security interface [int],clear mac address-table dynamic.
Related pages: MAC Address Table | VLANs & Trunk Ports | PortFast & BPDU Guard | Root Bridge Election (STP) | ACL Overview | Port Security & Sticky MAC Lab | VLAN Creation & Management Lab