Tutorial 6.11: Link-Layer Security and Network Protection Mechanisms

Table of Contents

Learning Objectives

Upon completion of this tutorial, you should be able to:

Overview

While network security often focuses on higher layers (e.g., firewalls, encryption), the link layer is a critical attack surface. Attackers can exploit vulnerabilities in Ethernet switching, ARP, and VLANs to launch man-in-the-middle attacks, denial-of-service attacks, and network reconnaissance. This tutorial covers the major link-layer security threats—MAC spoofing, ARP poisoning, VLAN hopping—and the protection mechanisms available in modern switches: port security, DHCP snooping, Dynamic ARP Inspection (DAI), IP Source Guard, 802.1X, and MACsec. Understanding these threats and defenses is essential for designing robust, resilient enterprise and data-center networks.

Technical and Theoretical Content

1. The Link-Layer Attack Surface

The link layer (Layer 2) is inherently trust-based: switches forward frames based on MAC addresses without authentication. This trust model enables several attack vectors:

These attacks can lead to data interception, session hijacking, denial-of-service, and network recon.

2. MAC Address Spoofing and MAC Flooding

2.1 MAC Spoofing

An attacker changes their NIC's MAC address to impersonate a legitimate device (e.g., a trusted server). This can bypass MAC-based ACLs or VLAN assignments. Mitigation: port security (limit MAC addresses per port) and 802.1X authentication.

2.2 MAC Flooding (CAM Table Overflow)

An attacker sends frames with many different source MAC addresses to fill the switch's CAM table. When the table is full, the switch cannot learn new MACs and begins flooding all frames to all ports (acting as a hub), allowing sniffing. Mitigation: port security limits MACs per port, and switches often have built-in protection (e.g., storm control, MAC address table aging).

3. ARP Spoofing and ARP Poisoning

ARP (Address Resolution Protocol) is stateless and lacks authentication. An attacker sends forged ARP replies to associate their MAC with another IP (e.g., the default gateway). This redirects traffic to the attacker, enabling MitM attacks, session hijacking, or DoS.

Mitigation:

4. VLAN Hopping Attacks

Attackers attempt to access VLANs they are not authorized for. Two common techniques:

5. Switch Security Features: Port Security

Port security restricts the number of MAC addresses allowed on a port and can take action (shutdown, restrict, protect) when a violation occurs.

6. DHCP Snooping, Dynamic ARP Inspection, and IP Source Guard

These three features work together to prevent several Layer 2 attacks:

7. Network Access Control (NAC) and IEEE 802.1X

802.1X provides port-based authentication, allowing only authenticated devices to access the network.

Authentication can be based on username/password, certificates, or MAC addresses (MAB – MAC Authentication Bypass). After successful authentication, the switch can assign VLANs and apply policies dynamically.

8. MACsec (IEEE 802.1AE) – Link-Layer Encryption

MACsec provides point-to-point encryption for Ethernet frames, securing communication between directly connected devices (e.g., switch-to-switch, host-to-switch). It uses GCM-AES-128 encryption and integrity protection. MACsec operates at the link layer, preventing eavesdropping and tampering. It is often used in data centers and high-security environments.

9. Layer 2 Attack Mitigation Best Practices

10. Case Studies: Securing Enterprise and Data-Center LANs

Case Study 1: Enterprise Campus
A university implements 802.1X for all wired and wireless clients, using EAP-TLS with certificates. DHCP snooping and DAI are enabled on access switches. Guest VLAN is isolated with ACLs. Port security is configured for labs (sticky MAC) to prevent device theft.

Case Study 2: Data Center
A cloud provider deploys MACsec between top-of-rack switches and spine switches to encrypt east-west traffic. They also use private VLANs to isolate customer traffic. DAI and IPSG are enabled to prevent ARP and IP spoofing within VLANs.


Quiz

Question 1: Which attack involves flooding a switch with many frames containing different source MAC addresses?

Answer

(b) MAC flooding. This attack overwhelms the CAM table.

Question 2: What is the primary purpose of Dynamic ARP Inspection (DAI)?

Answer

(b) To validate ARP packets and prevent ARP spoofing. DAI uses the DHCP snooping binding table.

