Networking FAQ: VLAN
Wikipedia
VLANs:
are independent logical LANs within the same physical network. They help in reducing the broadcast domain and aids in network administration by separating logical segments of a LAN (like company departments) that should not exchange data using a LAN (they still can exchange data by routing).
VLANs use medium to high range switches that enable software partitioning of the available ports, based on certain criteria. This set of ports is called a Virtual LAN or is abbreviated to VLAN. As you can imagine, the switch fabric could forward the Ethernet frames to the ports belonging to the same VLAN, while it would prevent any communication among distinct Virtual LANs.
VLAN Trunks:
When a single switch is not sufficient for a company, but the LAN extends over a set of them, the need arises to create Virtual LANs on each and enable communication between them. The first solution could be to use a port dedicated to the uplink for each VLAN. This would however lead to waste in terms of ports and cables; if the Virtual LANs common to two switches are n you must use n uplink cables.
A better solution is to create a trunk or trunking: in other words, both switches are attributed a common port (trunk port) to all the VLANs that need to be transported. Such trunks must run between these "tagged ports" of VLAN-aware devices, so they are often switch-to-switch or switch-to-router links rather than links to hosts.The switches tag each packet outbound of the trunk with a VLAN ID and each packet entering via trunking is forwarded on the right VLAN based on the VLAN ID. It is obvious that the two switches must use the same trunking protocol to communicate correctly via the trunk. There are different types of these protocols, which are often proprietary, and this could lead to inter-operational problems among different brands of switch that use the Virtual LANs. Yet, the most used trunking protocol is IEEE 802.1Q. The latter, for each Ethernet frame exiting the trunk configured port, adds 4 bytes and only 12 bits of which are used to identify the VLAN. The VLAN ID is therefore between 1 and 4094, considering 0 and 4095 are reserved values.