Yersinia and layer 2 protocol risks: STP, DTP, CDP, and DHCP on switches

Yersinia is a lab framework for testing layer 2 protocols such as STP, DTP, CDP, and DHCP. What each protocol risk means for a switch network, and the hardening that removes it: BPDU Guard, disabled DTP, and DHCP snooping.

Lesson 12 of 17 · 11 min read · practice only with authorization

Diagram

Layer 2 protocols an access port should not trust

Follow the path. One example at a time.

Step 1 of 4

DTP

A host negotiating a trunk could reach every VLAN.

Illustration: DTP
Switch# show interfaces Gi1/0/12 switchport | include Mode
Administrative Mode: dynamic auto
Operational Mode: static access

The example on the open step is one illustration, or the fix you can paste into an application you own.

What this page is made of

3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.

  1. Trunk negotiation

    What fails
    Ports left in dynamic mode can become trunks.
    Who is affected
    Every VLAN on the switch.
    What you would notice
    Access ports in dynamic auto or desirable.
    What you change
    Set switchport mode access and nonegotiate.
  2. Spanning tree

    What fails
    BPDUs from user ports can change the topology.
    Who is affected
    The whole layer 2 domain.
    What you would notice
    No BPDU Guard on edge ports.
    What you change
    Enable BPDU Guard and Root Guard where appropriate.
  3. Discovery leaks

    What fails
    CDP and LLDP announce details to any listener.
    Who is affected
    Network devices.
    What you would notice
    CDP enabled on user-facing ports.
    What you change
    Disable on edge ports; keep on infrastructure links if needed.

Using Yersinia responsibly

Yersinia belongs on an isolated lab switch or a simulator such as GNS3 or EVE-NG, never on a production network, where it can cause outages. In the lab, it shows whether the hardening above actually stops trunk negotiation and BPDU injection, which is the defensive question.

Auditing switch configs

Configuration audits catch most of this without sending a packet. Pull configs with your network automation tool and search for access ports missing nonegotiate or bpduguard.

$ grep -B2 -A8 "^interface GigabitEthernet1/0/" sw-floor3.cfg | grep -E "^interface|bpduguard|nonegotiate"

Check yourself

Recognition and the fix. Nothing here is a procedure.

1 / 3

An access port is in dynamic auto mode. What is the risk?

Sibling techniques

Pages at the same depth, plus a lab and a glossary card for this one.

  1. MapNetwork protocols for defenders: what each layer tells you in a captureEthernet, IP, TCP, UDP, DNS, TLS, and HTTP as they appear in a packet capture: the fields worth reading at each layer, a worked tcpdump trace of one web request, and which protocols leak what.

Practice

  1. LabControl benchA failure is described. Choose the control that changes the outcome.