Watch on Instagram

Network Bytes · Episode 116 · CCNA 2.2

"DTP: how trunks negotiate, and why to turn it off"

Cisco switches can negotiate a trunk on their own with DTP, the Dynamic Trunking Protocol. A dynamic desirable port asks, a dynamic auto port waits to be asked. Because an attacker's laptop can speak DTP too, set ports by hand and add switchport nonegotiate.

Posted · About a 1 minute watch, 4 minute read · Take the quiz

What a trunk is

A trunk is a link, usually between two switches, that carries traffic for many VLANs over one cable. Each frame gets a small 802.1Q tag that says which VLAN it belongs to, so the switch at the other end can keep the VLANs apart (see EP31 for trunks and 802.1Q tags, and EP97 for the native VLAN). An access port, by contrast, belongs to one VLAN and carries untagged frames for a single device. You can make a port a trunk by hand, or let the two switches negotiate it.

How DTP negotiates

Cisco switches negotiate trunks with DTP, the Dynamic Trunking Protocol, a Cisco-proprietary protocol. The two ports send small DTP frames to each other, and each port's switchport mode decides how it behaves:

  • switchport mode dynamic desirable: the port actively asks the other side, "want to be a trunk?"
  • switchport mode dynamic auto: the port only answers. It never starts the negotiation, but it agrees if the other side asks.
  • switchport mode trunk: always a trunk. It still sends DTP frames unless you add switchport nonegotiate.
  • switchport mode access: never a trunk.

The rule from the video: if one side asks and the other agrees, the link becomes a trunk. For example, desirable facing auto becomes a trunk, and so does desirable facing desirable.

The danger: switch spoofing

DTP trusts whatever is plugged in. An attacker's laptop can send DTP frames too and pretend to be a switch. If the wall jack's switch port is left in a dynamic mode and agrees, the laptop gets a trunk, and with it traffic from every VLAN that trunk carries. This attack is called switch spoofing, a form of VLAN hopping. Many current Catalyst switches ship with ports in dynamic auto (some older models used dynamic desirable), so an unconfigured port can agree to a trunk with a device that asks.

The fix: set ports by hand, turn DTP off

Do not leave trunking to negotiation. Set every port by hand:

`` interface GigabitEthernet0/5 switchport mode access switchport nonegotiate ``

User-facing ports get switchport mode access; links between switches get switchport mode trunk. Then add switchport nonegotiate (spoken "no-negotiate") so the port stops sending and answering DTP frames. The command is accepted only on ports set to access or trunk. Cisco's best practices add one more step: don't use VLAN 1 as the native VLAN (EP97). To check a port, show interfaces <port> switchport shows its administrative mode, its operational mode and whether negotiation is on.

Try it yourself

If you have Packet Tracer, connect two switches with a crossover cable. Set one port to switchport mode dynamic desirable and the other to switchport mode access, then run show interfaces trunk on both sides and see whether a trunk appears. Then change the access side to switchport mode trunk and add switchport nonegotiate on both ends, and check again with show interfaces <port> switchport (look at "Negotiation of Trunking").

Good to know

  • CCNA 2.2 covers configuring and verifying interswitch connectivity: trunk ports and 802.1Q. Related episodes: EP31 (trunks and 802.1Q tags), EP97 (the native VLAN).
  • DTP is Cisco proprietary. Dynamic desirable actively sends DTP frames to try to form a trunk; dynamic auto only responds; trunk mode is always a trunk but still sends DTP unless switchport nonegotiate is added; access mode is never a trunk.
  • Desirable with desirable, auto or trunk forms a trunk, and auto with trunk forms a trunk ("one side asks and the other agrees").
  • switchport nonegotiate is accepted only on ports set to access or trunk.
  • Many current Catalyst switches default to dynamic auto; some older models defaulted to dynamic desirable.
  • The attack is called switch spoofing, a form of VLAN hopping. Best practice: user ports in access mode, DTP disabled, and VLAN 1 not used as the native VLAN.
  • Both switches must also agree on the trunk encapsulation and VTP domain for DTP to form a trunk; the video leaves that out.
  • The video draws generic switches, not any vendor's hardware.

For CCNA learners

CCNA exam topic 2.2 asks you to configure and verify trunk ports. Know the four switchport modes, which pairs form a trunk, and why switchport mode access or switchport mode trunk plus switchport nonegotiate is the secure choice.

Answer to the comment question

No. Both ports are in dynamic auto, and dynamic auto only answers when it is asked. Neither port starts the negotiation, so no one asks, and the link stays an access link. For a trunk to form through DTP, at least one side has to ask (dynamic desirable) or be set to trunk.

Test your knowledge

Quick quiz: "DTP: how trunks negotiate, and why to turn it off"

4 multiple-choice questions. Pick one answer for each, then check how you did.

1What does a trunk link carry?
2What does a port in dynamic desirable mode do?
3Why is leaving a user port in a dynamic mode risky?
4Which configuration stops DTP on a user port?

Sources

Video transcript

Can two switches decide to build a trunk all by themselves?

A trunk carries many VLANs over one cable. You can set it by hand, or let switches negotiate.

Cisco switches negotiate with DTP: the Dynamic Trunking Protocol.

A port in dynamic desirable asks, "Want to be a trunk?" A port in dynamic auto just waits to be asked.

If one side asks and the other agrees, the link becomes a trunk.

The danger: an attacker's laptop can speak DTP too. If the port agrees, the attacker gets a trunk to every VLAN.

So set ports by hand, access or trunk, and add switchport nonegotiate to turn DTP off.

Two ports are both set to dynamic auto. Trunk, yes or no? Comment your answer below!

That's your byte.

More from Network Bytes

All Network Bytes lessons