TechKnowSurge
Cisco CCNA 5.7 Cisco CCNA 1.13 Cisco CCNA 2.1 Cisco CCNA 2.2
VideoNetworkFree

DEMO: Mitigating VLAN Hopping

VLAN hopping is a low-frequency but preventable network attack, and the right switch configurations make mitigation straightforward. This content walks through the specific port and trunk settings that block the attack vectors attackers rely on.

Complete this video to capture a CTF flag worth 1 point.

About this video

VLAN hopping is a technique that requires more technical skill than many network attacks and offers attackers a relatively limited payoff, but it remains worth defending against because the countermeasures are both effective and easy to apply. The primary attack vectors are Dynamic Trunking Protocol negotiation, which can allow a rogue device to establish a trunk link with a switch, and double-tagging against the native VLAN, which can cause frames to be delivered across VLAN boundaries. Both are addressed through deliberate switch configuration rather than additional tooling or licensing. On access ports, the critical setting is explicitly locking the port to access mode so that DTP negotiation cannot occur and no trunk link can be established from the connected device. Additional hardening measures include shutting down any ports not in active use, placing unused ports in an isolated VLAN that has no DHCP server and no uplinks to the rest of the network, and avoiding VLAN 1 as the assigned VLAN for any production or user-facing port. These steps collectively eliminate most of the surface area an attacker would need to begin a VLAN hopping attempt. On trunk links, static trunk mode should be configured explicitly using the switchport mode trunk command, which disables DTP entirely on that interface. The native VLAN on all trunk links should also be changed from the default VLAN 1 to a dedicated VLAN that carries no user traffic, or disabled altogether if untagged frames are not required. On certain switch platforms and firmware versions, such as the Cisco 3750, setting the trunk encapsulation to 802.1Q must be done before the trunk mode command will be accepted. Once these settings are applied consistently across all trunk links in the environment, the configurations that enable VLAN hopping are no longer present on the network.

What you'll learn

What's covered

VLAN Hopping Mitigation

Aligned to

Cisco CCNA
5.7 Configure and verify Layer 2 security features
1.13 Describe switching concepts
2.1 Configure and verify VLANs (normal range) spanning multiple switches
2.2 Configure and verify interswitch connectivity

Key terms

Virtual LAN
VLAN
A logical grouping of network devices that behave as if they are on the same network regardless of physical location.
VLAN Hopping
An attack in which traffic reaches a VLAN it should not, either by negotiating a trunk on a port left in dynamic mode or by double-tagging a frame so the outer tag is stripped as the native VLAN and the inner tag carries it into another VLAN.
Dynamic Trunking Protocol
DTP
A Cisco proprietary protocol that automatically negotiates whether to establish a VLAN trunk link between two switches. DTP allows switches to dynamically determine trunking mode, though it is often disabled in production environments for security reasons.
Trunk Link
A switch port configured to carry traffic for multiple VLANs simultaneously between network devices using VLAN tagging.
Native VLAN
The one VLAN on an 802.1Q trunk whose frames are sent untagged. Any untagged frame received on the trunk is assigned to it. Both ends of a trunk must be configured with the same native VLAN.
Access Port
A switch port that belongs to a single data VLAN and sends and receives untagged frames, used for connecting end devices such as PCs and printers. An access port may additionally carry a tagged voice VLAN for an IP phone without becoming a trunk.

Topics

Vlan Hopping Dynamic Trunking Protocol Network Security Cisco Switches Vlan Configuration Switch Hardening

Transcript

VLAN hopping is probably not a very common attack on your networks. The fact is, it takes a little more technical know-how to attack your network, and the benefits of doing it aren't quite as great as some of the other ways to leverage your network. However, the mitigation against it is really easy, so you might as well make these changes on your network. In fact, what we've already done is made these changes on our network just by setting up these switches the way we did, so let's cover what those changes were.

Checking an Access Interface

So what configurations have we already made that help us mitigate against VLAN hopping? Let's take a look. I'm on switch 2 right now. Let's take a look at an access interface first. What I'm going to do is a show run, and we'll take a look at one of the access interfaces. Fa0/1 is one of those access interfaces, so we'll get into that.

We can see that first of all it's shut down. So that alone - an attacker can't utilize a shutdown port - that's just security in general, that's nice. And then this is part of a VLAN that doesn't go anywhere, so VLAN 5 can't be trunked to anywhere else on this network, and it's got no DHCP server on there, so it's just a dead end network. So that is also just helpful for security in general.

I don't like to use the default VLAN, and the default VLAN on the Cisco switch is VLAN one, so it is on a separate VLAN that doesn't go anywhere, and so that helps with security.

Now specifically for VLAN hopping, this is an access port and cannot be changed to a trunk port, and that is done by this command right here. So an attacker can't establish Dynamic Trunking Protocol, because this is an access port and it won't allow it to create a trunk line with whoever is on the other side. So an attacker can't utilize this. We've got several steps here that mitigate against VLAN hopping, and several steps that mitigate against several other types of attacks as well.

Checking a Port Channel

Next, let's take a look at one of our port channels. Remember, the port channels are going to be our trunk lines between the switches. So I'm going to do a show run, and we'll just take a look at port channel one.

Another thing is that, as I mentioned, the native VLAN is not the default VLAN. By default on our Cisco switches the native VLAN is going to be also the default VLAN, VLAN one. Now I've got this set up as native VLAN 2, so if something does need to connect to this trunk line, it's going to connect on a native VLAN of two. But if you didn't need a native VLAN, you could just turn this off altogether and then you would mitigate against that.

It also is allowing only certain VLANs to go across here. And then it also is set up so it is not using Dynamic Trunking Protocol - it's set up specifically as a trunk line, switchport mode trunk. So now no device that connects to this can establish that Dynamic Trunking Protocol.

Turning Off DTP on Port Channel 2

Now one thing that I did on one of my switches - switch two, switch one here - let's take a look at it, because it's set up a little differently. I'll do a show run and we'll do interface port channel, and let's take a look at port channel 2.

In this case right here, switchport mode dynamic desirable. So this switchport is set up with DTP, and I don't really like that, so I want to change this to be a trunk line. I'm going to get into there and I'm going to do a switchport mode trunk to turn off DTP. Oh, I do need to get into the interface first, so I'm going to get into the interface: interface port channel 2, and then let's do a switchport mode trunk, and that will turn off DTP.

And I get this rejection right here: the command was rejected, an interface whose trunk encapsulation is auto cannot be configured to trunk mode. So this is a problem. I want to set this for trunk mode and turn off DTP, but it's not allowing me to do this.

There's a simple way to find solutions, and that is to go to Google and look up what it is that you're trying to fix. So in this case I'm just going to type in "whose trunk port is auto". There it is, so it pops up in there.

The reason why this is different, the reason why this is not coming up, is because this is a different type of switch. This is a 3750 and it's got a different firmware version on it. So I looked this up, and what we need to do to fix this is going to be a switchport trunk encapsulation dot1q. So I need to change that first before I can enter in that other command.

Let's try that out: trunk encapsulation dot1q, hit enter. And now I want to do my switchport mode trunk. Now let's take a look at that interface. I'll do an end, do an up arrow, and there we go, now it's set to trunk, and now we don't have DTP turned on on this trunk line.

I would need to do this for my other two port channels as well, because each one of my trunk lines across here needs to be changed to the same type of setting.

About TechKnowSurge

TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.

Explore free tools and programs →