1. Introduction to the trunk, 802.1Q and ISL encapsulation
The trunk is the mechanism that makes it possible to insert the VLAN identifier into a user frame. Any frame traveling across several devices will always keep the information about the VLAN it belongs to. And the destination device will know which ports the frame can be handled with (the ports belonging to the same VLAN).
If you want VLAN traffic between switches, you have to use a trunk. A trunk connection is simply a normal link, except that it is able to carry the traffic of different VLANs and has a method for separating the traffic between the VLANs. Here is an example:
As you can see, we have computers on both sides and they are in different VLANs. By using the trunk, we can make sure that all the VLAN traffic can be sent between the switches. Since our classic Ethernet frames have no field to show which VLAN they belong to, we will need another protocol. There are two very widely used trunking protocols:
- 802.1Q: this is the most common trunking protocol. It is a standard and is supported by many vendors.
- ISL: this is the Cisco trunking protocol. Not all switches support it.
2. Let's take a look at 802.1Q:
Here is an example of an 802.1Q Ethernet frame. As you can see, it is a normal Ethernet frame, but we have added a tag in the middle (that is the purple field). In our tag, you will find a “VLAN identifier”, which is the VLAN this Ethernet frame belongs to. This is how the switches know which VLAN our traffic belongs to. There is also a field called “Priority” that makes it possible to give a different priority to different types of traffic. This is useful when you have one VLAN for voice over IP traffic and another VLAN for data traffic: you probably want to give priority to the VoIP traffic, or the quality of your call could suffer. I hope this has been useful for understanding 802.1Q!
3. In commands
To change the mode of a port (interface) on a switch, you first have to select it with the interface command followed by the name; in our example this will be GigabitEthernet0/1.
Switch(config-if)#interface gig0/1
Switch(config-if)#switchport mode trunk
To allow a router to have several gateways (for several VLANs) on the same link as an 802.1Q trunk, you have to create subinterfaces and indicate the VLAN assigned to each interface. For example:
Router(config)#interface gig0/0.10
Router(config-subif)#encapsulation dot1Q 10
Router(config-subif)#ip address 192.168.10.1 255.255.255.0
Router(config)#interface gig0/0.20
Router(config-subif)#encapsulation dot1Q 20
Router(config-subif)#ip address 192.168.20.1 255.255.255.0
