> ## Content Index
> Fetch the complete content index at: https://www.pinglabz.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Yersinia on Kali: DTP Trunk Test Against a Cisco Switch Port
- URL: https://www.pinglabz.com/yersinia-dtp-trunk-test/
- Published: 2026-11-16T18:11:54.000Z
- Updated: 2026-11-16T18:12:17.000Z
- Description: Yersinia flipped a dynamic desirable access port into a full 802.1Q trunk in about 20 seconds. switchport mode access plus switchport nonegotiate left DTP disabled and the port never trunked again.
- Author: Jaime
- Tags: Kali Linux, DTP, VLAN Security, Cisco IOS XE, Network Engineering

A Cisco access port left in `dynamic desirable` or `dynamic auto` will form an 802.1Q trunk with anyone on the wire who speaks DTP, and a trunk carries every VLAN. The fast way to prove whether your access ports are safe is to try it: send DTP from Kali with Yersinia and watch the switch. In my home lab, `yersinia dtp -attack 1` turned a `dynamic desirable` port into a full trunk in about 20 seconds, and a `dynamic auto` port fell to the same frame. Setting `switchport mode access` with `switchport nonegotiate` stopped an identical second attack cold.

This post is that measured before and after on a Cisco IOS XE Layer 2 switch. The focus is the Cisco side, how to read `show interfaces switchport` and `show dtp`, and the hardening template, not the attack tool. The single trunking test is used only to confirm the port resists. Keep it inside an isolated lab.

