VLAN trunking allows multiple VLANs to travel across a single link between switches, eliminating the need for a dedicated cable per VLAN. The IEEE 802.1q standard governs this process by inserting a 4-byte tag into Ethernet frames to identify which VLAN the traffic belongs to.
VLAN Trunking
In prior videos we've learned how to set up VLANs on a switch, how to set up our switch so we can have multiple networks on that switch. But more than likely we're probably going to have multiple switches, and we're going to want those VLANs to communicate across all those switches. That's where trunking comes into play: trunking allows those VLANs to cross the link between switches.
Let's start out with a scenario where I don't have VLAN trunking on my network and I'm not going to set it up. In that scenario, what I'm going to have to do is run an ethernet cable between my switches for every single VLAN that I want connected across my network.
What I mean by that is, for instance, the demo laptop right here is set up on VLAN 10, the management VLAN. I also have a demo Pi set up on this management VLAN. If I didn't have VLAN trunking set up, I would have to have a cable — this is on an access port for VLAN 10 — and I would have to have another cable running from switch to switch that was for VLAN 10, between each of these switches, so that I could communicate across this network. But I'd have to do that for every single VLAN, so I'm going to have another cable for VLAN 20 that runs across there, and another cable for VLAN 30, and now I'm running cables for every single connection that I have out there.
This could be expensive. It could be expensive because of the cabling cost — ethernet doesn't cost all that much, but it could add up, especially if you're going longer distances, or if it's fiber it could be even more expensive. Or maybe it costs a lot of money to put that all into the ground, or however this is being routed from one location to another physically. More than that, it takes up valuable real estate on these switches. It's taking up these ports, and therefore it's going to require us to buy more switches at each one of these sites, which can get very expensive. So that is not a great scenario.
But what if we can carry all of the VLANs across a single interface? Then I just need to have my one cable that's running between each of these switches, and now whether you're on VLAN 10, 20, 30, 40, 50, it's all going across those same lines. That is a trunk line, and we need a protocol that's going to facilitate that.
Then we ask the question, what is IEEE 802.1Q? 802.1Q is what defines how this happens: how do we set up trunk lines, how do trunk lines function?
What it does is this. This demo laptop we have connected to VLAN 10, and the switch recognizes that it's connected to VLAN 10, so when it sends it over across to the next switch, what it will do is take that ethernet frame and slip a little tag into there, and that tag will say this is for VLAN 10. That way, when this switch gets it, it can see, oh yeah, this is part of VLAN 10, recognize that, and then adjust accordingly.
Let's say this is a broadcast packet and it's for VLAN 10. Then what it's going to do is send it out all of the ports that are associated with VLAN 10. If there are any access ports on this switch right here, then it will broadcast it out those VLAN 10 access ports. Or if this is a trunk line that has VLAN 10 on it, then it's going to send it down that trunk line, because it has VLAN 10 on the other side. Then this switch gets it and it does the same thing: if there are access ports that are associated with it, this VLAN 10 broadcast packet is going to be sent out all of those without being tagged, because they're access ports. So it gets tagged only on the trunk lines — going across the trunk lines, that's where it gets tagged. That broadcast then would make it out, and because this demo Pi is on VLAN 10, this demo Pi would receive that, whereas the other ones would not, because they're on different access ports for different VLANs.
From a frame perspective, if you recall, this is our ethernet frame right here, and our ethernet frame has a destination MAC address, a source MAC address, it has a type in there, and a trailer, a frame consistency check right there at the end. What an 802.1Q frame looks like is that we just slip in that tag in between. Right here we've slipped in the tag in between the source MAC address and the type field. Right here we slip in that tag with that VLAN information and then send it across that trunk line, and then it gets over to the other switch, and that other switch sees that — aha, I know what VLAN this is a part of, because I can see the tag.
The tag that gets inserted is 4 bytes, and it looks like this right here. The four bytes consist of two bytes of this tag protocol identifier; there's also three bits of PCP, or priority code point; there's a DEI, or drop eligible indicator; and then there's the VLAN ID. Really what we're mostly concerned about right now is this VLAN ID, because this is really what we're talking about, where it's tagging the VLAN information onto this frame before it sends it along.
One thing to note about this VLAN ID is that it is 12 bits long, or that is to the 12th. If you recall, when we're talking about binary, every bit has two possibilities — to the 12th, 4,096 — which is similar to how many VLANs we can set up on our Cisco devices. This is not by mistake. This is why there's a limit of 4,096 VLANs on our devices.
Just a little refresher on those VLAN IDs: don't forget that the VLAN ID of one is the Cisco default; 2 through 10001 is our normal range; we've got the 1002 through 1005, which are devoted to some other protocols; and then we have 1,6 through 4,094. So there we have about 4,096. One of them is zero, which we don't use, and then the other one is 4,95, which we don't use either. So there are our VLAN IDs that fit into that VLAN tag.
That is VLAN tagging. Pretty simplistic, really: 802.1Q defines what VLAN tagging is, takes that VLAN ID, inserts it in there, and sends it along.
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 →