Home > Switches > Layer 3 Switching > Layer 3 versus Layer 2 Switch for VLANs

Layer 3 versus Layer 2 Switch for VLANs

This article discusses the difference between layer 2 and layer 3 switches and the appropriate use cases for each.

如欲查看中文版本,请点击 这里

Overview

Traditional switching operates at layer 2 of the OSI model, where packets are sent to a specific switch port based on destination MAC addresses. Routing operates at layer 3, where packets are sent to a specific next-hop IP address, based on destination IP address. Devices in the same layer 2 segment do not need routing to reach local peers. What is needed however is the destination MAC address which can be resolved through the Address Resolution Protocol (ARP) as illustrated below:
6f0663e3-6a40-4436-951c-b2548b20073c
 

Here, PC A wants to send traffic to PC B at IP address 192.168.1.6.  It does not know the unique MAC address however, until it discovers it through an ARP, which is broadcasted throughout the layer 2 segment:
5f8578ad-9adc-41b0-8cc2-682380cadd12
 

It then sends the packet to the appropriate destination MAC address which the switch will then forward out the correct port based on its MAC-Address-Table.

 

Within a layer 2 switch environment exists a broadcast domain.  Any broadcast traffic on a switch will be forwarded out all ports with the exception of the port the broadcast packet arrived on.  Broadcasts are contained in the same layer 2 segment, as they do not traverse past a layer 3 boundary.

 

Large layer 2 broadcast domains can be susceptible to certain unintended problems, such as broadcast storms, which have the ability to cause network outages.  Also, it may be preferable to separate certain clients into different broadcast domains for security and policy reasons.  This is when it becomes useful to configure VLANs.  A layer 2 switch can assign VLANs to specific switch ports, which in turn are in different layer 3 subnets, and therefore in different broadcast domains.  VLANs allow for greater flexibility by allowing different layer 3 networks to be sharing the same layer 2 infrastructure.  The image below shows an example of a multi-VLAN environment on a layer 2 switch:

e43cd080-6efa-4181-83fc-2a70308c9e74

 

Since VLANs exist in their own layer 3 subnet, routing will need to occur for traffic to flow in between VLANs.  This is where a layer 3 switch can be utilized.  A Layer 3 switch is basically a switch that can perform routing functions in addition to switching.  A client computer requires a default gateway for layer 3 connectivity to remote subnets.  When the computer sends traffic to another subnet, the destination MAC address in the packet will be that of the default gateway, which will then accept the packet at layer 2, and proceed to route the traffic to the appropriate destination based on its routing table.

 

The diagram below shows an example of a layer 3 switching routing between VLANs through its two VLAN interfaces. As before, the layer 3 device will still need to resolve the MAC address of PC B through an ARP request broadcasted out to VLAN 20.  It then rewrites the appropriate destination MAC address and forwards the packet back out the layer 2 segment:
4478bd7d-57ee-485b-aee4-d7d41dce1807

Additional Resources

Layer 3 switch overview - An overview of how to configure layer 3 routing on Cisco Meraki switches

Layer 3 switch example - A configuration example using layer 3 routing on Cisco Meraki switches

Best practices for 802.1q VLAN tagging - Information regarding the appropriate use of VLAN tags

You must to post a comment.
Last modified
16:04, 19 Jul 2017

Tags

Classifications

This page has no classifications.

Article ID

ID: 1147

Contact Support

Most questions can be answered by reviewing our documentation, but if you need more help, Cisco Meraki Support is ready to work with you.

Open a Case

Ask the Community

In the Meraki Community, you can find answers provided by fellow Meraki users and ask questions of your own.

Visit the Community