VLANs, Priority Tagging and Link Aggregation
How one switch becomes several isolated LANs with 802.1Q VLANs, what the 4-byte tag carries, access and trunk ports, routing between VLANs, Q-in-Q, 802.1p priority classes, and how LACP bundles several links into one with per-flow hashing.
kvi5hnuCode Sprout team member19 min readOn this page
A switched Ethernet can connect every computer in a building into one big LAN. Any host can reach any other with no routing, and broadcasts reach everyone. That's convenient, but it's also the problem:
- Broadcast and multicast traffic goes to every port. ARP requests (hosts asking for a neighbor's MAC address, article 21), DHCP discovery (hosts looking for a server to give them an address, article 29), service announcements and IPv6 multicasts add up as the LAN grows, and every host must look at them.
- No isolation. The finance department's computers, the guest Wi-Fi and the security cameras can all talk to each other directly at the link layer.
- Physical layout dictates the network. Without some other mechanism, the only way to put two groups on separate LANs is separate switches and cables.
Virtual LANs (VLANs), defined in IEEE 802.1Q, solve this by splitting one physical switched network into several logical ones. Each VLAN is its own broadcast domain: frames in VLAN 10 never reach ports in VLAN 20, even on the same switch. To get from one VLAN to another, traffic must go through a router, exactly as if the VLANs were separate physical LANs.
How a switch assigns frames to VLANs
A VLAN-aware switch decides which VLAN each incoming frame belongs to. The common methods:
- By port. Each switch port is assigned to one VLAN, and everything plugged into it belongs to that VLAN. This is by far the most common method because it's simple and hard to get around.
- By MAC address. The switch keeps a table mapping source MAC addresses to VLANs. That breaks easily, because MAC addresses change (randomized Wi-Fi addresses, replaced network cards) and are easy to fake.
- By protocol or IP subnet. The switch looks at the EtherType or the IP source address. This is rarely used today.
- By authentication. With 802.1X (port-based network login, article 81), a user or device logs in, and the authentication server tells the switch which VLAN to put that port in. Enterprise networks use this to put employees, guests and printers on different VLANs from the same wall socket.
Access ports and trunk ports
On one switch, port membership is enough. But VLANs usually span several switches, and the link between two switches carries traffic for many VLANs. The receiving switch must be told which VLAN each frame belongs to, so frames on such a link carry a VLAN tag. That gives two kinds of port:
- An access port belongs to one VLAN and sends and receives untagged frames. Ordinary computers, printers and phones connect here and never see a tag.
- A trunk port carries several VLANs, with each frame tagged with its VLAN number. Trunks connect switches to each other, and to routers, servers and hypervisors (the software that runs virtual machines) that handle many VLANs.
Many switches also let a trunk carry one VLAN untagged, called the native VLAN (Cisco's term) or the port's PVID (port VLAN ID, the 802.1Q term). Untagged frames arriving on the trunk are put in that VLAN.
The 802.1Q tag
The tag is 4 bytes inserted between the source MAC address and the EtherType:

- TPID (16 bits), the tag protocol identifier, is
0x8100. It sits where the EtherType normally is, so a device that doesn't understand tags sees an unknown EtherType rather than garbage. The real EtherType follows the tag. - PCP (3 bits), the priority code point, holds one of eight priority values. This is the 802.1p part, explained below.
- DEI (1 bit), the drop eligible indicator, marks frames that may be dropped first when a switch is congested. It used to be called CFI (canonical format indicator) and had a different meaning.
- VID (12 bits) is the VLAN number. Of the 4096 values,
0means "no VLAN, this tag only carries a priority" and4095is reserved, leaving 4094 usable VLANs. VLAN1is the default VLAN on most switches.
The tag makes the frame 4 bytes longer, so the largest tagged frame is 1522 bytes. The payload limit stays 1500, so the MTU (the largest payload a frame can carry, article 14) is unchanged.
VLANs in the lab
The lab builds a VLAN-aware switch from a Linux bridge with VLAN filtering turned on, and plugs in four hosts and a router:

Note the trap set for h2. It has an address in the same IP subnet as h1 (192.0.2.12), but its port is in VLAN 20. Here's the switch's VLAN table. PVID Egress Untagged marks an access port: untagged frames coming in join that VLAN, and frames going out have their tag removed. The trunk tr carries VLANs 10 and 20, both tagged:
port vlan-id
p1 10 PVID Egress Untagged
p2 20 PVID Egress Untagged
p3 10 PVID Egress Untagged
p4 20 PVID Egress Untagged
tr 10
20
h1 can reach h3, which is in the same VLAN:
PING 192.0.2.11 (192.0.2.11) 56(84) bytes of data.
64 bytes from 192.0.2.11: icmp_seq=1 ttl=64 time=0.045 ms
64 bytes from 192.0.2.11: icmp_seq=2 ttl=64 time=0.058 ms
h1 can't reach h2, even though their addresses say they're on the same subnet. h1 broadcasts an ARP request asking for 192.0.2.12, but the switch delivers it only to VLAN 10 ports, so h2 never hears it:
2 packets transmitted, 0 received, 100% packet loss, time 1020ms
A host in another VLAN can be reached only through a router. The router r has one physical interface on the trunk and two VLAN subinterfaces on Linux, eth0.10 and eth0.20, each acting like a separate network card in its VLAN. This design is called a router on a stick. They were created like this:
ip link add link eth0 name eth0.10 type vlan id 10
ip link add link eth0 name eth0.20 type vlan id 20 egress-qos-map 0:5
h1 pings h4 in VLAN 20 through the router:
64 bytes from 198.51.100.20: icmp_seq=1 ttl=63 time=0.269 ms
A capture on the trunk port shows the same ping crossing the trunk twice in each direction. Each line gives the frame length, source and destination MAC, VLAN ID, priority, IP addresses and packet type:
frame.len eth.src eth.dst vlan.id vlan.priority ip.src ip.dst _ws.col.info
102 02:00:00:00:10:01 02:00:00:00:00:fe 10 0 192.0.2.10 198.51.100.20 Echo request id=0x006b
102 02:00:00:00:00:fe 02:00:00:00:20:04 20 5 192.0.2.10 198.51.100.20 Echo request id=0x006b
102 02:00:00:00:20:04 02:00:00:00:00:fe 20 0 198.51.100.20 192.0.2.10 Echo reply id=0x006b
102 02:00:00:00:00:fe 02:00:00:00:10:01 10 0 198.51.100.20 192.0.2.10 Echo reply id=0x006b
The request arrives from h1 tagged with VLAN 10. The router sends it back down the same cable tagged with VLAN 20, after rewriting the MAC addresses as every router does. Notice priority 5 on the frames the router sends into VLAN 20: the egress-qos-map 0:5 option maps the kernel's default priority 0 to PCP 5 on that subinterface. The frames are 102 bytes, which is the 98-byte frame of a default ping (14-byte Ethernet header plus an 84-byte IP packet) plus the 4-byte tag. Here is the tag decoded, followed by the start of the raw frame. 81 00 is the TPID, and 00 0a is binary 000 0 000000001010: priority 0, DEI 0, VLAN 10:
802.1Q Virtual LAN, PRI: 0, DEI: 0, ID: 10
000. .... .... .... = Priority: Best Effort (default) (0)
...0 .... .... .... = DEI: Ineligible
.... 0000 0000 1010 = ID: 10
Type: IPv4 (0x0800)
0000 02 00 00 00 00 fe 02 00 00 00 10 01 81 00 00 0a ................
0010 08 00 45 00 00 54 81 ed 40 00 40 01 cc 69 c0 00 ..E..T..@.@..i..
Routing between VLANs used to be slow compared with switching, so VLANs were sometimes avoided. Today layer 3 switches route between VLANs at full switching speed, and router-on-a-stick is mostly found in small networks, labs and virtualized setups.
Priority: 802.1p classes of service
The 3-bit PCP field gives each frame one of eight priorities. A switch with several output queues can send high-priority frames first when a port is busy. The standard recommends which traffic goes where:
| PCP | Recommended use |
|---|---|
| 1 | Background (bulk transfers, backups), the lowest |
| 0 | Best effort, the default for ordinary traffic |
| 2 | Excellent effort |
| 3 | Critical applications |
| 4 | Video, under 100 ms latency |
| 5 | Voice, under 10 ms latency |
| 6 | Internetwork control (routing protocols) |
| 7 | Network control, the highest |
Note that 1 ranks below 0. The standard defines only how priority is carried. How a switch maps PCP values to queues, and how the queues share the link, is up to the vendor and the network administrator. A tag with VID 0 carries only a priority, so priority can be used without VLANs. At the IP layer the same job is done by the DSCP (Differentiated Services Code Point) field (article 25), which survives routers, while the 802.1p priority is lost at the first router unless the router copies it across.
Q-in-Q: tags inside tags
A provider that carries Ethernet for many customers faces a problem: every customer uses its own VLAN numbers, and they overlap. IEEE 802.1ad ("provider bridging", nicknamed Q-in-Q) lets the provider add its own outer tag with TPID 0x88A8, called the S-tag (service tag), around the customer's inner C-tag (customer tag) with TPID 0x8100. Here the lab builds a service VLAN 100 carrying customer VLAN 10, and captures one frame:
Ethernet II, Src: 02:00:00:00:0a:01 (02:00:00:00:0a:01), Dst: 02:00:00:00:0b:02 (02:00:00:00:0b:02)
Destination: 02:00:00:00:0b:02 (02:00:00:00:0b:02)
Source: 02:00:00:00:0a:01 (02:00:00:00:0a:01)
Type: 802.1ad Provider Bridge (Q-in-Q) (0x88a8)
IEEE 802.1ad, ID: 100
.... 0000 0110 0100 = ID: 100
Type: 802.1Q Virtual LAN (0x8100)
802.1Q Virtual LAN, PRI: 0, DEI: 0, ID: 10
.... 0000 0000 1010 = ID: 10
Type: IPv4 (0x0800)
0000 02 00 00 00 0b 02 02 00 00 00 0a 01 88 a8 00 64 ...............d
0010 81 00 00 0a 08 00 45 00 00 54 65 75 40 00 40 01 ......E..Teu@.@.
The frame now has two 4-byte tags, 88 a8 00 64 (VLAN 100) followed by 81 00 00 0a (VLAN 10). Each tag adds 4 bytes, so double-tagged frames need equipment that accepts frames of at least 1526 bytes. Q-in-Q also lifts the 4094-VLAN limit to about 16 million combinations, although large data centers today more often use VXLAN (Virtual Extensible LAN, article 20), which carries a 24-bit network ID inside UDP.
Link aggregation: several links acting as one
Link aggregation, also called bonding, teaming, port channel or EtherChannel, combines several physical links between the same two devices into one logical link. It gives you two things:
- More capacity. Four 10 Gb/s links act like one 40 Gb/s link for many flows at once.
- Redundancy. If one member link fails, traffic moves to the others without the logical link going down.
The standard is IEEE 802.1AX (it started as 802.3ad, the name you'll still see in Linux options). Its control protocol, LACP (Link Aggregation Control Protocol), lets both ends confirm which links belong together, instead of relying on manual configuration that could, for example, bundle a cable plugged into the wrong switch. Each end sends LACPDUs to the reserved multicast address 01:80:c2:00:00:02 with the "slow protocols" EtherType 0x8809. A LACPDU describes the sender (the actor) and what it knows about the other end (the partner): system ID (a MAC address), port number, port priority and a key that identifies which ports may be grouped. Links whose information matches on both sides form a link aggregation group (LAG).
The lab builds a two-link LACP bond between srv and sw using Linux's bonding driver in mode 802.3ad. The driver's status file below calls each member link a Slave Interface. Both members show the same Aggregator ID, which means they joined one LAG, and the second listing shows that both ends use key 15 and that the partner is sw's MAC address:
Bonding Mode: IEEE 802.3ad Dynamic link aggregation
Transmit Hash Policy: layer3+4 (1)
LACP active: on
LACP rate: fast
Slave Interface: e1
Aggregator ID: 1
Slave Interface: e2
Aggregator ID: 1
Active Aggregator Info:
Aggregator ID: 1
Number of ports: 2
Actor Key: 15
Partner Key: 15
Partner Mac Address: 02:00:00:00:0b:01
The first LACPDUs on one member link show the two ends learning about each other. In the first one the partner is still all zeros, and within a second each side lists the other as its partner. With lacp_rate fast, LACPDUs go out every second, against every 30 seconds with the default slow rate. (subtype=0x01 identifies LACP among the protocols that share the slow-protocols EtherType.)
0.000 02:00:00:00:0a:01 -> 01:80:c2:00:00:02 subtype=0x01 actor=02:00:00:00:0a:01 key=15 port=1 partner=00:00:00:00:00:00
0.007 02:00:00:00:0b:01 -> 01:80:c2:00:00:02 subtype=0x01 actor=02:00:00:00:0b:01 key=15 port=1 partner=02:00:00:00:0a:01
0.952 02:00:00:00:0a:01 -> 01:80:c2:00:00:02 subtype=0x01 actor=02:00:00:00:0a:01 key=15 port=1 partner=02:00:00:00:0b:01
0.952 02:00:00:00:0b:01 -> 01:80:c2:00:00:02 subtype=0x01 actor=02:00:00:00:0b:01 key=15 port=1 partner=02:00:00:00:0a:01
1.896 02:00:00:00:0a:01 -> 01:80:c2:00:00:02 subtype=0x01 actor=02:00:00:00:0a:01 key=15 port=1 partner=02:00:00:00:0b:01
1.896 02:00:00:00:0b:01 -> 01:80:c2:00:00:02 subtype=0x01 actor=02:00:00:00:0b:01 key=15 port=1 partner=02:00:00:00:0a:01
Decoding the last LACPDU in the capture shows the state flags both ends agreed on. Synchronization means the link is in the right aggregation group, and Collecting and Distributing mean it's carrying traffic in both directions. LACP Activity means the end sends LACPDUs on its own, LACP Timeout here means the fast timeout, and Aggregation that the link may be bundled. Those six flags are the six lowest bits of the state byte, which is why it reads 0x3f (binary 00111111):
Actor Key: 15
Actor Port: 1
Actor State: 0x3f, LACP Activity, LACP Timeout, Aggregation, Synchronization, Collecting, Distributing
Partner State: 0x3f, LACP Activity, LACP Timeout, Aggregation, Synchronization, Collecting, Distributing
Why one connection can't use two links
A LAG doesn't spread frames one by one across its links. If it did, frames of one TCP connection would travel over links with slightly different delays and arrive out of order, which TCP handles badly (article 67). Instead the sender computes a hash over fields that identify a flow, and every frame of a flow goes over the same member link. Common choices: source and destination MAC (layer2), IP addresses (layer3), or IP addresses plus TCP/UDP ports (layer3+4, used in the lab). The consequences:
- One flow never goes faster than one member link. A single file copy over a 4 × 10 Gb/s bond still tops out at 10 Gb/s.
- The split depends on the hash. With few flows, it can put most or all of them on one link.
The lab opened eight TCP connections over the bond to the same server port, twice. Only the client's source ports differed between the two runs. A capture on each member link shows which connections it carried. First with eight consecutive source ports:
e1: source ports 41000,41001,41004,41005
e2: source ports 41002,41003,41006,41007
Then with eight different source ports:
e1: source ports 41000,41001,41004,41005,41008,41009,41012,41013
e2: source ports

Same hosts, same server, same number of connections. In the second run, every connection hashed onto e1, and the second link sat idle. Real clients pick their source ports at random, so a real bond lands somewhere between these extremes, and with only a few large flows the imbalance can be severe. Bonds work best with many flows.
Finally, the lab pinged across the bond every 50 ms while it took one member link down:
80 packets transmitted, 80 received, 0% packet loss, time 4166ms
No ping was lost: the bond noticed the dead link immediately (the lab's virtual links report carrier loss instantly) and moved everything to the remaining member. On real hardware, failover takes from a few milliseconds when the link loses signal, up to 3 seconds (fast rate) or 90 seconds (slow rate) when the link stays up but stops passing LACPDUs.
Linux bonding modes
Linux supports more than LACP. The mode option picks one:
| Mode | Name | What it does | Needs switch support? |
|---|---|---|---|
| 0 | balance-rr | Round-robin, frame by frame | Static aggregation; reorders TCP |
| 1 | active-backup | One link active, others on standby | No |
| 2 | balance-xor | Hash-based, no negotiation | Static aggregation |
| 3 | broadcast | Every frame on every link (rarely used) | Static aggregation |
| 4 | 802.3ad | LACP with hash-based distribution | LACP |
| 5 | balance-tlb | Adapts outgoing load per peer | No |
| 6 | balance-alb | Also balances incoming traffic by rewriting ARP replies | No |
active-backup is the safe choice when the switches can't be configured. LACP is the standard choice when they can. Bundling links that end on two different switches isn't part of basic 802.1AX: vendors offer it as MLAG or MC-LAG (multi-chassis link aggregation), and modern data centers often use EVPN (Ethernet VPN, a way to build layer 2 networks over a routed IP network) multihoming instead.
Common questions
What's the difference between a VLAN and a subnet?
A VLAN is a layer 2 broadcast domain: which ports can exchange frames directly. A subnet is a layer 3 address range (article 8). Normally there's one subnet per VLAN, and they line up. The lab showed what happens when they don't: h2 had an address in h1's subnet, but in a different VLAN, so h1 couldn't reach it.
Do VLANs make a network secure?
They separate traffic, which is useful, but they're not a security boundary on their own. Misconfigured trunks, VLAN hopping and attacks on the switch itself can cross them. Real security between VLANs comes from the router or firewall that connects them, which decides what may pass.
Why does my capture on a trunk show no VLAN tags?
Many network cards remove the tag in hardware and pass the VLAN ID to the kernel separately (VLAN offload). The capture then shows untagged frames, even though they were tagged on the wire. Turn the offload off with ethtool -K <interface> rxvlan off, or capture on a switch's mirror port.
Is there still a use for vconfig?
No. It was the old Linux tool for VLAN interfaces and has been replaced by ip link add link eth0 name eth0.10 type vlan id 10. The eth0.10 naming style is just a convention: you can name the interface anything.
Can a bond of two 1 Gb/s links give my laptop a 2 Gb/s download?
Only across several connections. Each connection is pinned to one link by the hash, so a single download is still limited to 1 Gb/s. Downloads that open several connections, like many browsers and download tools do, can use both links if the hash happens to spread the connections.
Why does LACP exist if static bonding works?
Static bonding trusts the configuration. If a cable goes to the wrong switch, or a link is up but broken in one direction, a static bond keeps sending traffic into it. LACP checks continuously that both ends agree about each link, and removes any link where the LACPDUs stop arriving or don't match.
What happens when VLAN IDs run out?
There are only 4094. Providers use Q-in-Q to stack a second tag. Cloud and data center networks mostly use overlay tunnels such as VXLAN, which has a 24-bit segment ID (about 16 million networks) and runs over a routed IP network. Article 20 covers tunnels.
Summary
- VLANs (802.1Q) split one switched network into separate broadcast domains. Traffic between VLANs must go through a router.
- Ports are usually assigned to a VLAN by port. Access ports carry one VLAN untagged, and trunk ports carry several, tagged. Untagged frames on a trunk belong to its native VLAN (PVID).
- The 4-byte tag holds a TPID of
0x8100, a 3-bit priority, a drop-eligible bit and a 12-bit VLAN ID (4094 usable values). Tagged frames can be 1522 bytes, and the MTU stays 1500. - 802.1p priorities give eight classes, with 1 below 0, and switches map them to queues as configured. 802.1ad Q-in-Q adds an outer tag with TPID
0x88A8. - Link aggregation (802.1AX, LACP) bundles links for capacity and redundancy. LACPDUs to
01:80:c2:00:00:02confirm which links belong together. - Traffic is spread by hashing flow fields, so one flow uses one link and the split can be uneven. Linux offers several bonding modes, with
802.3adandactive-backupthe most common.
Practice questions
1. A frame on a trunk begins ff ff ff ff ff ff 02 00 00 00 10 01 81 00 a0 1e 08 06. What VLAN and priority does it have, and what does it carry?
Answer
81 00 is the 802.1Q TPID. The next two bytes are a0 1e, binary 1010 0000 0001 1110. The top 3 bits 101 are PCP 5, the next bit is DEI 0, and the low 12 bits 0000 0001 1110 are VLAN 30. The EtherType after the tag is 08 06, ARP. It's a broadcast ARP request in VLAN 30 with voice priority.
2. Two hosts are on access ports in VLANs 10 and 20 of the same switch, and both have addresses in 192.0.2.0/24. What happens when one pings the other, and how would you fix it properly?
Answer
The ping fails. The first host broadcasts an ARP request, but the switch delivers it only within VLAN 10, so the second host never receives it. The proper fix is to give each VLAN its own subnet and route between them through a router or layer 3 switch, or to put both hosts in the same VLAN if they're meant to be on one LAN.
3. Why is the PCP value 1 described as lower priority than 0?
Answer
Because most traffic is untagged or tagged with the default priority 0, which needs to mean "normal". To have a class below normal for background traffic such as backups, the standard assigned it the value 1. So the order from lowest to highest is 1, 0, 2, 3, 4, 5, 6, 7.
4. A server has a 4 × 25 Gb/s LACP bond. One backup job using a single TCP connection gets about 25 Gb/s. Is the bond broken?
Answer
No. The bond hashes each flow onto one member link so its packets stay in order, so a single TCP connection can't go faster than one member, 25 Gb/s. Running the backup over several parallel connections could use more of the bond, if the hash spreads them across the links.
5. A switch receives an untagged frame on a trunk port whose PVID is 99. Which VLAN does the frame join? What is that configuration called?
Answer
It joins VLAN 99. On a trunk, untagged frames are put in the port's PVID, often called the native VLAN. Using an otherwise unused VLAN as the native VLAN is a common defense against VLAN hopping.
6. How many bytes of tags does a Q-in-Q frame have, and what are the two TPIDs?
Answer
8 bytes: an outer S-tag with TPID 0x88A8 followed by an inner C-tag with TPID 0x8100, each 4 bytes. The frame can therefore be up to 1526 bytes with a 1500-byte payload.
Previous: Ethernet: Frames, MAC Addresses, EtherTypes and Today's Speeds
Next: Duplex, Autonegotiation, Wake-on-LAN, Energy Saving and Link Flow Control

More in TCP/IP Course
Quiz: TCP/IP Delicate Details
Twenty-five questions on the details that catch out experienced engineers: sequence numbers for SYN and FIN, TIME_WAIT versus tcp_fin_timeout, Karn's algorithm, socket buffer doubling, even and odd ephemeral ports, IPv6 checksums and fragmentation, negative DNS caching, and capture filter traps.
Quiz: TCP/IP Interview Questions
Thirty-three networking questions of the kind asked in developer, SRE and network engineering interviews: what happens when you load a URL, TCP versus UDP, handshakes, closing and TIME_WAIT, subnetting, NAT, DNS, MTU problems, congestion, TLS and QUIC, and debugging slow or failing connections.
Quiz: TCP/IP Course Final Exam (All Parts)
The final exam for the TCP/IP course: thirty questions across all fourteen parts, from packets and addressing through Ethernet, ARP, IP, DHCP, NAT, ICMP, UDP, DNS, TCP connections, reliability, congestion control, security, QUIC and troubleshooting.
Quiz: Modern Transports and Troubleshooting (TCP/IP Part 14)
Review modern transports and troubleshooting: QUIC packets, handshakes, 0-RTT, streams and connection migration, HTTP/3, Multipath TCP, SCTP multihoming, and a layered method for diagnosing real network faults.
Discussion
Sign in to ask a question or share what you learned.