Sunday, December 22, 2013

Working with VLANs



Let’s add one more switch (switch1) and two PCs (PC0 in VLAN1 and PC5 in VLAN2) to our previous topology. Here is the topology pic and the configuration on the switch is done accordingly.
Just for the confirmation. Let’s check the VLAN information on Switch1:


(If you want to know how to move the ports into a particular VLAN, see my previous post:)
A small note, here i used IP addressing in such a way that you can come know to which VLAN a device belongs to, just by seeing the IP address. For example, 10.0.1.1 is VLAN1 device (The third octet number indicates VLAN number, one more eg: 10.0.2.1 indicate VLAN2 device).



Now let’s see the communication between the devices in the same VLAN  on the switch0:

Testing communication between devices in same VLAN on switch0:

Between devices in VLAN1:

Let’s check communication between PC1 (10.0.1.1) and PC2 (10.0.1.2).

Pinging PC1 (10.0.1.1) from PC2 (10.0.1.2).

 
So the communication is fine from PC2 (10.0.1.2) to PC1 (10.0.1.1). Obviously the communication from PC1 to PC2 will also be fine.
However, Lets check:

Pinging PC2 (10.0.1.2) from PC1 (10.0.1.1).



Even this is also fine.

Between devices in VLAN2:

Let’s ping both PC3 and PC4 each other.

Pinging PC4 (10.0.2.2) from PC3 (10.0.2.1).



So the communication is fine from PC3 to PC4. Obviously the communication from PC1 to PC2 will also be fine.


However, Lets check:

Pinging PC3 (10.0.2.1) from PC4 (10.0.2.2).
 


So the devices in the same VLAN and on single switch (switch0) are able to communicate each other.

Now let’s see the communication between the devices in the same VLAN but on the different switches (switch0 & switch1):


As per our topology, PC0 (10.0.1.3) is in VLAN1 and PC5 (10.0.2.3) is in VLAN2, and both are on switch1.

Now let’s check if PC0 (10.0.1.3) on switch1 and PC2 (10.0.1.2) on switch0 in VLAN1 are able to communicate. And also check whether if PC5 (10.0.2.3) on switch1 and PC3 (10.0.2.1) on switch0  in VLAN2 are able to communicate each other.

Pinging PC2 (10.0.1.2) on switch0 from PC0 (10.0.1.3) on switch1:



So they are able to communicate, by this we are clear that VLAN1 devices on different switches (switch0 & siwtch1) are able to speak each other.

Let’s check whether VLAN2 devices are able to communicate each other:

Pinging PC3 (10.0.2.1) on switch0 from PC5 (10.0.2.3) on switch1:
 


So the devices in VLAN2 on different switches (switch0 & switch1) are unable to communicate.

Why?

If you’ve remembered, by default  all the ports of a switch will be in VLAN1.

Let’s see the VLAN configuration on both the switches:
VLAN configuration on switch0:





VLAN configuration on switch1:



If you take a look at the topology both the switches are connected through their Fa0/1 ports which are in default VLAN (VLAN1).

                Since the ports are in VLAN1 the link between switch0 and switch1 is allowing only VLAN1 traffic. That is the reason for the communication between VLAN1 devices, if the port between both switches is configured to be in VLAN2 then only VLAN2 devices will be able to communicate.

Let’s move the Fa0/1 port on both of the switches to VLAN2.

Moving Fa0/1 into VLAN2 on switch1:

Switch1(config)#interface fastEthernet 0/1
Switch1(config-if)#switchport access vlan 2


Moving Fa0/1 into VLAN2 on switch0:

switch0(config)#interface fastEthernet 0/1
switch0(config-if)#switchport access vlan 2



Now let’s ping again PC3 (10.0.2.1) on switch0 from PC5 (10.0.2.3) on switch1:


Now they’re able ping because we’ve configured the ports Fa0/1 on both switches  to be in VLAN2.
                But now the devices in VLAN1 from one switch to another switch cannot ping each other, let check it too.

Pinging PC2 (10.0.1.2) on switch0 from PC0 (10.0.1.3) on switch1:
 

They’re unable to reach each other because the link between both the switches is supporting only VLAN2. So here the link is supporting only one VLAN at a time.

 So how to enable communication between devices in same VLAN on different switches (here switch0 and switch1) ?

                We need to create one more link between switches and move the ports corresponding to that link into the required VLAN as shown below.
               
 Here is just moved the port Fa0/24 on Switch1 into VLAN2, and about switch0 already the port Fa0/24 is in VLAN2 as we configured earlier.


However let ‘s check the VLAN configuration on both switches:


VLAN configuration on Switch0:


VLAN configuration on Switch1:
   
           You can confirm from the above screens that Fa0/24 on both switches is configured to be under VLAN2. Now lets check whether VLAN1 devices on boths switches are able to communicate and also VLAN2 devices.

Checking communication between VLAN1 devices:

Pinging PC2 (10.0.1.2) on switch0 from PC0 (10.0.1.3) on switch1:


So VLAN1 devices are able to communicate each other.

Checking communication between VLAN2 devices:

Pinging PC3 (10.0.2.1) on switch0 from PC5 (10.0.2.3) on switch1:

 

So VLAN1 devices are also able to communicate each other.

But the problem here is we are using one port on each switch for one vlan, that means as there are two VLANs we’re using 2 ports on each switch that is nothing but 4 ports totally.
               
    Like this if we have 10 VLANs then (10x2)= 20 ports are needed totally. So as the VLANs increases we need more ports which is increasing the expenditure and also more number of ports are used here.

People has found a solution for this problem, that is nothing but Trunk Ports.
Trunk ports allow all (Multiple) VLANs traffic to pass over them. So in our example if we configure any port for example Fa0/1 on both the switches as a Trunk port, then at a time the devices in both VLANs can communicate i.e, devices  in VLAN1 on both switches can communicate each other AND devices in VLAN2 on both switches can communicate each other.
    
            So there is no need for another port (Fa0/24) for VLAN2. Similarly if there are 10 Vlans, we can use only one port as a trunk port and the devices can communicate.

The main advantage of trunk ports is they reduced the requirement of the number of physical ports on switches and also router for multiple VLAN communication.

How to configure trunk ports?
How the trunk ports work?
What is trunking?
What are the different types of trunking methods? How they work?

And more about trunking will be discussed in the next post.


No comments:

Post a Comment