![Yersinia DTP trunk test lab topology against a Cisco Layer 2 switch](https://storage.ghost.io/c/ff/28/ff28db4a-11e1-4835-b928-158974cf96c1/content/images/2026/11/diagram-yersinia-2.png)

Kali sends DTP to SW1's dynamic port; it trunks. mode access plus nonegotiate stops the next attack while the static trunk to SW2 keeps working.

## What DTP is doing

Dynamic Trunking Protocol lets two Cisco switches agree to trunk automatically. The administrative mode you set decides how a port behaves when a DTP partner appears.

| Administrative mode | Sends DTP?               | Becomes a trunk if the neighbor is... |
| ------------------- | ------------------------ | ------------------------------------- |
| dynamic auto        | Responds only            | trunk or desirable                    |
| dynamic desirable   | Actively asks            | trunk, desirable, or auto             |
| trunk               | Yes (unless nonegotiate) | always trunk                          |
| access              | No                       | never (stays access)                  |
| nonegotiate         | No                       | DTP off; mode is forced               |

The risk is the two dynamic modes on a host-facing port. `dynamic auto` waits to be asked; `dynamic desirable` asks first. Yersinia supplies the DTP frame either one needs, so both end up as a trunk. I confirmed both in this lab: `dynamic auto` and `dynamic desirable` each went to `Operational Mode: trunk` under the same attack. The default on many older templates was `dynamic auto`, which is why unconfigured ports are the classic problem.

## Lab setup

- **SW1** — Cisco IOS XE 17.18.2 Layer 2 switch
- **Kali** — Kali Rolling, yersinia 0.8.2, on `eth1` (no IP; DTP is Layer 2)
- **SW2** — a second switch on `Et1/0`, a real static trunk, to show the fix does not break legitimate trunks
- **Victim** — a host in VLAN 10

SW1 `Et0/1` faces Kali, `Et0/2` faces the victim, `Et0/3` faces the gateway, `Et1/0` is the inter-switch link to SW2\. Addresses use documentation ranges only. Built in my home lab and torn down afterward.

## Step 1: Install Yersinia

```
sudo apt install yersinia
yersinia dtp -attack ?
```

Attack `1` is `NONDOS attack enabling trunking`, the one used here. It is the single frame needed to see whether a port will negotiate a trunk. Everything else below is Cisco.

## Step 2: Make the port vulnerable and baseline it

Set the test port to `dynamic desirable`, then record the starting state before any DTP from Kali:

```
interface Ethernet0/1
 switchport mode dynamic desirable
```

```
SW1# show interfaces Ethernet0/1 switchport | include Administrative Mode|Operational Mode|Negotiation
SW1# show interfaces trunk
SW1# show dtp interface Ethernet0/1 | include TOS|FSM|packets received|Enabled
```

![Baseline: administrative dynamic desirable, operational static access, trunk table empty](https://storage.ghost.io/c/ff/28/ff28db4a-11e1-4835-b928-158974cf96c1/content/images/2026/11/yer-before-2.png)

Baseline: administrative dynamic desirable, operational static access, trunk table empty

Read this carefully. **Administrative Mode: dynamic desirable** but **Operational Mode: static access**, because no partner has spoken DTP yet. **Negotiation of Trunking: On** is the warning sign. The trunk table is empty and DTP shows `0 packets received`, FSM `S2:ACCESS`. A quick glance at "operational access" can fool you into thinking the port is safe. It is not; it is one DTP frame away from trunking.

## Step 3: Run the trunking test

Yersinia's attack mode waits for a keypress, so pipe a long-lived stdin or it exits before the switch reacts:

```
tail -f /dev/null | yersinia dtp -attack 1 -interface eth1
```

After about 20 seconds, poll SW1:

![After the attack: operational mode trunk, VLANs 1-4094, DTP FSM S6:TRUNK](https://storage.ghost.io/c/ff/28/ff28db4a-11e1-4835-b928-158974cf96c1/content/images/2026/11/yer-trunk-2.png)

After the attack: operational mode trunk, VLANs 1-4094, DTP FSM S6:TRUNK

### Reading the output

- **Operational Mode: trunk** is the finding. The administrative mode is still `dynamic desirable`; the operational mode is what the wire is actually doing.
- **\`show interfaces trunk\`** now lists `Et0/1`, encapsulation `n-802.1q`, native VLAN 1, **VLANs allowed 1-4094**. A port that was meant to be a single-VLAN access port now carries every VLAN the switch knows.
- **DTP FSM state S6:TRUNK**, neighbor MAC `00F57F1E3DBD` (Yersinia's spoofed address), and `3 packets received (3 good)` prove the switch accepted Kali's DTP frames. Before the attack that counter was 0.

### The frames on the wire

A capture on Kali shows the DTP exchange:

![tcpdump decode of the DTP frames Yersinia sends and the switch answers](https://storage.ghost.io/c/ff/28/ff28db4a-11e1-4835-b928-158974cf96c1/content/images/2026/11/yer-capture-1.png)

tcpdump decode of the DTP frames Yersinia sends and the switch answers

Yersinia sends DTPv1 frames from a spoofed source MAC to the Cisco DTP multicast `01:00:0c:cc:cc:cc`, carrying a status TLV (`0x03`, value `0xa5`) that asks to trunk. The switch answers with its own DTP frame (status value `0xa0`). Those replies are the negotiation that flips the port.

## Step 4: Harden the port

The fix is two lines on the access port, plus the usual host-port protections:

```
interface Ethernet0/1
 switchport mode access
 switchport access vlan 10
 switchport nonegotiate
 spanning-tree portfast
 spanning-tree bpduguard enable
```

```
SW1# show interfaces Ethernet0/1 switchport | include Administrative Mode|Operational Mode|Negotiation
SW1# show dtp interface Ethernet0/1 | include FSM|Enabled
```

![After hardening: static access, negotiation off, DTP disabled, FSM S1:OFF](https://storage.ghost.io/c/ff/28/ff28db4a-11e1-4835-b928-158974cf96c1/content/images/2026/11/yer-fix-1.png)

After hardening: static access, negotiation off, DTP disabled, FSM S1:OFF

**Negotiation of Trunking: Off** and DTP **Enabled: no**, **FSM state S1:OFF**. `switchport mode access` alone sets the intent, but `switchport nonegotiate` is what actually silences DTP on the port. Use both.

## Step 5: Prove the fix holds

Run the same Yersinia attack for another 25 seconds against the hardened port, with the legitimate trunk to SW2 live:

![Re-run attack: port stays access, DTP off, 6 packets received 0 good, trunk table shows only the legit SW2 trunk](https://storage.ghost.io/c/ff/28/ff28db4a-11e1-4835-b928-158974cf96c1/content/images/2026/11/yer-proof-1.png)

Re-run attack: port stays access, DTP off, 6 packets received 0 good, trunk table shows only the legit SW2 trunk

Yersinia still sends frames, but the switch counts `6 packets received (0 good)`, drops all 6 as `other`, stays in `S1:OFF`, and never forms a trunk. The only entry in `show interfaces trunk` is `Et1/0`, the legitimate static trunk to SW2 on native VLAN 999\. The hardening stopped the attack without touching the real trunk, which is the result you want: the control blocks the negotiation but leaves authorized trunking alone.

## The hardening template

Apply this to every host-facing access port, and keep real trunks static:

```
! host ports
interface range Ethernet0/1 - 2
 switchport mode access
 switchport access vlan 10
 switchport nonegotiate
 spanning-tree portfast
 spanning-tree bpduguard enable
!
! unused ports: shut, in a parking VLAN
interface range Ethernet1/1 - 3
 switchport mode access
 switchport access vlan 999
 switchport nonegotiate
 shutdown
!
! real trunk: static, DTP off, native VLAN moved off 1
interface Ethernet1/0
 switchport trunk encapsulation dot1q
 switchport mode trunk
 switchport trunk native vlan 999
 switchport trunk allowed vlan 10,999
 switchport nonegotiate
```

Three habits matter here: `switchport nonegotiate` everywhere so DTP never runs, unused ports shut in a dead parking VLAN, and the native VLAN moved off VLAN 1 on trunks. During the attack the formed trunk used native VLAN 1 even though the access VLAN was 10, and that mismatch is the opening for double-tagging [VLAN hopping](https://www.pinglabz.com/vlan-hopping-attacks/).

At scale, do not configure this port by port. Define the access-port behavior once (an interface template or your switch build macro), apply it to every edge range, and keep `switchport nonegotiate` in the base template so a newly patched port is never a dynamic port. A good `show interfaces status` or `show interfaces trunk` audit after any change catches the one port someone set by hand.

## Verification methods compared

| Method                           | What it tells you                                     | Speed                   |
| -------------------------------- | ----------------------------------------------------- | ----------------------- |
| show interfaces switchport       | Administrative vs operational mode, negotiation state | Instant, per port       |
| show interfaces trunk            | Which ports are actually trunking right now           | Instant, switch-wide    |
| show dtp interface               | DTP FSM state, neighbor, packet counters              | Instant, deepest detail |
| DTP capture in Wireshark/tcpdump | The frames themselves, for proof                      | Needs a capture         |
| Yersinia active test             | Confirms behavior end to end                          | \~20 s per port         |

For a routine audit, `show interfaces trunk` across the switch plus `Negotiation of Trunking` is enough. The active Yersinia test is for proving a specific port really resists.

## What breaks

The hardening is safe on access ports, but a few changes bite if you apply them without reading the port first.

- **\`nonegotiate\` on a trunk that still relies on DTP.** If an inter-switch link was coming up only because both sides negotiated, forcing `nonegotiate` without setting a static `switchport mode trunk` on both ends drops the trunk. Make the trunk static first, then turn DTP off.
- **Encapsulation ordering on this image.** `switchport mode trunk` is rejected until `switchport trunk encapsulation dot1q` is set, and `switchport nonegotiate` is rejected while the mode is still dynamic. Set encapsulation, then mode, then nonegotiate.
- **A formed trunk carries every VLAN.** While the attacked port was trunking it allowed VLANs 1-4094, so any VLAN on the switch was briefly reachable from that port. That is why the test must stay in an isolated lab.
- **Native VLAN 1 on the formed trunk.** The attacker-formed trunk took native VLAN 1 even though the access VLAN was 10\. Moving native VLANs off 1 on real trunks closes the double-tagging path.

## DTP hardening cheat sheet

| Goal                         | Command                                                                                     |
| ---------------------------- | ------------------------------------------------------------------------------------------- |
| Force access, no negotiation | switchport mode access \+ switchport nonegotiate                                            |
| Protect the edge             | spanning-tree portfast \+ spanning-tree bpduguard enable                                    |
| Static trunk, DTP off        | switchport trunk encapsulation dot1q then switchport mode trunk then switchport nonegotiate |
| Move native off VLAN 1       | switchport trunk native vlan 999                                                            |
| Park unused ports            | switchport access vlan 999 \+ shutdown                                                      |
| Audit                        | show interfaces trunk, show interfaces switchport, show dtp interface                       |

## Gotchas

**Yersinia exits immediately.** Attack mode waits for a keypress; if stdin closes it stops before the switch reacts. Pipe `tail -f /dev/null` or run it from a real terminal.

**"Operational Mode: static access" is not "safe".** On a `dynamic` port that just means no partner has spoken DTP yet. Check `Negotiation of Trunking`; if it is `On`, the port is exposed.

**Static trunks need encapsulation first.** On this image, `switchport mode trunk` is rejected until you set `switchport trunk encapsulation dot1q`, and `switchport nonegotiate` is rejected while the mode is still dynamic. Set encapsulation, then mode, then nonegotiate.

**Native VLAN 1 on a formed trunk.** The attacker-formed trunk took native VLAN 1 even though the access VLAN was 10\. Move native VLANs off 1 on real trunks to close the double-tagging path.

## FAQ

### Does \`dynamic auto\` also trunk with Yersinia?

Yes, confirmed in this lab. `dynamic auto` waits for the other side to ask, and Yersinia's enabling-trunking attack is that ask, so the port went to `Operational Mode: trunk` just like `dynamic desirable`. `dynamic desirable` is more aggressive because the switch asks first, but both end in a trunk once DTP succeeds.

### Is \`switchport mode access\` enough without \`nonegotiate\`?

Not on its own. Mode access sets intent, but DTP can still run unless you add `nonegotiate`. In this lab, mode access plus nonegotiate left DTP `Enabled: no` and FSM `S1:OFF`, and the re-run attack counted `6 packets received (0 good)`. Use both on host ports.

### Will \`nonegotiate\` break a real trunk between switches?

Only if the trunk still relies on DTP to come up. Configure inter-switch links as static `switchport mode trunk` with `switchport nonegotiate` on both ends, as on `Et1/0` above, and DTP is simply not needed. The static trunk to SW2 kept working throughout the hardened re-test.

### What is the native VLAN mismatch about?

A trunk has one native (untagged) VLAN. If an access port trunks with native VLAN 1 while hosts live in VLAN 10, an attacker can double-tag frames to hop VLANs. Moving native VLANs off 1 and never trunking host ports closes that.

### Can Yersinia also attack STP?

Yes, through separate STP attacks such as claiming root. That is a different test; pair it with [BPDU Guard](https://www.pinglabz.com/bpdu-guard-rogue-bridge-lab/) and Root Guard rather than mixing it into this DTP proof.

### Is Yersinia still maintained?

Upstream releases are infrequent. Kali still ships 0.8.2 and it worked for this DTP test. Treat it as a lab audit tool, not a production dependency.

## Key takeaways

- `yersinia dtp -attack 1` against a `dynamic desirable` or `dynamic auto` port formed a full trunk in about 20 seconds; `show interfaces trunk` and DTP FSM `S6:TRUNK` were the proof.
- `switchport mode access` plus `switchport nonegotiate` stopped the same attack: DTP went to `Enabled: no`, FSM `S1:OFF`, and the re-run counted 6 packets received, 0 good.
- Read `Negotiation of Trunking`, not just operational mode; a dynamic port can read "static access" and still be one frame from trunking.
- Harden every host port to static access with DTP off, park and shut unused ports, and keep real trunks static with the native VLAN off 1.

One line of scope: this validates DTP hardening on access ports; VTP, STP root attacks, and 802.1X on the edge are separate controls with their own tests.

**More in this series:** [thc-ipv6 on Kali](https://www.pinglabz.com/thc-ipv6-ra-guard-test/) to test IPv6 RA Guard on the same switch, [arpwatch](https://www.pinglabz.com/how-to-use-arpwatch/) to catch other Layer 2 spoofing on the wire, and [How to Use Wireshark](https://www.pinglabz.com/how-to-use-wireshark/) to read the DTP captures.

## Related

- [DTP: Dynamic Trunking Protocol Explained](https://www.pinglabz.com/dtp-dynamic-trunking-protocol/)
- [VLAN Hopping Attacks](https://www.pinglabz.com/vlan-hopping-attacks/)
- [BPDU Guard: Catch a Rogue Bridge](https://www.pinglabz.com/bpdu-guard-rogue-bridge-lab/)
- [VLAN Access Ports and switchport modes](https://www.pinglabz.com/vlan-access-ports-switchport-modes/)
- [Tagged vs Untagged VLANs](https://www.pinglabz.com/tagged-vs-untagged-vlans/)