Sub topic 9
Trunk negotiation and why to turn it off
This chapter assumes you can already configure access and trunk ports, you know what the native VLAN and an allowed VLAN list are, and you can read basic Cisco IOS output. It covers how a switch port can decide on its own to become a trunk, why that is a risk, and how to turn it off.
What DTP does
The IEEE 802.1Q standard defines the tag format. It does not define a way for two switches to agree that a link should be a trunk. Cisco added that with the Dynamic Trunking Protocol (DTP), a proprietary protocol that works as follows:
- DTP frames are sent to the multicast address
01-00-0C-CC-CC-CC. Cisco's Layer 2 protocols, such as CDP, use the same address. - A port sends them about every 30 seconds while its mode allows negotiation.
- Each side advertises what it is willing to do, and both sides then settle on access or trunk.
- On switches that support both ISL and 802.1Q, DTP also negotiates the encapsulation.
Non-Cisco devices do not understand DTP. A Linux host, a printer or another vendor's switch ignores the frames, so DTP can never form a trunk with them.
The four administrative modes
The switchport mode command sets the administrative mode of a port. The default differs between platforms and software versions, so check your own switch with show interfaces <port> switchport. Many Catalyst switches default to dynamic auto.
| Mode | Sends DTP frames | Behavior |
|---|---|---|
| `access` | Not needed | Permanently a non-trunk port. |
| `trunk` | Yes | Permanently a trunk. It also tries to convince the neighbor to trunk. |
| `dynamic auto` | Yes (replies) | Becomes a trunk only if the neighbor asks. It never asks first. |
| `dynamic desirable` | Yes (initiates) | Actively asks the neighbor to trunk. |
switchport nonegotiate is not a mode. It is a separate setting that stops the port from sending DTP frames. IOS accepts it only on a port that is statically trunk or access. It is rejected on dynamic auto and dynamic desirable, because those modes cannot work without DTP.
Negotiation outcomes
The table shows the result for each pair of settings on the two ends of a link.
| Side A | Side B | Result |
|---|---|---|
| dynamic auto | dynamic auto | access |
| dynamic auto | dynamic desirable | trunk |
| dynamic desirable | dynamic desirable | trunk |
| dynamic auto | trunk | trunk |
| dynamic desirable | trunk | trunk |
| dynamic auto or desirable | access | access |
| trunk | access | mismatch |
The two-auto result surprises many people. Both ends wait to be asked, nobody asks, and the link stays an access link.
The trunk and access pairing is a misconfiguration. One end sends tagged frames and the other expects untagged ones. Traffic for the native VLAN may still pass, while tagged traffic is dropped or misplaced. Spanning tree and CDP messages can also behave oddly.
The Python function below encodes the table so you can check any pair.
def negotiate(a: str, b: str) -> str:
"""Return the outcome for two DTP-capable ports.
Modes: access, trunk, auto (dynamic auto), desirable (dynamic desirable).
"""
valid = {"access", "trunk", "auto", "desirable"}
if a not in valid or b not in valid:
raise ValueError("unknown mode")
pair = {a, b}
if pair == {"access", "trunk"}:
return "mismatch"
if "access" in pair:
return "access"
if "trunk" in pair or "desirable" in pair:
return "trunk"
return "access" # auto + auto: nobody initiates
for a, b in [("auto", "auto"), ("auto", "desirable"), ("trunk", "access")]:
print(a, b, "->", negotiate(a, b))The diagram shows the decision for one port in a dynamic mode.
Why negotiation is a security problem
A port in dynamic auto or dynamic desirable will become a trunk for anyone who speaks DTP. An attacker who plugs a laptop into such a port can send DTP frames, using a tool such as Yersinia or a crafted Scapy packet. The switch then turns the port into a trunk.
The attacker now receives tagged frames for every VLAN the trunk allows. By default that is every VLAN. They can also send frames tagged for any of those VLANs. This attack is called switch spoofing, and it is one of the two VLAN hopping methods covered in a later chapter.
Negotiation also causes ordinary operational problems:
- Surprise trunks. Someone sets one end to
desirableand a trunk forms that nobody planned. - Different defaults between models. The same cable behaves differently after a switch replacement.
- Link state hidden from the config.
show running-configon a dynamic port does not say whether the link is a trunk right now. You have to look at the operational state.
A trunk that exists because you configured it is predictable. A trunk that exists because two defaults happened to match is not.
Configuring a link without negotiation
Configure both ends of an inter-switch link statically and stop DTP frames. This is the trunk from the earlier chapter, with the relevant lines marked.
! Switch A and Switch B, uplink port
interface GigabitEthernet0/24
switchport trunk encapsulation dot1q
switchport mode trunk
switchport nonegotiate
switchport trunk native vlan 999
switchport trunk allowed vlan 10,20
!
! User-facing ports
interface range GigabitEthernet0/1 - 12
switchport mode access
switchport access vlan 10
switchport nonegotiateThe switchport trunk encapsulation dot1q line is needed only on switches that support both ISL and 802.1Q. Newer switches that support only 802.1Q reject it. The command must come before switchport mode trunk.
Apply switchport nonegotiate on both ends of the trunk. If you apply it on only one end, you can get a surprising result:
- Side A is
mode trunkwithnonegotiate. It sends no DTP frames. - Side B is
dynamic auto. It waits for a request that never arrives. - Side B therefore stays an access port while Side A is a trunk. This is the mismatch from the table, and it is the most common cause of "the trunk is half up" tickets.
Unused ports
Ports with nothing connected are the easiest place for an attacker to start. A common baseline for each unused port is:
- Set
switchport mode access. - Assign it to an unused VLAN that has no SVI and is not allowed on any trunk.
- Run
shutdown.
interface range GigabitEthernet0/13 - 23
switchport mode access
switchport access vlan 998
switchport nonegotiate
shutdownThis leaves no negotiation path and no useful VLAN, and it keeps the port down.
Checking the result
Three commands show the actual state of a port.
show interfaces GigabitEthernet0/24 switchport
show dtp interface GigabitEthernet0/24
show interfaces trunkIn the switchport output, compare these fields:
- Administrative Mode is what you configured, for example
trunkordynamic auto. - Operational Mode is what the port is doing now, for example
trunkorstatic access. - Negotiation of Trunking shows
Offwhennonegotiateis applied andOnotherwise.
If the administrative mode says dynamic auto and the operational mode says trunk, DTP made that decision. That is what you want to eliminate.
show interfaces trunk lists only ports that are actually trunking. A port you meant to be a trunk that is missing from this list is a negotiation or mismatch problem.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Both switches show the link as access | Both ends are `dynamic auto` | Configure `switchport mode trunk` on both ends. |
| One end shows trunk, the other access | `trunk` with `nonegotiate` against a dynamic port | Set the other end to `trunk`. |
| `nonegotiate` rejected | Port is in a dynamic mode | Set `switchport mode trunk` or `access` first. |
| Link to a non-Cisco switch never trunks | The neighbor does not speak DTP | Configure `trunk` statically on the Cisco side. |
| New switch behaves differently from the old one | Different default mode | Set the mode explicitly on every port. |
Summary
DTP is a Cisco-only convenience. It saves a few commands and costs predictability and security. In production, set every port to an explicit access or trunk. Add nonegotiate on trunks, shut down unused ports, and read the operational mode to confirm what the port is actually doing.
Exercise
Switch A's uplink is set to switchport mode dynamic auto. Switch B's uplink is set to switchport mode trunk with switchport nonegotiate. What mode does each port end up in, and why? What single change on Switch A fixes it permanently?
Show answer
Switch B is a static trunk and Switch A is an access port, so the link is mismatched. With nonegotiate, Switch B sends no DTP frames. Switch A in dynamic auto never initiates, so it never receives a request and stays access. Setting switchport mode trunk on Switch A (and adding nonegotiate there as well) fixes it.
Exercise
An attacker connects a laptop to a port configured as switchport mode dynamic desirable and sends DTP trunk requests. Name two configuration changes that stop this, and say what each one prevents.
Show answer
First, switchport mode access on the port. The port can no longer become a trunk, so the attacker never receives tagged traffic for other VLANs. Second, switchport nonegotiate (valid once the port is static), which stops the port from taking part in DTP. A third option that also works is shutdown on unused ports.