Part I: Network Theory Chapter 3

Data Link Layer Protocols

Ethernet, MAC addressing, ARP, switching, VLANs, 802.1X, and Layer 2 security fundamentals

Chapter 3: Data Link Layer Protocols

The Hospital That Lost Its Network

In 2016, a hospital’s entire network crashed during a critical surgery. The cause? An engineer had connected both ends of a patch cable to the same switch, creating a Layer 2 loop. Within seconds, broadcast storms overwhelmed every switch in the building. Monitoring systems went dark. Infusion pumps lost connectivity. For eight terrifying minutes, the surgical team worked blind while network engineers frantically traced cables.

The network had no Spanning Tree Protocol enabledβ€”a basic Layer 2 safeguard. This incident, fortunately ending without patient harm, illustrates a crucial truth: Layer 2 might seem simple compared to routing and applications, but its failures can be catastrophic and immediate.

The Data Link layer sits at a critical junction in the network stack. It’s where raw bits become structured frames, where local addressing happens, and where many of the most devastating network attacks occur. ARP spoofing, MAC flooding, VLAN hoppingβ€”these attacks exploit fundamental assumptions about local network trust.

In this chapter, we’ll explore Ethernet, MAC addressing, ARP, switching, VLANs, and the security mechanisms that protect (or fail to protect) Layer 2 networks.


The Bridge Between Physical and Logical

The Physical layer deals in raw bitsβ€”electrical pulses, light flashes, or radio waves. The Network layer deals in global addresses and routing across the internet. Between them sits the Data Link layer, providing the crucial service of organizing bits into meaningful units and delivering them between devices on the same local network.

When your computer sends data to your router, that data doesn’t magically appear at the router. The Data Link layer:

  • Packages data into frames with structured headers and trailers
  • Addresses frames using MAC addresses (hardware addresses)
  • Detects transmission errors using CRC checksums
  • Coordinates access to the shared physical medium

Understanding this layer is essential for network security because many powerful attacks exploit how the Data Link layer operates on trust assumptions that were never designed for hostile environments.


Ethernet: The Foundation of Wired LANs

A Brief History

Ethernet was invented at Xerox PARC in the early 1970s by Robert Metcalfe and David Boggs. The name comes from β€œluminiferous ether”—the hypothetical medium once thought to carry light waves through space.

The original Ethernet used coaxial cable in a bus topology, with all devices sharing a single cable. When one device transmitted, all others could hear it. This created the fundamental challenge Ethernet needed to solve: what happens when two devices try to transmit simultaneously?

Ethernet Evolution

Ethernet has evolved dramatically since then:

GenerationSpeedMediaYearNotes
Original10 MbpsCoax (10BASE5)1973Thick Ethernet
10BASE-T10 MbpsTwisted pair1990Star topology begins
Fast Ethernet100 MbpsCat51995100BASE-TX
Gigabit1 GbpsCat5e/Fiber19991000BASE-T
10 Gigabit10 GbpsCat6a/Fiber2002Data centers
25/40/100 Gb25-100 GbpsFiber2010sCloud/HPC
200/400 Gb200-400 GbpsFiber2020sHyperscale

Throughout this evolution, the basic frame structure and addressing scheme have remained remarkably consistent.

The Ethernet Frame

Ethernet organizes data into units called frames. A frame is a structured sequence of bytes with a defined format that both sender and receiver understand.

Ethernet II Frame Format

Ethernet II Frame Format:
═══════════════════════════════════════════════════════════════════════

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”
β”‚ Preamble β”‚   Dest   β”‚  Source  β”‚EtherType β”‚      Payload      β”‚ FCS  β”‚
β”‚ 7 bytes  β”‚   MAC    β”‚   MAC    β”‚ 2 bytes  β”‚   46-1500 bytes   β”‚4 byteβ”‚
β”‚ + SFD    β”‚ 6 bytes  β”‚ 6 bytes  β”‚          β”‚                   β”‚      β”‚
β”‚ 1 byte   β”‚          β”‚          β”‚          β”‚                   β”‚      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”˜
    β”‚            β”‚           β”‚          β”‚              β”‚           β”‚
    β”‚            β”‚           β”‚          β”‚              β”‚           β”‚
    β”‚            β”‚           β”‚          β”‚              β”‚           β”‚
    β–Ό            β–Ό           β–Ό          β–Ό              β–Ό           β–Ό
Synchronize   Where to    Who sent   What's       The actual     Error
receiver's    send this   this       inside?      data           check
clock         frame       frame      (IPv4/ARP/                  (CRC)
                                     IPv6/VLAN)

Preamble and Start Frame Delimiter (SFD) - 8 bytes: The preamble is a series of alternating 1s and 0s (10101010…) that allows the receiving NIC to synchronize its clock with the incoming signal. The final byte, the SFD (10101011), signals that the actual frame is about to begin. These bytes are typically stripped by the hardware before the frame reaches higher layers.

Destination MAC Address - 6 bytes: The hardware address of the intended recipient. This can be a unicast address (specific device), broadcast address (all devices on the segment), or multicast address (group of devices).

