MAC Address Table β Comprehensive Guide
1. What is a MAC Address Table?
The MAC Address Table (also called CAM Table β Content Addressable Memory Table) is a database switches use to map MAC addresses to physical switch ports and VLANs.
Purpose: Enables efficient Layer 2 frame forwarding by letting the switch know exactly which port a frame should go to, instead of broadcasting it everywhere.
2. Role in Layer 2 Switching
At Layer 2, switches use the MAC table to forward frames only to the port where the destination device is connected. This improves bandwidth use and reduces unnecessary traffic, unlike a hub which floods traffic to all ports.
3. How MAC Addresses are Learned
- When a frame arrives, the switch records the source MAC address, port, and VLAN in the MAC table.
- Most entries are dynamically learned from real network traffic.
- Static MACs can be configured by admins for critical devices.
Example:
MAC: AA-AA-AA-AA-AA-AA | Port: 1 | VLAN: 10 | Type: Dynamic
4. MAC Address Table Structure
Field | Description |
---|---|
MAC Address | Device's hardware (Layer 2) address |
Port | Physical switch port (e.g., Fa0/1) |
VLAN | VLAN membership (e.g., 10) |
Type | Dynamic or Static |
Table Size: Limited by hardware (e.g., 8,192 entries). Exceeding this may cause MAC flooding (see below).
5. Aging and Timeout
- Dynamically learned entries have an aging timer (default 300s typical). If not seen in that time, the entry is removed.
- Static entries do not age outβmust be manually deleted.
6. Static vs. Dynamic MAC Addresses
Aspect | Dynamic | Static |
---|---|---|
Learning | Automatic (from traffic) | Manual (admin-configured) |
Aging | Yes | No |
Use Cases | Standard hosts/devices | Critical devices, security |
Cisco Example:
switch(config)# mac address-table static AA-AA-AA-AA-AA-AA vlan 10 interface fastEthernet 0/1
7. MAC Table Lookup Process
- If destination MAC found: frame forwarded to correct port(s).
- If not found: switch floods the frame to all ports in that VLAN except source.
8. VLAN and MAC Address Table
- Each VLAN has a separate MAC address table context.
- The same MAC may appear on different VLANs with different ports.
Prevents inter-VLAN frame leakage.
9. MAC Address Table Overflow
Overflow Symptoms: Switch begins flooding all unknown traffic (acts like a hub).
Security risk: Attackers can flood switch with fake MACs (MAC flooding attack).
Prevention: Use Port Security to limit learned MACs per port.
10. Viewing the MAC Address Table
show mac address-table show mac-address-table
Sample Output:
VLAN MAC Address Type Ports ---- --------------- ------- ----- 10 AA-AA-AA-AA-AA-AA DYNAMIC Fa0/1 20 BB-BB-BB-BB-BB-BB STATIC Fa0/2
11. Aging Time Configuration
switch(config)# mac address-table aging-time 600
Short aging causes more flooding; long aging can delay removal of unused MACs.
12. MAC Address Table and Switchport Security
- Port Security: Restricts number of allowed MACs per port.
- Actions on violation: Shutdown, Restrict, Protect.
- Sticky MAC: Dynamically learned MACs are saved as static.
switch(config-if)# switchport port-security switch(config-if)# switchport port-security mac-address sticky
13. MAC Address Table in Multi-Switch Environments
- Trunk ports: MACs are learned and shared across switches.
- Spanning Tree: May block ports, affecting MAC learning.
- EtherChannel: Multiple links act as one; MACs mapped to port-channel.
14. Troubleshooting MAC Address Issues
Problem | Cause | Solution |
---|---|---|
Incorrect MAC learning | Network loops, trunk misconfiguration | Check VLAN/trunk/STP config |
MAC Flapping | Same MAC on multiple ports | Investigate for loops or moving devices |
Use these commands:
show mac address-table show interfaces status show spanning-tree
π Summary Table
Field | Description |
---|---|
MAC Address | Device hardware address (e.g., 00-1A-2B-3C-4D-5E) |
Port | Switch port (e.g., Fa0/1) |
VLAN | VLAN membership (e.g., 10) |
Type | Dynamic or Static |
Age | Time since last activity |
π§βπ» When and Why to Use MAC Address Tables
- Switch forwarding decisions in Layer 2 environments
- Troubleshooting device connectivity, loops, or broadcast storms
- Security: Limit access by MAC (Port Security)
- Monitor for overflow or abnormal behavior
π Example Scenario
PC1: MAC 00:11:22:33:44:55 on Fa0/1 VLAN 10
PC2: MAC 00:11:22:33:44:66 on Fa0/2 VLAN 10
When PC1 sends a frame, switch learns its MAC and port. When PC2 replies, switch learns its MAC and port. Afterwards, unicast frames are sent only to the correct port (no flooding).