PocketCLI Tutorial - VLANs and Trunking

May 28, 2019 - Reading time: 7 minutes


In the previous tutorial, we looked at how to create VLANs, assign ports to VLANs, and how to delete VLANs, all on one switch. In this tutorial, we shall look at how to configure VLANs on multiple switches, and how same VLANs on different switches can communicate; introducing a term known as Trunking.

In this tutorial, we shall create a lab in the Pocket CLI App to configure VLANs on two switches. Required devices for this lab are two Switches and four Hosts.

As in the screenshot above, connect Host0 to fa0/1 on switch1, Host2 to fa0/2 on Switch1, Host1 to fa0/1 on Switch2, and Host3 to fa0/2 on Switch2, all with a straight-through connection. Connect Switch1 and Switch2 via fa0/5 on both switches using a crossover connection.

1. Create VLAN 10 and VLAN 20 with IDs ACCT and MKT respectively on both switches.

On Switch1:

switch1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
switch1(config)#vlan 10
switch1(config-vlan)#name ACCT
switch1(config)#vlan 20
switch1(config-vlan)#name MKT

On Switch2 :

switch2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
switch2(config)#vlan 10
switch2(config-vlan)#name ACCT
switch2(config)#vlan 20
switch2(config-vlan)#name MKT


2. Assign IP address to Host0 and to Host1, putting them on the same network.


3. Assign IP address to Host2 and to Host3, putting both too on the same network.


4. On switch1, assign port fa0/1 to VLAN10 and fa0/2 toVLAN20.

switch1(config)#int fa0/1 
switch1(config-if)#switchport access vlan 10
switch1(config)#int fa0/2
switch1(config-if)#switchport access vlan 20


5. On switch2, assign port fa0/1 to VLAN10 and fa0/2 to VLAN20.

switch2(config)#int fa0/1
switch2(config-if)#switchport access vlan 10
switch2(config)#int fa0/2
switch2(config-if)#switchport access vlan 20


The above puts Host0 and Host1 on VLAN 10, and Host2 and Host3 on VLAN 20.


Now Host0 and Host1 are on the same VLAN but on different switches. For these two computers to be able to communicate, so as Host2 and Host3, we need to configure trunk ports. A trunk port is an interface that can carry multiple VLANs.

In this example, we configure int fa0/5 on both switches as trunk ports.

On Switch1:

switch1(config)#int fa0/5 
switch1(config-if)#switchport trunk encapsulation dot1q
switch1(config-if)#switchport mode trunk


On Switch2:

switch2(config)#int fa0/5 
switch2(config-if)#switchport trunk encapsulation dot1q
switch2(config-if)#switchport mode trunk


To view the trunk configuration on the switch, enter the command; show interface trunk as shown below:

switch1#show interface trunk
Port Mode Encapsulation Status Native vlan
Fa0/5 on 802.1q trunking 1

Port Vlans allowed on trunk
Fa0/5 1-1005

Port Vlans allowed and active in management domain
Fa0/5 1,10,20

Port Vlans in spanning tree forwarding state and not pruned
Fa0/5 1,10,20


With this Host0 on switch1 and Host1 on swicth2 will be able to communicate, as well as Host2 and Host3. For Communication across VLAN 10 and VLAN 20, a Router is required, a configuration known as Router on Stick. This will be covered in future tutorials.


Success Tips:

a. Create VLANs that you really need. Too many unnecessary VLANs can make management difficult or cumbersome.

b. Assign only ports that needs to be on a particular VLAN and leave all other ports shutdown.

c. It is best to configure VLANs other than the default VLAN 1 for ports involved in communication.

d. It is best to put voice traffic and data traffic on separate VLANs.



PocketCLI Tutorial - VLANs and Trunking | PocketCLI