Source MAC Address - 6 bytes: The hardware address of the sending device. This is always a unicast address.

EtherType - 2 bytes: Indicates which protocol is encapsulated in the payload. Common values:

EtherTypeProtocolDescription
0x0800IPv4Internet Protocol v4
0x0806ARPAddress Resolution Protocol
0x86DDIPv6Internet Protocol v6
0x8100802.1QVLAN-tagged frame
0x88A8802.1adQ-in-Q (double VLAN tag)
0x8847MPLSMultiprotocol Label Switching

Payload - 46 to 1500 bytes: The actual data being carried, typically an IP packet. The minimum payload size of 46 bytes ensures frames are long enough to detect collisions in original Ethernet designs. If the data is smaller, padding is added. The maximum of 1500 bytes is the standard Maximum Transmission Unit (MTU) for Ethernet.

Frame Check Sequence (FCS) - 4 bytes: A CRC-32 (Cyclic Redundancy Check) value calculated over the frame. The receiver recalculates the CRC and compares it to detect transmission errors. If they don’t match, the frame is silently discarded.

Security Note: Ethernet provides error detection but not error correction or authentication. Frames can be easily crafted with any source MAC addressβ€”the hardware doesn’t verify ownership. This fundamental lack of authentication enables MAC spoofing attacks.

** COMMON MISTAKE**

Confusing MTU with frame size. The MTU (1500 bytes) is the maximum payload size. The actual frame on the wire is larger due to headers (14 bytes) and trailer (4 bytes), plus preamble (8 bytes). For jumbo frames (MTU 9000), ensure all devices in the path support themβ€”one non-jumbo device causes fragmentation or black-holing.

CSMA/CD: Handling Collisions

In shared Ethernet (hubs and the original bus topology), all devices compete for the same transmission medium. Ethernet uses CSMA/CD (Carrier Sense Multiple Access with Collision Detection) to manage this:

  1. Carrier Sense: Before transmitting, a device listens to check if the medium is in use
  2. Multiple Access: If the medium is quiet, the device transmits. Multiple devices can attempt access
  3. Collision Detection: While transmitting, the device monitors for collisions (another device transmitting simultaneously)
  4. Collision Handling: If a collision is detected, both devices stop, wait a random time (binary exponential backoff), and try again

CSMA/CD Process

CSMA/CD Process:
═══════════════════════════════════════════════════════════════════

    Device A                Shared Medium               Device B
    ════════               ═════════════               ════════
        β”‚                                                   β”‚
        β”‚ 1. Listen - is anyone transmitting?               β”‚
        β”‚    (Carrier Sense)                                β”‚
        β”‚                                                   β”‚
        β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”‚
        β”‚                 TRANSMIT                          β”‚
        │◄───────────────────────────────────────────────────
        β”‚                                                   β”‚
        β”‚ 2. Collision detected!                            β”‚
        β”‚    Both stop transmitting                         β”‚
        β”‚                                                   β”‚
        β”‚ 3. Wait random backoff (0-2^n slots)              β”‚
        β”‚    Device A: 3 slot times                         β”‚
        β”‚    Device B: 1 slot time                          β”‚
        β”‚                                                   β”‚
        β”‚                              Device B retries     β”‚
        │◄───────────────────────────────────────────────────
        β”‚                 SUCCESS                           β”‚
        β”‚                                                   β”‚
        β”‚ Then Device A retries                             β”‚
        β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”‚
        β”‚                 SUCCESS                           β”‚

With modern switched Ethernet, each port has its own collision domain, and full-duplex connections eliminate collisions entirely. CSMA/CD is largely historical, but understanding it explains why Ethernet has minimum frame sizes and certain timing constraints.


MAC Addresses

Structure and Format

A MAC address (Media Access Control address) is a unique identifier assigned to network interfaces. Every Ethernet NIC in the world has a unique 48-bit (6-byte) MAC address burned into it during manufacture.

MAC addresses are typically written in hexadecimal, with bytes separated by colons or hyphens:

MAC Address Formats

MAC Address Formats:
═══════════════════════════════════════════════════════════════════

00:1A:2B:3C:4D:5E   (Colon notation - Linux/macOS)
00-1A-2B-3C-4D-5E   (Hyphen notation - Windows)
001A.2B3C.4D5E      (Cisco notation)

MAC Address Structure (48 bits):
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         OUI             β”‚    Device Identifier    β”‚
β”‚  (First 24 bits/3 bytes)β”‚  (Last 24 bits/3 bytes) β”‚
β”‚                         β”‚                         β”‚
β”‚   Assigned by IEEE      β”‚   Assigned by vendor    β”‚
β”‚   to manufacturers      β”‚   (unique per device)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Example: 00:1A:2B:3C:4D:5E
         β”œβ”€β”€β”€β”€β”€β”€β”€ β”œβ”€β”€β”€β”€β”€β”€β”€
           OUI     Device
         (Vendor)  ID

