TCP/IP Computer Networks include different types of networking devices which operate in unison to support the communication needs of the enterprise. Two of the most fundamental building blocks of networks are network switches and network routers.
Some other devices found in enterprise networks include also network firewalls, Web Application Firewalls (WAF), proxy servers, load balancers, IPS/IDS security systems, authentication servers, network management and monitoring systems etc.
However, network switches and routers are the basic elements on which everything else is built upon.
When beginner network engineers start reading about the OSI model of networking, learn that a network switch belongs to Layer 2 of OSI whereas a network router belongs to Layer 3 of the OSI model. However, this is not always the case.
In this article we’ll discuss Layer 3 switches (which have some overlapping functionality with Layer 3 routers) and describe the similarities and differences between Layer 3 switches vs Routers.
Before moving forward, let’s first see a network diagram which depicts a popular topology found in enterprise networks. The diagram will help in our discussion when comparing L3 switches and Routers.
Table Of Contents
What is a Network Switch (Layer 2 and Layer 3)
The majority of network switches operate at the Layer 2 of OSI model. This means that their purpose is to forward ethernet frames from one port of the switch to another port.
They make use of Layer 2 MAC addresses in order to forward frames to the correct destination port but they don’t know anything about Layer 3 IP addresses of the packets passing through them.
On the other hand, a Layer 3 switch is a combo device which operates at both Layer 2 and Layer 3 of the OSI model.
That is, the Layer 3 switch forwards ethernet frames between ports but can also make routing decisions based on a routing table and Layer 3 IP addresses.
Let’s see an example:
Assume we have a Layer 2 switch which has 3 different VLANs configured on it. If a host on VLAN 2 wants to communicate with a host on VLAN 3 (belonging to a different Layer 3 subnet) the L2 switch is not able to route the traffic between VLANs.
Now, assume we have a Layer3 switch with 3 different VLANs. Now, this type of switch is able to provide also routing between its VLANs since it has knowledge of the Layer 3 subnets and IP addresses and can route packets between these segments.
As shown on the diagram above, a Layer 3 switch can connect hosts directly to it and also have other Layer 2 switches connected in order to provide routing between VLANs (inter-vlan routing).
What is a Network Router
As shown on the diagram above, Network Switches mostly exist on the internal LAN network in order to provide ethernet connectivity to internal hosts and VLANs.
On the other hand, a Network Router is usually connected to the border perimeter of the network for providing a boundary between the internal LAN and the external WAN world (e.g the Internet or another WAN network).
In other words, the router provides connectivity between one or more LAN networks with one or more WAN networks.
For example, a small home router provides connectivity between your internal LAN network and a WAN network. The WAN interface of the router can be ADSL, Fiber optic, Cable etc.
Similarly, in a bigger enterprise network (as shown on the diagram above), a router usually sits on the boundary between the internal LANs and the Internet or other WAN network such as MPLS etc.
Unlike a L3 switch, a router operates purely on the Layer 3 OSI level and routes packets based on their destination IP address. This operation is based on the routing table of the device which tells the router about the best possible path and to which outgoing interface to send each packet.
Layer 3 Switch Vs Router
Now that we have a general idea of each device, let’s examine and compare some of the similarities and differences between the two.
Both devices have a routing table in order to decide how each IP packet will be forwarded through the device.
They both look at the destination IP address included in each packet header and then look into their routing table which provides information pertaining to where each destination network can be reached.
In order to built their routing table, both a L3 switch and a Router support dynamic routing protocols such as OSPF, RIP etc, or statically configured routes.
Moreover, both devices can enforce traffic control to packets (usually with Access Control Lists) in order to allow or block traffic between networks. These Access Control Lists can usually work up to TCP layer 4 whereby they can also control traffic at the port level as well (e.g allow traffic to IP 220.127.116.11 at port 443).
The main difference between a L3 switch and router is that a Router device supports different types of WAN interfaces, whereas a switch consists of multiple Ethernet ports (such as RJ45 electrical ports or multi-Gigabit Fiber optic ports).
The router on the other hand can support various WAN interfaces such as Fiber optic, ADSL, Cable, ATM, Frame Relay, Electrical Ethernet etc.
Moreover, the forwarding performance of a switch is much higher than a router because the switch uses hardware ASIC chips to perform the packet forwarding whereas a router usually uses software routing (except some high-end routers).
The router on the other hand supports more advanced networking features such as QoS (quality of service for traffic), Tunnel termination (e.g GRE or IPSEC for VPNs), Network Address Translation (NAT), advanced routing protocols such as BGP etc.
Use cases for Layer 3 Switches
Layer 3 switches are mostly used in campus LAN networks, in Data centers and in large internal corporate networks to provide routing between VLANs.
Because of their large port density, they can accommodate multiple internal hosts and work at very high speeds such as Gigabit, 10 Gigabit etc.
If you want to segment a large internal LAN into multiple VLANs and provide routing between them, the L3 switch is ideal for such scenario.
Use cases for Routers
The main use case of a router is for WAN connectivity as discussed above. Especially if you want to provide WAN redundancy or Internet access redundancy, a router is ideal for connecting to multiple WAN networks and for routing failover and load-balancing using BGP for example.
Let’s see a side by side comparison between the two devices.
|Layer 3 Switch||Router|
|Works both at Layer 2 and Layer 3 of OSI model||Works only at Layer 3 of OSI model|
|Supports only Ethernet Interfaces (electrical, optical)||Supports different types of interfaces such as Ethernet, ADSL, Cable, Fiber, ATM, E1 etc|
|Higher forwarding throughput||Lower forwarding throughput|
|Supports basic routing functionality||Supports advanced routing functionality with more protocols such as BGP, ISIS, MPLS support, VRF etc.|
|No advanced networking features||Supports advanced networking features such as QoS, VPN, Tunnelling (GRE,IPSEC), NAT, VRF etc|
|Lower Cost||Higher Cost|
|Used mostly within internal networks, Data Centers, Campus LANs etc||Used mostly as border device between LAN/WAN, in ISP environments etc.|
|High Port Density||Lower Port Density|
|Smaller routing table||Large routing table|
- 10 Best Computer Networking Jobs with High Salaries in USA
- Collision Domains and Broadcast Domains Explained (with Diagrams and Examples)
- 10 Best Network Troubleshooting Software Tools (Free&Paid)
- DNS Port Number – What is Domain Name System – How DNS Works
- How to Configure Static Routing on Cisco IOS Routers (Examples)