Sub topic 9
Trunk negotiation and why to turn it off
This chapter assumes you can configure access and trunk ports, know what the native VLAN is, and can read basic Cisco IOS output. It covers how Cisco switches can form a trunk automatically, why that is a risk, and how to turn it off.
What DTP does
The Dynamic Trunking Protocol (DTP) is a Cisco-proprietary protocol. Two directly connected switch ports use it to agree on whether the link should be a trunk. DTP frames are sent on the link, and each side decides its operational mode from the frames it receives.
A port's administrative mode decides how it takes part:
switchport mode accessforces the port to be an access port. It does not send DTP frames on current IOS releases.switchport mode trunkforces the port to trunk. It still sends DTP frames, so a neighbor in a dynamic mode may trunk with it.switchport mode dynamic desirableactively asks the neighbor to trunk.switchport mode dynamic autoaccepts a trunk if the neighbor asks, but never asks.
On many Cisco platforms, the default mode is dynamic auto or dynamic desirable, depending on the model and IOS version. Check your platform.
Which combinations become trunks
| Local mode | Neighbor: dynamic auto | Neighbor: dynamic desirable | Neighbor: trunk | Neighbor: access |
|---|---|---|---|---|
| dynamic auto | access | trunk | trunk | access |
| dynamic desirable | trunk | trunk | trunk | access |
| trunk | trunk | trunk | trunk | mismatch |
The two dynamic auto ports end up as an access link because neither side asks. A trunk port facing an access port is a misconfiguration: one side tags frames and the other does not understand them.
Why to turn it off
Negotiation is convenient, but it lets a device decide the port's role. Two problems follow.
- Unwanted trunks. A port left in a dynamic mode will trunk with any device that sends DTP frames. An attacker can run software that imitates a switch, a technique called switch spoofing. Once the port trunks, the attacker can reach every VLAN allowed on it. This is one of the VLAN hopping attacks covered later.
- Unpredictable state. The port's operational mode depends on the neighbor. A change on the other switch can quietly turn an access link into a trunk, or the reverse.
The fix is to state the role of every port explicitly:
- User-facing ports: set
switchport mode access. - Switch-to-switch ports: set
switchport mode trunkandswitchport nonegotiate.
switchport nonegotiate stops the port from sending DTP frames. It is only allowed when the port is in trunk or access mode, not in a dynamic mode.
Configuration
interface GigabitEthernet0/24
switchport mode trunk
switchport trunk native vlan 999
switchport trunk allowed vlan 10,20
switchport nonegotiate
!
interface GigabitEthernet0/1
switchport mode access
switchport access vlan 10On switches that support both ISL and 802.1Q, enter switchport trunk encapsulation dot1q before switchport mode trunk.
Unused ports should also be set to access mode, assigned to an unused VLAN, and shut down.
Verifying the result
show interfaces GigabitEthernet0/24 switchportLook at two lines in the output. Administrative Mode shows what you configured. Operational Mode shows what the port is doing now. Negotiation of Trunking: Off confirms that nonegotiate is active.
Exercise
Switch A's port is set to switchport mode dynamic auto. Switch B's port on the same link is also dynamic auto. Does the link trunk? What is the smallest change that makes it trunk, and what should you do for a production link?
Show answer
No. Neither side initiates, so the link stays an access link. Setting either side to dynamic desirable or trunk makes it trunk. For a production link, set both sides to switchport mode trunk and add switchport nonegotiate, so the result does not depend on negotiation.