Question 3: Which switch security feature restricts the number of MAC addresses on a port?

Answer

(b) Port security. It limits MAC addresses per port.

Question 4: What is the default native VLAN on most switches?

Answer

(b) VLAN 1. It is the default native VLAN.

Question 5: Which protocol provides port-based authentication?

Answer

(c) IEEE 802.1X. It is the standard for port-based authentication.

Question 6: What is the effect of MAC flooding on a switch?

Answer

(b) The switch floods all frames to all ports. This is because the CAM table is full.

Question 7: Which feature prevents IP spoofing on a switch port?

Answer

(b) IP Source Guard. It filters based on IP-MAC bindings.

Question 8: How does a switch spoofing VLAN hopping attack work?

Answer

(b) The attacker negotiates a trunk with the switch using DTP. This gives access to all VLANs.

Question 9: What is the function of DHCP snooping?

Answer

(a) To prevent rogue DHCP servers. It only allows DHCP replies on trusted ports.

Question 10: Which of the following is a best practice for native VLAN on trunk ports?

Answer

(b) Use a unused VLAN (e.g., 999) for native VLAN. This prevents VLAN hopping.

Question 11: What does MACsec provide?

Answer

(b) Encryption for Ethernet frames. MACsec provides link-layer confidentiality and integrity.

Question 12: In port security, which violation mode shuts down the port?

Answer

(c) Shutdown. The port is error-disabled.

Question 13: Which protocol is used by the switch to communicate with the authentication server in 802.1X?

Answer

(a) RADIUS. The switch acts as an authenticator and uses RADIUS.

Question 14: What is the purpose of BPDU Guard on an access port?

Answer

(b) To disable the port if a BPDU is received. It prevents rogue switches.

Question 15: How can ARP spoofing be mitigated?

Answer

(b) Using Dynamic ARP Inspection (DAI). DAI validates ARP packets.

Question 16: What is a common result of ARP poisoning?

Answer

(a) Man-in-the-middle attack. ARP poisoning redirects traffic to the attacker.

Question 17: Which feature can prevent a rogue device from acting as a DHCP server?

Answer

(b) DHCP snooping. It blocks DHCP server replies on untrusted ports.

Question 18: In 802.1X, what is the role of the supplicant?

Answer

(b) The client device seeking network access. The supplicant is the client.

Question 19: Which of the following is a Layer 2 attack that can cause a switch to flood traffic?

Answer

(b) MAC flooding. CAM table overflow causes flooding.

Question 20: What is the purpose of the "sticky" feature in port security?

Answer

(a) To permanently learn MAC addresses. Sticky MAC addresses are saved in the configuration.

Question 21: Which encryption standard is used by MACsec?

Answer

(a) AES-128 (GCM mode). MACsec uses AES-128 GCM.

Question 22: What is a risk of using VLAN 1 for user traffic?

Answer

(b) It is vulnerable to VLAN hopping attacks. VLAN 1 is the default native VLAN and is often targeted.

Question 23: Which of the following is a mitigation for double-tagging VLAN hopping?

Answer

(a) Use a different native VLAN for trunks. Change native VLAN to an unused VLAN.

Question 24: What is the purpose of IP Source Guard?

Answer

(a) To prevent IP spoofing. IP Source Guard filters traffic based on the DHCP binding table.

Question 25: In 802.1X, which entity is responsible for granting or denying network access?

Answer

(d) Both (b) and (c). The authenticator enforces the decision made by the authentication server.

Question 26: What is a common symptom of ARP spoofing?

Answer

(b) Hosts experiencing intermittent connectivity. ARP spoofing can redirect traffic incorrectly.

Question 27: Which switch feature can detect and block a rogue DHCP server?

Answer

(a) DHCP snooping. It only allows DHCP replies on trusted ports.

Question 28: What is the role of the authenticator in 802.1X?

Answer

(b) It is the network device (switch) that controls port access. The authenticator enforces authentication.

Question 29: Which of the following is a best practice for STP security?

Answer

(a) Enable BPDU Guard on all access ports. This prevents rogue switches.

Question 30: What is the purpose of MACsec?

Answer

(a) To provide authentication and encryption for Ethernet frames. MACsec secures link-layer communication.