Special bits in first octet:
Bit 0 (I/G): 0 = Unicast, 1 = Multicast
Bit 1 (U/L): 0 = Universally administered (vendor), 1 = Locally administered

OUI (Organizationally Unique Identifier): The first 24 bits identify the manufacturer. IEEE assigns OUIs to vendors. You can look up a MAC address prefix to identify the manufacturerβ€”useful for network reconnaissance.

Device Identifier: The last 24 bits are assigned by the manufacturer, ensuring uniqueness within their allocation.

Special MAC Addresses

Broadcast Address: FF:FF:FF:FF:FF:FF A frame sent to the broadcast address is received by all devices on the local network segment. ARP requests, for example, use broadcast to find the MAC address corresponding to an IP.

Multicast Addresses: MAC addresses with the least significant bit of the first byte set to 1 are multicast addresses. These deliver frames to a group of interested receivers rather than all devices.

Unicast vs Multicast (first byte)

Unicast vs Multicast (first byte):
═══════════════════════════════════════════════════════════════════

Unicast:   00000000  (even number: 0x00, 0x02, 0x04...)
                  ^
                  └── LSB = 0 means unicast

Multicast: 00000001  (odd number: 0x01, 0x03, 0x05...)
                  ^
                  └── LSB = 1 means multicast

Common multicast MACs:
01:00:5E:xx:xx:xx  - IPv4 multicast
33:33:xx:xx:xx:xx  - IPv6 multicast
01:80:C2:00:00:00  - Spanning Tree Protocol (STP)
01:00:0C:CC:CC:CC  - Cisco Discovery Protocol (CDP)

Locally Administered Addresses: The second least significant bit of the first byte indicates whether the address is globally unique (manufacturer-assigned) or locally administered (set by network administrator). Virtual machines often use locally administered addresses.

MAC Address Lookup

Knowing that MAC addresses contain manufacturer information enables network reconnaissance:

# Online OUI lookup (many tools available)
# Example output for 00:1A:2B:xx:xx:xx
Vendor: Ayecom Technology Co., Ltd.

# Common manufacturer OUIs (memorize these for quick identification):
Apple:     00:03:93, 00:0A:27, 00:0D:93, 3C:15:C2, F0:18:98
Intel:     00:02:B3, 00:03:47, 00:1B:21, 3C:A9:F4
Cisco:     00:00:0C, 00:01:42, 00:17:94, 00:1E:BD
Dell:      00:06:5B, 00:08:74, 00:14:22, 18:03:73
VMware:    00:0C:29, 00:50:56 (virtual machines!)
VirtualBox: 08:00:27

TRY IT YOURSELF

Look up MAC addresses on your network:

# Find your MAC address
ip link show              # Linux
ifconfig | grep ether     # macOS
getmac                    # Windows

# See MAC addresses of other devices (from ARP cache)
arp -a

# Look up vendor online
# https://macvendors.com/ or use wireshark's OUI database

Security Note: MAC addresses can be easily changed (spoofed) in software, despite being β€œburned in” to hardware. Most operating systems allow setting arbitrary MAC addresses. This enables MAC spoofing attacks and can defeat MAC-based access controls. Never rely solely on MAC addresses for security.


Address Resolution Protocol (ARP)

The Problem ARP Solves

Imagine you’re on your computer at IP address 192.168.1.100, and you want to communicate with your router at 192.168.1.1. You know the router’s IP address, but to actually send an Ethernet frame, you need its MAC address. IP addresses mean nothing at Layer 2β€”switches and NICs only understand MAC addresses.

ARP (Address Resolution Protocol) bridges this gap, translating IP addresses (Layer 3) to MAC addresses (Layer 2). It’s a simple yet critical protocol, and its lack of authentication makes it a prime target for attacks.

How ARP Works

ARP uses two message types: ARP Request and ARP Reply.

ARP Request (Broadcast): When a device needs to find the MAC address for an IP, it sends an ARP request to the broadcast MAC address (FF:FF:FF:FF:FF:FF). The request says, essentially: β€œWho has IP 192.168.1.1? Tell 192.168.1.100.”

ARP Reply (Unicast): The device with the requested IP responds directly to the requester with its MAC address: β€œ192.168.1.1 is at 00:11:22:33:44:55.”

ARP Resolution Process

