Vlan Trunking
Why do we need VLAN trunking
By default without vlan trunking, when Switch B connect to Switch A via a port that was configured for VLAN 20. Switch B can only talk to VLAN 20
[!important]
You cannot connect cross VLAN between 2 switch since vlan is to isolate and separate the network. If you connect like that it simply won't have any communication.
So in this case, to cross-communicaiton between all vlans, we need many ethernet cable:
as a result you just loose half the ports on the switch.
VLAN Trunking
VLAN trunking will allow multiple VLANs to talk to its corresponding VLAN across switch via 1 port (trunk port)
Enable multiple vLANs to transmit over a single physical link between switches. Using VLAN Tagging to keep the vlan information intact.
The untagged vlan will be automatically fall back to the default tagging which is 1
Note that Port15
and Port0
here are Trunkport and cannot belong to any VLANs
Now that VLANs can communicate cross switch however will be limited by the cable speed. For example if a cable is 10 Mbps, now all the VLAN will share the same 10Mbps connection. If we don't use trunking then each VLAN has its own 10Mbps connection to use.
In the system, VLAN trunking works like this where packet go through the trunk needs to be tagged VLAN Tagging
However, the two switch must agree on a protocol for trunking to work, the two possible protocols are:
To determine which protocol your switch support, use show interface capabilities
When connect cisco with other devices, use 802.1Q. Otherwise consider to use ISL (Inter Switch Link) or 802.1Q depends on its features.
Switch can also determine which protocol to use automatically by using DTP (Dynamic Trunking Protocol)
Configuring VLAN Trunking on Cisco
To configure vlan trunking, we would first need to define a the trunk encapsulation
.
Note: even though if we're using 802.1Q which does not have trunk encapsulation, you will still need to specify. Since it's just how the command works.
int g1/0/45
switchport trunk encapsulation dot1q
switchport mode trunk
[!important]
Themode
here are from DTP (Dynamic Trunking Protocol)
[!note]
By default, all VLANs in switch will be included in a trunk. This might cause unnecessary bandwidth
To allow a port for VLAN, we can do
switchport trunk allowed vlan ?