Question 31: In port security, what is the default maximum number of MAC addresses allowed?

Answer

(a) 1. Default is 1 MAC address per port.

Question 32: What is the effect of enabling DHCP snooping on a VLAN?

Answer

(b) DHCP messages on untrusted ports are filtered. It prevents rogue DHCP servers.

Question 33: Which of the following is an example of a Layer 2 man-in-the-middle attack?

Answer

(b) ARP poisoning. It redirects traffic through the attacker.

Question 34: What is the difference between port security "restrict" and "protect" violation modes?

Answer

(b) Restrict generates logs; protect does not. Restrict sends a syslog/SNMP trap; protect drops frames silently.

Question 35: Which of the following can be used to secure trunk links?

Answer

(a) MACsec. MACsec encrypts traffic on trunk links.

Question 36: What is the primary benefit of using 802.1X in a campus network?

Answer

(b) It allows dynamic VLAN assignment based on user identity. 802.1X can assign VLANs and policies per user.

Question 37: Which feature uses the DHCP snooping binding table to validate ARP packets?

Answer

(b) Dynamic ARP Inspection. DAI validates ARP packets using the binding table.

Question 38: What is the purpose of the "storm control" feature on a switch?

Answer

(a) To limit broadcast, multicast, and unknown unicast traffic. Storm control prevents denial-of-service from flooding.

Question 39: In a secure LAN design, where should port security be applied?

Answer

(b) Access ports connected to end devices. Port security is typically used on access ports.

Question 40: What is the primary defense against double-tagging VLAN hopping?

Answer

(a) Setting native VLAN to an unused VLAN. This prevents the attacker from exploiting the native VLAN.

Exercises

Exercise 1: Port Security Configuration

Write the Cisco IOS commands to enable port security on interface Gi0/1, with a maximum of 5 MAC addresses, violation mode "shutdown", and sticky learning.

Solution
interface gigabitEthernet 0/1
 switchport mode access
 switchport port-security
 switchport port-security maximum 5
 switchport port-security violation shutdown
 switchport port-security mac-address sticky
        

Exercise 2: DHCP Snooping Configuration

Enable DHCP snooping on a switch, set VLAN 10 as the trusted VLAN, and configure the uplink port Gi0/24 as trusted.

Solution
ip dhcp snooping
ip dhcp snooping vlan 10
interface gigabitEthernet 0/24
 ip dhcp snooping trust
        

Exercise 3: Dynamic ARP Inspection (DAI) Configuration

Enable DAI for VLAN 20 and configure port Gi0/2 as trusted for ARP.

Solution
ip arp inspection vlan 20
interface gigabitEthernet 0/2
 ip arp inspection trust
        

Exercise 4: Double Tagging Attack

Explain how a double-tagging VLAN hopping attack works. What are the requirements for the attack to succeed?

Solution

The attacker sends a frame with two 802.1Q tags. The outer tag is for the native VLAN of the first switch (which strips it). The inner tag is for the target VLAN. The first switch forwards the frame to the trunk with only the inner tag, and the second switch receives it and forwards it to the target VLAN. Requirements: the attacker must be on the same native VLAN as the trunk, and the trunk must have the native VLAN set to the same VLAN as the attacker's port.

Exercise 5: Mitigating ARP Spoofing

You suspect ARP spoofing on a VLAN. List three steps you would take to mitigate it using switch features.

Solution
  1. Enable Dynamic ARP Inspection (DAI) on the VLAN.
  2. Ensure DHCP snooping is enabled and trusted ports are correctly configured.
  3. Implement port security to limit MAC addresses on access ports.

Exercise 6: VLAN Hopping Prevention

You are configuring a trunk between two switches. What steps should you take to prevent VLAN hopping?

Solution

Exercise 7: 802.1X Configuration

Describe the steps to configure 802.1X on a Cisco switch, including the RADIUS server configuration.

Solution
aaa new-model
radius-server host 192.168.1.100 key secret
aaa authentication dot1x default group radius
dot1x system-auth-control
interface gigabitEthernet 0/1
 authentication port-control auto
 dot1x pae authenticator
        

Exercise 8: IP Source Guard Configuration