ARP Resolution Process:
═══════════════════════════════════════════════════════════════════

   Device A (192.168.1.100)                    Router (192.168.1.1)
   MAC: AA:AA:AA:AA:AA:AA                      MAC: 00:11:22:33:44:55
           β”‚                                            β”‚
           β”‚  1. ARP Request (Broadcast)                β”‚
           β”‚     "Who has 192.168.1.1?"                 β”‚
           β”‚     Destination: FF:FF:FF:FF:FF:FF         β”‚
           β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”‚
           β”‚                    β”‚                       β”‚
           β”‚      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”‚
           β”‚      β”‚  All devices receive this   β”‚       β”‚
           β”‚      β”‚  (it's broadcast)           β”‚       β”‚
           β”‚      β”‚                             β”‚       β”‚
           β”‚      β”‚  Only the owner of          β”‚       β”‚
           β”‚      β”‚  192.168.1.1 responds       β”‚       β”‚
           β”‚      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚
           β”‚                                            β”‚
           β”‚  2. ARP Reply (Unicast)                    β”‚
           β”‚     "192.168.1.1 is at 00:11:22:33:44:55"  β”‚
           │◄────────────────────────────────────────────
           β”‚     Destination: AA:AA:AA:AA:AA:AA         β”‚
           β”‚                                            β”‚
           β”‚  3. Device A updates ARP cache             β”‚
           β”‚     192.168.1.1 β†’ 00:11:22:33:44:55        β”‚
           β”‚                                            β”‚

ARP Packet Structure

ARP Packet Format

ARP Packet Format:
═══════════════════════════════════════════════════════════════════

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Hardware Type  β”‚ Protocol Type β”‚ HW Len β”‚ Proto Len β”‚ Opcode   β”‚
β”‚   (2 bytes)    β”‚   (2 bytes)   β”‚(1 byte)β”‚ (1 byte)  β”‚(2 bytes) β”‚
β”‚   0x0001=Eth   β”‚   0x0800=IPv4 β”‚  0x06  β”‚   0x04    β”‚ 1=Req    β”‚
β”‚                β”‚               β”‚        β”‚           β”‚ 2=Reply  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                    Sender MAC Address (6 bytes)                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                    Sender IP Address (4 bytes)                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                    Target MAC Address (6 bytes)                β”‚
β”‚           (00:00:00:00:00:00 for requests)                     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                    Target IP Address (4 bytes)                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The ARP Cache

To avoid constant ARP requests, devices maintain an ARP cacheβ€”a table mapping IP addresses to MAC addresses. When a device receives an ARP reply (or sees ARP traffic), it updates its cache. Entries typically expire after 2-20 minutes, depending on the operating system.

# View ARP cache on Linux/macOS
arp -a
# or
ip neigh show

# Example output:
192.168.1.1 at 00:11:22:33:44:55 on en0 ifscope [ethernet]
192.168.1.50 at aa:bb:cc:dd:ee:ff on en0 ifscope [ethernet]

# View ARP cache on Windows
arp -a

# Clear ARP cache (requires admin/root)
# Linux:
sudo ip -s -s neigh flush all
# macOS:
sudo arp -a -d
# Windows (elevated):
netsh interface ip delete arpcache

ARP Security Vulnerabilities

ARP was designed in an era when networks were small, trusted environments. It has no authenticationβ€”any device can claim to own any IP address. This fundamental weakness enables ARP spoofing (also called ARP poisoning), one of the most powerful Layer 2 attacks.

ARP Spoofing Attack

ARP Spoofing Attack:
═══════════════════════════════════════════════════════════════════

   Normal Operation:
   ─────────────────
   
   Victim ──────────► Gateway
   192.168.1.100      192.168.1.1
   
   Victim's ARP cache:
   192.168.1.1 β†’ 00:11:22:33:44:55 (legitimate gateway MAC)


   During ARP Spoofing Attack:
   ───────────────────────────
   
   Attacker sends fake ARP replies:
   "192.168.1.1 is at AA:BB:CC:DD:EE:FF" (attacker's MAC)
   
   Victim ─────X─────► Gateway
       β”‚
       └───────────►  Attacker
                      AA:BB:CC:DD:EE:FF
   
   Victim's ARP cache (poisoned):
   192.168.1.1 β†’ AA:BB:CC:DD:EE:FF (attacker's MAC!)
   
   Now all traffic intended for gateway goes to attacker!

In ARP spoofing, an attacker sends fake ARP replies to associate their MAC address with another device’s IP (commonly the gateway). Victims update their ARP cache with the false information and start sending traffic to the attacker instead of the legitimate destination. This enables man-in-the-middle attacks.

Security Note: ARP spoofing is covered in detail in Part II, Chapter 2. Defenses include static ARP entries, Dynamic ARP Inspection (DAI) on switches, and monitoring for ARP anomalies.

THINK ABOUT IT

ARP has no authentication because it was designed for trusted academic networks. If you were designing a protocol today to solve the same problem, what security measures would you include?


Switches and Switching

From Hubs to Switches

As discussed in Chapter 1, hubs are simple devices that repeat all traffic to all portsβ€”every device sees every frame. This creates congestion, security issues, and collision problems. Switches solved these problems by learning which devices are connected to which ports and forwarding traffic only where it needs to go.

How Switches Learn

Switches build a MAC address table (also called a CAM tableβ€”Content Addressable Memory) by observing the source MAC address of frames arriving on each port. When a switch receives a frame:

  1. Learning: Record the source MAC address and the port it arrived on
  2. Forwarding Decision:
    • If the destination MAC is in the table β†’ forward to that port only (unicast)
    • If the destination MAC is not in the table β†’ flood to all ports except source (unknown unicast)
    • If the destination MAC is broadcast/multicast β†’ flood appropriately

Switch Learning Process

Switch Learning Process:
═══════════════════════════════════════════════════════════════════

Initial State: Empty MAC table
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ MAC Address Table       β”‚
│──────────────┬──────────│
β”‚ MAC          β”‚ Port     β”‚
β”‚ (empty)      β”‚          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Step 1: Device A (MAC AA:AA) sends frame from Port 1
        Switch learns: AA:AA is on Port 1
        
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ MAC          β”‚ Port     β”‚
β”‚ AA:AA:AA:AA  β”‚ 1        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Step 2: Device B (MAC BB:BB) sends frame from Port 2
        Switch learns: BB:BB is on Port 2
        
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ MAC          β”‚ Port     β”‚
β”‚ AA:AA:AA:AA  β”‚ 1        β”‚
β”‚ BB:BB:BB:BB  β”‚ 2        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Step 3: A wants to send to B
        Switch looks up BB:BB β†’ Port 2
        Forwards ONLY to Port 2 (not flooding!)
        
    Port 1          Port 2          Port 3
       β”‚               β”‚               β”‚
    [Device A] ───► [Device B]     [Device C]
                                   (doesn't see
                                   this traffic)

MAC Address Table Details

# View MAC address table on Cisco switch
show mac address-table

# Example output:
Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
   1    0011.2233.4455    DYNAMIC     Gi0/1
   1    aabb.ccdd.eeff    DYNAMIC     Gi0/2
  10    0022.3344.5566    DYNAMIC     Gi0/5
  
# Table aging: Entries expire after 300 seconds (default)
# This is important - if a device moves to a different port,
# the old entry must age out or be replaced

Collision Domains and Broadcast Domains

Collision Domain: A network segment where collisions can occur if two devices transmit simultaneously. In hub-based networks, all ports share one collision domain. Switches create separate collision domains for each portβ€”devices on different ports can transmit simultaneously without collision.

Broadcast Domain: A network segment where broadcast frames are received by all devices. A standard switch is one broadcast domainβ€”broadcasts reach all ports. Routers (Layer 3 devices) separate broadcast domains.

Collision Domains and Broadcast Domains

Collision Domains and Broadcast Domains:
═══════════════════════════════════════════════════════════════════

    Hub-Based Network:               Switch-Based Network:
    ──────────────────              ─────────────────────
    
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚      HUB     β”‚                β”‚    SWITCH    β”‚
    β””β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”˜                β””β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”˜
     β”‚   β”‚   β”‚   β”‚                   β”‚   β”‚   β”‚   β”‚
     A   B   C   D                   A   B   C   D
    
    1 Collision Domain              4 Collision Domains
    1 Broadcast Domain              1 Broadcast Domain
    
    All devices compete             Each port has its own
    for same bandwidth              full bandwidth
    
    
    Router Separates Broadcast Domains:
    ───────────────────────────────────
    
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  Switch 1  β”‚         β”‚  Switch 2  β”‚
    β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
          β”‚     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
          └────── ROUTER β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”˜
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    
    Broadcast Domain 1    Broadcast Domain 2
    (Broadcasts don't     (Separate from BD1)
     cross the router)

Security Note: The MAC address table has finite size (typically 8K-128K entries depending on switch model). In a MAC flooding attack, an attacker sends frames with thousands of fake source MAC addresses, filling the table. When the table is full, the switch can’t learn new addresses and must flood all trafficβ€”turning it into a hub and allowing the attacker to see all traffic. We cover this attack in Part II, Chapter 2.


VLANs (Virtual Local Area Networks)

The Problem VLANs Solve

Imagine a company with multiple departmentsβ€”Engineering, Sales, HRβ€”all on the same floor, connected to the same switches. Without any separation, a broadcast from an Engineering computer reaches everyone. More concerning, any compromised device can potentially access traffic from any department.

VLANs solve this by creating logical network segments within a physical switch infrastructure. Devices in different VLANs cannot communicate directly, even if they’re connected to the same switchβ€”traffic between VLANs must go through a router (Layer 3 device).

How VLANs Work

Each switch port is assigned to a VLAN. Frames are tagged internally with their VLAN ID, and the switch only forwards frames within the same VLAN.

VLAN Example

VLAN Example:
═══════════════════════════════════════════════════════════════════

Same Physical Switch, Logically Separated:

    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚                       SWITCH                             β”‚
    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚
    β”‚  β”‚ VLAN 10   β”‚    β”‚ VLAN 20  β”‚    β”‚ VLAN 30  β”‚           β”‚
    β”‚  β”‚Engineeringβ”‚    β”‚  Sales   β”‚    β”‚    HR    β”‚           β”‚
    β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜           β”‚
    β”‚       β”‚                β”‚               β”‚                 β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚                β”‚               β”‚
       β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”
       β”‚   Eng   β”‚     β”‚  Sales   β”‚     β”‚   HR    β”‚
       β”‚Computersβ”‚     β”‚Computers β”‚     β”‚Computersβ”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       
Broadcasts in VLAN 10 don't reach VLAN 20 or 30
Traffic between VLANs must go through a router

    VLAN 10                  Router                  VLAN 20
       β”‚                       β”‚                        β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   Inter-VLAN routing
                   (Layer 3 required)

802.1Q VLAN Tagging

When frames need to travel between switches, they must carry their VLAN information. IEEE 802.1Q defines how VLAN tags are inserted into Ethernet frames.

802.1Q Tagged Frame

802.1Q Tagged Frame:
═══════════════════════════════════════════════════════════════════

Standard Ethernet Frame:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚Dest MAC β”‚Src MAC  β”‚EtherType β”‚        Payload          β”‚   FCS   β”‚
β”‚ 6 bytes β”‚6 bytes  β”‚ 2 bytes  β”‚                         β”‚ 4 bytes β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

802.1Q Tagged Frame (4 bytes inserted):
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚Dest MAC β”‚Src MAC  β”‚   802.1Q Tag        β”‚EtherType β”‚   Payload    β”‚   FCS   β”‚
β”‚ 6 bytes β”‚6 bytes  β”‚   (4 bytes)         β”‚ 2 bytes  β”‚              β”‚ 4 bytes β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚                   β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”
            β”‚ TPID          β”‚ TCI               β”‚
            β”‚ (2 bytes)     β”‚ (2 bytes)         β”‚
            β”‚ 0x8100        β”‚                   β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚               β”‚               β”‚
               β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”
               β”‚Priority β”‚     β”‚  DEI    β”‚     β”‚VLAN ID  β”‚
               β”‚ 3 bits  β”‚     β”‚ 1 bit   β”‚     β”‚ 12 bits β”‚
               β”‚(0-7 QoS)β”‚     β”‚(discard)β”‚     β”‚(1-4094) β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

VLAN ID range: 1-4094 (0 and 4095 reserved)

Access Ports vs Trunk Ports:

Port TypeConnectsFramesVLAN Handling
AccessEnd devicesUntaggedSwitch adds/removes tags internally
TrunkSwitchesTagged (802.1Q)Tags preserved across link
Native VLANN/AUntagged on trunkDefault VLAN for untagged frames

Access vs Trunk Ports

Access vs Trunk Ports:
═══════════════════════════════════════════════════════════════════

                   Access Port             Trunk Port
                   ───────────             ──────────
                   
    [Computer] ──── [Switch 1] ════════════ [Switch 2]
                        β”‚                       β”‚
                    Access Port            Trunk Port
                        β”‚
      Computer sends    β”‚              Frames on trunk
      untagged frames   β”‚              carry 802.1Q tags
                        β”‚              (except native VLAN)
                        β–Ό
      Switch internally assigns
      VLAN based on port config

VLAN Security Considerations

While VLANs provide network segmentation, they’re not a perfect security boundary:

VLAN Hopping Attacks:

  1. Switch Spoofing: Attacker configures their NIC to act like a trunk port, potentially accessing multiple VLANs
  2. Double Tagging: Attacker sends frames with two 802.1Q tags; outer tag is stripped by first switch, inner tag routes to victim VLAN

Double Tagging Attack

Double Tagging Attack:
═══════════════════════════════════════════════════════════════════

Attacker is on VLAN 10 (native VLAN)
Target is on VLAN 20

Attacker sends double-tagged frame:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚Eth Hdr β”‚Outer Tag   β”‚Inner Tag   β”‚   Payload   β”‚
β”‚        β”‚VLAN 10     β”‚VLAN 20     β”‚             β”‚
β”‚        β”‚(native)    β”‚(target)    β”‚             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Switch 1 (receiving on native VLAN):
- Strips outer tag (it's native VLAN, untagged expected on trunk)
- Forwards with only inner tag (VLAN 20)

Switch 2:
- Receives frame tagged VLAN 20
- Delivers to VLAN 20!

Frame reached VLAN 20 from VLAN 10!
(Note: Only works one-way, no return path)

VLAN Security Best Practices:

  1. Never use VLAN 1 for production traffic
  2. Change native VLAN to unused VLAN
  3. Explicitly configure access ports (don’t rely on DTP)
  4. Disable unused ports and put them in unused VLAN
  5. Use Private VLANs for additional isolation
  6. Prune unnecessary VLANs from trunks

Security Note: VLAN hopping attacks are covered in Part II, Chapter 2. Proper switch hardening can prevent most of these attacks.


802.1X: Network Access Control

The Problem 802.1X Solves

Traditional network access is simple: plug in a cable, get network access. But in enterprise environments, this is a security nightmare. Anyone who gains physical access can connect to the network.

802.1X provides port-based Network Access Control (NAC). Before a device can access the network, it must authenticate. Until then, only authentication traffic is allowed.

802.1X Components

802.1X Architecture

802.1X Architecture:
═══════════════════════════════════════════════════════════════════

    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  Supplicant  β”‚     β”‚ Authenticatorβ”‚     β”‚Authenticationβ”‚
    β”‚   (Client)   β”‚     β”‚   (Switch)   β”‚     β”‚    Server    β”‚
    β”‚              β”‚     β”‚              β”‚     β”‚   (RADIUS)   β”‚
    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚                    β”‚                    β”‚
           β”‚ 1. EAPOL-Start     β”‚                    β”‚
           β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”‚                    β”‚
           β”‚                    β”‚                    β”‚
           β”‚ 2. EAP-Request     β”‚                    β”‚
           β”‚    Identity        β”‚                    β”‚
           │◄────────────────────                    β”‚
           β”‚                    β”‚                    β”‚
           β”‚ 3. EAP-Response    β”‚                    β”‚
           β”‚    Identity        β”‚                    β”‚
           β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”‚                    β”‚
           β”‚                    β”‚                    β”‚
           β”‚                    β”‚ 4. RADIUS Access-  β”‚
           β”‚                    β”‚    Request         β”‚
           β”‚                    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”‚
           β”‚                    β”‚                    β”‚
           β”‚                    β”‚ 5. RADIUS Access-  β”‚
           β”‚                    β”‚    Challenge       β”‚
           β”‚                    │◄────────────────────
           β”‚                    β”‚                    β”‚
           β”‚ 6. EAP-Request     β”‚                    β”‚
           β”‚    (Method)        β”‚                    β”‚
           │◄────────────────────                    β”‚
           β”‚                    β”‚                    β”‚
           β”‚ 7. EAP-Response    β”‚                    β”‚
           β”‚    (Credentials)   β”‚                    β”‚
           β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”‚                    β”‚
           β”‚                    β”‚                    β”‚
           β”‚                    β”‚ 8. RADIUS Access-  β”‚
           β”‚                    β”‚    Request         β”‚
           β”‚                    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”‚
           β”‚                    β”‚                    β”‚
           β”‚                    β”‚ 9. RADIUS Accept   β”‚
           β”‚                    β”‚    (with VLAN)     β”‚
           β”‚                    │◄────────────────────
           β”‚                    β”‚                    β”‚
           β”‚ 10. EAP-Success    β”‚                    β”‚
           │◄────────────────────                    β”‚
           β”‚                    β”‚                    β”‚
           β”‚   PORT AUTHORIZED  β”‚                    β”‚
           β”‚   (Network Access) β”‚                    β”‚
           │◄══════════════════►│                    β”‚

Supplicant: The client device requesting access (computer, phone, IoT device)

Authenticator: The network device controlling access (switch, wireless AP)

Authentication Server: Validates credentials (typically RADIUS server)

EAP Methods

EAP (Extensible Authentication Protocol) is a framework supporting multiple authentication methods:

EAP MethodDescriptionSecurity Level
EAP-MD5Password hashLow (no mutual auth)
EAP-TLSCertificate-basedHigh (mutual auth, PKI required)
EAP-TTLSTLS tunnel + inner methodHigh
PEAPTLS tunnel + MSCHAPv2High (most common)
EAP-FASTCisco, uses PACHigh

PEAP (Protected EAP) is most common in enterprises:

  1. Establishes TLS tunnel to RADIUS server
  2. User authenticates within tunnel (usually username/password)
  3. Server certificate validates server identity

802.1X Security Benefits

  • Identity-based access: Know who/what is on your network
  • Dynamic VLAN assignment: Users can be placed in appropriate VLAN based on identity
  • Guest access control: Unauthenticated devices can be redirected to captive portal
  • Endpoint compliance: Can check device health before granting access (NAC)
  • Audit trail: Authentication events are logged

802.1X Bypass Techniques

Attackers have developed techniques to bypass 802.1X:

  1. MAC Authentication Bypass (MAB): If enabled for devices that can’t do 802.1X, attacker spoofs authorized MAC
  2. Hub insertion: Place hub between authenticated device and switch
  3. Transparent bridge: Bridge traffic through authenticated device
  4. VLAN manipulation: If dynamic VLAN assignment isn’t properly secured

Security Note: 802.1X bypass techniques are covered in Part II, Chapter 2. Defense requires proper configuration and additional controls like MACSec.


Spanning Tree Protocol (STP)

The Loop Problem

Network designers often want redundant paths for reliabilityβ€”if one link fails, traffic can use another. However, creating physical loops in a switched network causes serious problems:

  1. Broadcast Storms: Broadcasts loop endlessly, multiplying and consuming all bandwidth
  2. MAC Table Instability: The switch sees the same MAC on multiple ports, constantly updating its table
  3. Multiple Frame Delivery: Unicast frames can be delivered multiple times

How STP Works

The Spanning Tree Protocol (IEEE 802.1D and later 802.1w for Rapid STP) prevents loops by logically disabling redundant paths while keeping them available for failover.

Spanning Tree Protocol

Spanning Tree Protocol:
═══════════════════════════════════════════════════════════════════

Physical Topology (has loops):

    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  Switch A  │═══════════│  Switch B  β”‚
    β”‚(Root Bridgeβ”‚           β”‚            β”‚
    β”‚ BID: 1000) β”‚           β”‚ BID: 2000  β”‚
    β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜           β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
          β”‚                        β”‚
          β”‚                        β”‚
          β”‚    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”‚
          └════│  Switch C  β”‚β•β•β•β•β•β•β”˜
               β”‚ BID: 3000  β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

STP Logical Topology (loop-free):

    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  Switch A  │═══════════│  Switch B  β”‚
    β”‚   (ROOT)   β”‚  RP    DP β”‚            β”‚
    β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜           β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
          β”‚ DP                     β”‚ RP
          β”‚                        β”‚
          β”‚    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”‚
          └════│  Switch C  │══════X  ← BLOCKED PORT
          DP   β”‚            β”‚         (prevents loop)
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

RP = Root Port (best path to root)
DP = Designated Port (forwards traffic)
Blocked = Neither (breaks the loop)

STP works by:

  1. Electing a Root Bridge: One switch becomes the β€œroot” of the spanning tree (lowest Bridge ID wins)
  2. Calculating Paths: Each switch determines its best path to the root
  3. Blocking Redundant Ports: Ports that would create loops are put in β€œblocking” state
  4. Monitoring: If a link fails, blocked ports can transition to forwarding

STP Versions

VersionStandardConvergenceNotes
STP802.1D30-50 secondsOriginal, slow
RSTP802.1w1-2 secondsRapid, most common
MSTP802.1s1-2 secondsMultiple spanning trees per VLAN

STP Security Implications

STP manipulates traffic flow, which attackers can exploit:

Root Bridge Manipulation: By advertising a lower Bridge ID, an attacker’s device can become the root bridge, forcing all traffic to flow through it.

STP Denial of Service: Sending topology change notifications can cause network instability as switches constantly recalculate.

Defenses:

  • BPDU Guard: Disable port if BPDU received (use on access ports)
  • Root Guard: Prevent port from becoming root port
  • BPDU Filter: Stop sending/receiving BPDUs (use with caution)

Security Note: STP attacks are covered in Part II, Chapter 2.


Layer 2 Security Summary

Defense in Depth at Layer 2

ThreatAttackDefense
MAC SpoofingAttacker changes MACPort Security, 802.1X
ARP SpoofingFake ARP repliesDAI, Static ARP, ARP inspection
MAC FloodingOverflow CAM tablePort Security limits
VLAN HoppingDouble tagging, switch spoofingProper VLAN config, no native VLAN
STP ManipulationBecome root bridgeBPDU Guard, Root Guard
Unauthorized AccessPhysical connection802.1X, NAC

Switch Hardening Checklist

Basic Switch Hardening

Basic Switch Hardening:
═══════════════════════════════════════════════════════════════════

β–‘ Change default passwords
β–‘ Enable SSH, disable telnet
β–‘ Configure management VLAN (not VLAN 1)
β–‘ Disable unused ports
β–‘ Put unused ports in "black hole" VLAN
β–‘ Configure all ports as access (not auto/trunk)
β–‘ Enable port security with MAC limits
β–‘ Enable BPDU Guard on access ports
β–‘ Enable Root Guard on non-root ports
β–‘ Enable Dynamic ARP Inspection (DAI)
β–‘ Enable DHCP Snooping
β–‘ Configure native VLAN (not VLAN 1)
β–‘ Enable logging to central syslog
β–‘ Enable NTP for synchronized timestamps
β–‘ Regular firmware updates

Key Takeaways

  1. Ethernet frames data with addressing and error detection, forming the foundation of wired LANs

  2. MAC addresses provide hardware-level device identification but can be easily spoofed

  3. ARP translates IP addresses to MAC addresses, but lacks authenticationβ€”making it vulnerable to spoofing attacks

  4. Switches intelligently forward traffic based on MAC addresses, creating efficient networks, but their CAM tables can be overwhelmed

  5. VLANs provide logical segmentation but aren’t a complete security boundaryβ€”proper configuration is essential

  6. 802.1X provides identity-based network access control, significantly improving security

  7. STP prevents loops but can be manipulated if not properly secured


Self-Assessment

  1. Comprehension: Why can an attacker send ARP replies for IP addresses they don’t own?

  2. Application: A switch suddenly starts flooding all unicast traffic to all ports. What attack might be occurring?

  3. What if: If 802.1X is deployed but MAB (MAC Authentication Bypass) is enabled for IoT devices, what risk remains?


Review Questions

  1. What information does an Ethernet frame header contain?
  2. How does a switch learn which devices are connected to which ports?
  3. Why is ARP vulnerable to spoofing attacks?
  4. What’s the difference between a collision domain and a broadcast domain?
  5. How do VLANs improve network security, and what are their limitations?
  6. What is the purpose of 802.1X, and what are its three main components?

Key RFCs and Standards

  • RFC 826 - An Ethernet Address Resolution Protocol (ARP)
  • RFC 5227 - IPv4 Address Conflict Detection
  • IEEE 802.3 - Ethernet
  • IEEE 802.1Q - Virtual LANs
  • IEEE 802.1X - Port-Based Network Access Control
  • IEEE 802.1D/w/s - Spanning Tree Protocol variants