What is a Trunk Link and How to Configure it on a Switch

Knowledge about trunks adds a lot of value in ensuring good performance of our local networks. The purpose of trunks is essential, since their main mission is to facilitate inter-communication between the different VLANs, that is, virtual local area networks, but also to share these VLANs with other manageable switches that we have connected to the network. net. This guide will help you better understand what trunking is, how it works, and at the same time apply the knowledge through configuration on devices from popular manufacturers like Cisco and D-Link.

What is a trunk link or trunk?

It is a link that is configured in one or more ports of a switch to allow the traffic of the different VLANs that we have configured to pass through. This link can work in a switch connection to another switch or, from a switch to a router, and even from a switch to a server that supports the 802.1Q standard to “pass” multiple VLANs simultaneously. In either case, there is no doubt about its efficiency, since it saves the need to use a physical link for each VLAN.

Trunk Link: How to Configure it on a Switch

The essential protocol that gives life to the trunk link is the one that belongs to the IEEE 802.1Q standard. This allows Ethernet frames to travel through the network with a “tag” containing the VLAN identifier (this frame is called a tagged frame).

The process of adding the VLAN ID is called frame tagging . Remember that when we are talking about frames, we do it at the layer 2 level, that is, at the data link level. The information found within the frame is modified so that the switches involved can identify both the source and destination VLANs. This allows traffic to flow properly between them.

The process of removing the VLAN ID is called frame untagging or untagging the frame. This is done when the switch has an “access” type link, that is, it removes the tag from the frame to provide the original frame to the PC, server or end device that does not “understand” tagged VLANs.

Trunk configuration on Cisco switches

We opted for this brand because it is one of the most used when we are learning about networks, since the typical Cisco CCNA certification is widely known by any network administrator. In addition, we must bear in mind that Cisco has a tool such as Cisco Packet Tracer to perform configuration tests with a simulator.

The image we share above simulates a small network consisting of two computers, each of which is connected to a switch. In turn, these switches are connected to each other. This scenario consists of the application of a trunk link that allows two computers in the same VLAN to communicate. The latter, even if they are connected to different switches.

Now we see the same example network, but with the details of the ports used. Generally, for trunking configuration, the last port on each switch is used. However, you can choose the port you want, and always keep in mind which ports you have chosen, to correctly configure each of them.

The first step is to configure the VLAN on each switch with the same identifier number and name.

On the first switch:

SW1(config)#vlan 10
SW1(config-vlan)#name ejemplo
SW1(config-vlan)#exit

On the second switch:

SW2(config)#vlan 10
SW1(config-vlan)#name ejemplo
SW1(config-vlan)#exit

To verify the creation of your VLAN you can use the following command:

show vlan

Or you can opt for the abbreviated command:

sh vlan

Expect to see the following on the CLI of each switch:

10 ejemplos active Fa0/1
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active

In the first line we can see our VLAN number 10 with an example name. It also tells us that it is active and is assigned to the Fast Ethernet 0/1 interface. But how do we assign it?

This step must be repeated on the port of each switch that is connected to the computers:

SW1(config)#interface fa0/1
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 10
SW2(config)#interface fa0/1
SW2(config-if)#switchport mode access
SW2(config-if)#switchport access vlan 10

Now, you need to configure the trunk link on each of the switches. You must configure each of the interfaces that are being used for the connection between them:

SW1(config)#interface fa0/24
SW1(config-if)#switchport mode trunk
SW2(config)#interface fa0/24
SW2(config-if)#switchport mode trunk

Important. You may get the following error message when trying to assign interfaces as trunks:

Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode.

It depends on the brand and model you use, whether or not that message will appear. But, you shouldn’t worry. This message tells us that the trunk encapsulation of the interface is not established with the IEEE 802.1Q standard that we mentioned above. Consequently, we must correct it with the following command:

SW1(config-if)#switchport trunk encapsulation dot1q

So, the commands to establish the trunks will be the following:

SW1(config)#interface fa0/24
SW1(config-if)#switchport trunk encapsulation dot1q
SW1(config-if)#switchport mode trunk
SW2(config)#interface fa0/24
SW2(config-if)#switchport trunk encapsulation dot1q
SW2(config-if)#switchport mode trunk

Another very important aspect is that the “switchport mode trunk” command allows you to trunk each and every one of the VLANs, but all switches allow adding or removing the VLAN IDs of this trunk link. Why are we going to pass a VLAN if we are not really going to use it on the other switch? In these cases, we could use the following command: “switchport trunk allowed vlan 10” to allow this VLAN only, since it is much more elegant than not passing all VLANs.

Finally, we only have to assign the IP addresses to each computer and you only need to ping to verify that both computers can communicate correctly. That is, according to the example shown from the computer with IP 192.168.10.1 you must ping the computer with IP 192.168.10.2. If the ping is OK, everything is fine.

Configuring a trunk link on D-Link switches

Not everything is going to be Cisco in the world of networks, D-Link is one of the best manufacturers and has the most manageable switches in their portfolio. D-Link allows us to configure trunk links directly from a very intuitive graphical user interface, below, you can see how easy it is to configure a trunk link on a switch from this manufacturer.

In a D-Link DGS-1210-10MP switch, we can go directly to the VLAN / 802.1Q VLAN menu, and choose that the ports are untagged, tagged or not member. in this case, if we want ports 1, 2, 3, 4, 9 and 10 to be in trunk, it is enough to select them all in «tagged» mode. In this way, we will be passing a trunk of VLANs.

The D-Link DXS-1210-10TS switch allows us greater configurability, in this case, we can configure it in “L2 Features / VLAN Interface”. Here we can put it in “Link” VLAN mode, check the incoming frames if we want them to be always tagged, not tagged or both, and we can even define a native VLAN. If we want to configure only the VLANs that pass through the trunk, we will have to select “Hybrid VLAN mode” and add them manually.

As you have seen, configuring a trunk link is quite simple, although we must follow a series of recommendations when doing it, and pay close attention to the ports where we are configuring it.