Enable IP Source Guard on port Gi0/3 for both IP and MAC filtering.

Solution
interface gigabitEthernet 0/3
 ip verify source port-security
        

Exercise 9: MAC Flooding Mitigation

Explain how port security and MAC address aging help mitigate MAC flooding attacks.

Solution

Port security limits the number of MAC addresses per port, preventing an attacker from flooding the CAM table from a single port. MAC address aging ensures that entries eventually expire, allowing the switch to recover from an attack. Also, storm control can limit the rate of unknown unicast frames.

Exercise 10: BPDU Guard and Root Guard

What is the difference between BPDU Guard and Root Guard? When would you use each?

Solution

BPDU Guard: Shuts down a port if a BPDU is received, used on access ports to prevent rogue switches. Root Guard: Prevents a port from becoming a root port; if a superior BPDU is received, the port is blocked. Used on ports that should not become root, typically downstream links.

Exercise 11: Secure Trunk Configuration

Write a Cisco command sequence to configure a trunk port with native VLAN 999, allowed VLANs 10,20,30, and disable DTP.

Solution
interface gigabitEthernet 0/1
 switchport trunk encapsulation dot1q
 switchport mode trunk
 switchport trunk native vlan 999
 switchport trunk allowed vlan 10,20,30
 switchport nonegotiate
        

Exercise 12: MACsec Configuration

Describe the basic steps to enable MACsec on a switch port.

Solution

Enable MACsec globally, configure a key chain, and apply the security policy to the interface. For example:

macsec
key chain MACSEC_KEY
 key 1
  key-string 
 interface gigabitEthernet 0/1
  macsec
  macsec key chain MACSEC_KEY
        

Exercise 13: DHCP Snooping Binding Table

Explain how the DHCP snooping binding table is built and how it is used by DAI and IPSG.

Solution

DHCP snooping watches DHCP exchanges on trusted ports and records IP-MAC-VLAN-port bindings in a table. DAI uses this table to validate ARP packets (matching source IP to MAC). IPSG uses it to filter IP packets (allowing only packets from the bound IP/MAC).

Exercise 14: STP Security

Why is it important to enable BPDU Guard on all access ports? What can happen if a rogue switch is connected to an access port?

Solution

BPDU Guard prevents a rogue switch from participating in STP, which could cause topology changes, loops, or even become the root bridge. Without BPDU Guard, a rogue switch could cause network instability or man-in-the-middle attacks.

Exercise 15: Secure LAN Design

List five best practices for securing a campus LAN against Layer 2 attacks.

Solution
  1. Enable port security on access ports.
  2. Enable DHCP snooping, DAI, and IPSG.
  3. Use 802.1X for user/device authentication.
  4. Change native VLAN on trunks to an unused VLAN.
  5. Enable BPDU Guard on access ports and Root Guard on appropriate ports.

Exercise 16: ARP Spoofing Detection

How can an administrator detect an ARP spoofing attack on a network? What tools can be used?

Solution

Monitor ARP tables for inconsistencies (e.g., multiple IPs mapping to same MAC). Use tools like arpwatch, Wireshark (filter for ARP replies with different MACs), or switch logs from DAI. DAI will log dropped ARP packets when it detects a violation.

Exercise 17: Port Security Violation Recovery

A switch port has been error-disabled due to a port security violation. How can you recover it without rebooting the switch?

Solution

Use the command shutdown followed by no shutdown on the interface, or enable errdisable recovery cause psecure-violation globally.

Exercise 18: 802.1X with MAC Authentication Bypass (MAB)

When would you use MAB in an 802.1X environment? What are its limitations?

Solution

MAB is used for devices that do not support 802.1X, such as printers, IP cameras, or legacy devices. The switch uses the device's MAC address to authenticate against the RADIUS server. Limitations: MAC addresses can be spoofed, and MAB is less secure than certificate-based authentication.

Exercise 19: DHCP Starvation Attack

What is a DHCP starvation attack and how can it be mitigated?

Solution

An attacker sends many DHCP requests with spoofed MAC addresses to exhaust the DHCP server's pool of addresses, preventing legitimate clients from obtaining IPs. Mitigation: DHCP snooping with rate limiting on untrusted ports, and setting the DHCP server to detect and block such attacks.

Exercise 20: Securing the Management Plane

What recommendations would you give for securing management access to switches (SSH, SNMP, etc.) in addition to Layer 2 protections?

Solution

Use SSH instead of Telnet, enable AAA with TACACS+/RADIUS for authentication, use SNMPv3 with encryption, restrict management IPs via ACLs, use a dedicated management VLAN, and disable unused services (e.g., HTTP, CDP).

Homework

Homework 1: Compare and contrast the security features of DHCP snooping, Dynamic ARP Inspection, and IP Source Guard. Explain how they work together to secure a LAN.

Answer

DHCP snooping builds a binding table of IP-MAC-VLAN-port. DAI uses this table to validate ARP packets, preventing ARP spoofing. IPSG uses the table to filter IP traffic, preventing IP spoofing. Together, they provide a comprehensive defense against IP and ARP-based attacks.

Homework 2: Describe the three violation modes of port security (shutdown, restrict, protect). In which scenarios would you choose each mode?

Answer

Shutdown: disables the port, useful for high-security areas where immediate action is needed. Restrict: drops violating frames and logs, good for monitoring. Protect: drops violating frames silently, used when you want to limit impact on the network.

Homework 3: Explain the double-tagging VLAN hopping attack in detail. What configuration mistakes make it possible, and how can you prevent it?

Answer

Double tagging: attacker sends a frame with two tags; the first switch strips the outer tag (native VLAN) and forwards the inner tag. The second switch forwards based on the inner tag. This works if the attacker is on the same native VLAN as the trunk and the native VLAN is VLAN 1 (default). Prevention: change native VLAN to an unused VLAN, and never use VLAN 1 for user traffic.

Homework 4: Describe the 802.1X authentication process step by step, from the supplicant connecting to the network to gaining access.

Answer
  1. Supplicant connects to the switch port.
  2. Switch (authenticator) sends EAP-Request/Identity to supplicant.
  3. Supplicant responds with EAP-Response/Identity.
  4. Switch encapsulates the response in RADIUS and forwards to authentication server.
  5. Authentication server challenges the supplicant (e.g., EAP-TLS, PEAP).
  6. Supplicant and server authenticate each other.
  7. Authentication server sends RADIUS-Accept to switch.
  8. Switch grants access to the port, optionally assigns VLAN.

Homework 5: Compare MACsec with IPsec. When would you use MACsec instead of IPsec for securing network communication?

Answer

MACsec operates at Layer 2, protecting Ethernet frames between directly connected devices. IPsec operates at Layer 3, protecting IP packets end-to-end. MACsec is suitable for campus or data center links where encryption is needed on physical links; IPsec is used for VPNs and across untrusted networks. MACsec is simpler for point-to-point links, but IPsec provides more flexibility and works over the internet.

Homework 6: What is the purpose of the "trust" feature in DHCP snooping and DAI? Why are uplink ports typically trusted?

Answer

Trusted ports are those from which we accept DHCP replies (DHCP snooping) and ARP packets (DAI) without validation. Uplink ports are trusted because they connect to legitimate servers (DHCP server, router). This allows valid traffic while protecting against rogue devices on access ports.

Homework 7: Explain the concept of "sticky MAC" and its use in port security. What are the advantages and disadvantages?

Answer

Sticky MAC dynamically learns MAC addresses and stores them in the running configuration, making them persistent across reboots. Advantages: no need to manually configure each MAC; provides a permanent record. Disadvantages: if a device is replaced, the new MAC must be added or the port reconfigured; also, sticky MAC addresses are not automatically removed if a device moves.

Homework 8: Describe a scenario where a guest VLAN is used in a campus network. What security measures would you apply to the guest VLAN?

Answer

Guest VLAN is used for visitors who need internet access but should not access internal resources. Security measures: isolate guest VLAN from internal VLANs (via ACLs), limit bandwidth, enable DHCP snooping and DAI, use 802.1X for guest authentication (often with captive portal), and apply micro-segmentation to prevent guest-to-guest attacks.

Homework 9: Explain how Storm Control works and what types of traffic it can limit. Why is it important?

Answer

Storm Control limits the rate of broadcast, multicast, and unknown unicast traffic on a port. When the rate exceeds a threshold, the switch drops subsequent frames. It is important to prevent denial-of-service due to broadcast storms (e.g., from loops or attacks) and to protect against switch CPU overload.

Homework 10: What is the role of the RADIUS server in 802.1X? How does the switch communicate with the RADIUS server?

Answer

The RADIUS server authenticates the supplicant and returns an authorization decision (accept/reject) and optionally VLAN assignment. The switch acts as a RADIUS client, encapsulating EAP messages in RADIUS packets and sending them to the server over UDP (ports 1812/1813).

Homework 11: What is the difference between a MAC flood and a MAC spoof attack? Which is more dangerous in terms of traffic interception?

Answer

MAC flood overwhelms the CAM table, causing the switch to flood all traffic, allowing sniffing. MAC spoof is impersonating a specific MAC to redirect traffic. MAC spoof can lead to targeted MitM attacks, while MAC flood is broader but less stealthy. MAC spoof can be more dangerous if the attacker impersonates a gateway.

Homework 12: How can an administrator verify that DHCP snooping is working correctly? What commands are used?

Answer

Commands: show ip dhcp snooping (status, trust settings), show ip dhcp snooping binding (list of bindings), show ip dhcp snooping statistics (counters). Also check logs for DHCP snooping messages.

Homework 13: What is the purpose of "IP Device Tracking" and how does it differ from DHCP snooping?

Answer

IP Device Tracking is a feature that tracks IP addresses of devices on a port, often used with DAI when DHCP snooping is not available. It uses probes to detect active IPs. DHCP snooping relies on DHCP messages; IP Device Tracking can work with static IPs.

Homework 14: Describe a security incident where an attacker used ARP poisoning to intercept SSH traffic. How could DAI have prevented it?

Answer

The attacker sends forged ARP replies associating the gateway IP with the attacker's MAC. All traffic to the gateway goes through the attacker, who can sniff SSH sessions (unless encrypted). DAI would have detected the invalid ARP reply (since the MAC doesn't match the DHCP binding) and dropped it, preventing the attack.

Homework 15: Explain how MACsec can be used to secure traffic on a trunk link between two switches. What are the key exchange mechanisms?

Answer

MACsec encrypts all Ethernet frames on the trunk. It uses a pre-shared key or MKA (MACsec Key Agreement) protocol to establish encryption keys. MKA uses 802.1X authentication to derive keys securely.

Homework 16: What are the risks of using VLAN 1 for management traffic? How can you mitigate them?

Answer

VLAN 1 is the default native VLAN and is often targeted for VLAN hopping. Attackers can exploit it. Mitigate by moving management to a dedicated VLAN, changing native VLAN to an unused VLAN, and blocking VLAN 1 on trunks.

Homework 17: Compare the effectiveness of static ARP entries versus DAI in preventing ARP spoofing. Which is more scalable?

Answer

Static ARP entries are effective but require manual configuration on every device and are not scalable. DAI is automated and uses DHCP bindings, making it scalable and easier to manage for large networks. DAI is preferred in enterprise environments.

Homework 18: Describe the concept of "micro-segmentation" using VXLAN and how it enhances security at the link layer.

Answer

Micro-segmentation uses VXLAN overlays to create small, isolated network segments. This limits east-west traffic and reduces attack surface. Security policies can be applied per segment, and VXLAN provides L2 isolation across L3, enhancing security.

Homework 19: What is the role of "AAA" (Authentication, Authorization, and Accounting) in switch security? How does it complement Layer 2 protections?

Answer

AAA provides centralized authentication (who is accessing the device), authorization (what they can do), and accounting (logging). It complements Layer 2 protections by securing management access to switches, ensuring only authorized administrators can change configurations, which could otherwise disable security features.

Homework 20: Write a comprehensive secure LAN configuration checklist for a new building deployment. Include both Layer 2 and management security items.

Answer

Summary

This tutorial covered link-layer security threats and protection mechanisms:

Implementing these protections is essential to prevent eavesdropping, man-in-the-middle attacks, and denial-of-service at the link layer. In the final tutorial, we will review and integrate all Unit 6 concepts.

👤