Introduction
While studying for CompTIA Network+, I couldn't totally grasp the difference between routers and switches. Even when I memorized their functions, the knowledge never stuck. However, once I knew the reason why they are needed, everything clicked. So, I decided to write it down.
Understand the difference between routers and switches
Comparing these two devices side by side makes it much easier to understand.
Switch:
→ Transfer data inside the same network
→ Use MAC address
→ Layer 2(Data Link Layer)
Router:
→ Transfer data in different networks
→ Use IP Address
→ Layer 3(Network Layer)
Familiar example
Switch = extension call in the office
→ Connect with people from the same company
Router = international telephone exchange
→ Connects people from different countries (networks)
→ Determines which route to use
Division of roles of routers and switches
Internet
│
┌────────────┴──────────┐
│ Router │ ← Layer 3
│ Different NW Transfer │ Judge from IP address
└────────────┬──────────┘
│
┌────────────┴─────────────┐
│ Switch │ ← Layer 2
│ The same NW Transfer │ Judging from MAC address
└───────┬──────────┬────────┘
│ │
┌──┴──┐ ┌──┴──┐
│PC-A │ │PC-B │
└─────┘ └─────┘
The main role of routers
1. Routing ( Route Selection )
It decides routes that head to the destination.
Tokyo → Osaka:
Route A: Tokyo → Nagoya → Osaka
Route B: Tokyo → Kyoto → Osaka
↓
Choose the best path for data transfer
2. Network segmentation・ border
The router acts as the boundary between the Internet and the internal network.
Internet
│
│ Global IP
│ 203.0.113.1
┌──────┴──────┐
│ Router │
└──────┬──────┘
│ Private IP
│ 192.168.1.1
┌──────┴──────┐
│ Switch │
└──┬───────┬──┘
│ │
┌──┴──┐ ┌──┴──┐
│PC-A │ │PC-B │
│~.1.2│ │~.1.3│
└─────┘ └─────┘
3. NAT ( Network Address Translation)
NAT is a mechanism that allows multiple devices to share a single global IP address.
【NAT( Sharing one IP address by multiple PCs)】
Internal Network (Office) Internet
┌───────────────────┐ ┌───────────────┐
│ PC-A 192.168.1.2 │ │ │
│ PC-B 192.168.1.3 ├── Router ──┤ 203.0.113.1 │
│ PC-C 192.168.1.4 │ │ (Just one) │
└───────────────────┘ └───────────────┘
Multiplex private IPs 1 Global IP
4. Data flow
【PC-A → Data flow to the Internet】
PC-A(192.168.1.2)
↓ " I need to send this to the Internet"
Switch
↓ head to Router
Router
↓ exchange to global IP(NAT)
↓ select the best path
Internet
↓
Destination server
5. Packet filtering
A basic security feature that blocks unauthorized access
from outside the network.
Routing Table
Routers have maps called routing table.
They look at it and select the path for destinations.
Destination network | Next router | Distance
192.168.1.0/24 | Direct connection | 0
10.0.0.0/8 | 192.168.2.1 | 1
0.0.0.0/0 | 203.0.113.1 | Default
Static routing and Dynamic routing
Static routing
It is a method to configure the routing tables by hand.
Administrator
↓ Configure the route by hand
Router A ──→ Router B ──→ Router C
↓
Destination NW
Static route → If you need change, you have to update it by hand as well
Features:
・For small scale network
・Best suited for environments where routes rarely change
・Simple settings
・Gives administrators full control over routing decisions
Dynamic routing
It is a method to configure the routing tables automatically.
Router A ←→ Router B ←→ Router C
↕ ↕ ↕
Exchange routing information each other
Choose the best path automatically
Handle automatically, if routes change
Features:
・For large scale network
・Best suited for environments where routes change frequently
・Handle automatically, if routes change
・Protocols: RIP・OSPF・BGP etc…
Proper use
Static Routing → Small scale and the least update environment
Dynamic Routing → Large scale and frequent update environment
Links with OSI reference model
Layer 7 Application │
Layer 6 Presentation │
Layer 5 Session │ Not applicable for routers
Layer 4 Transport │
─────────────────────────────
Layer 3 Network ← Router function (IP Address)
─────────────────────────────
Layer 2 Data Link ← Switch function (MAC Address)
Layer 1 Physical ← Cable・ Physical signal
─────────────────────────────
Familiar example for routers
A home Wi-Fi router is actually an all-in-one device that combines a router, a switch, and a Wi-Fi access point.
Domestic Wi-Fi Router
┌─────────────────────────────────────────────────────────────────┐
│ Router function→ Connect between domestic network and Internet │
│ Switch function→ Connect PC with wired connection │
│ Wi-Fi AP function→ Connect devices with wireless connection │
└─────────────────────────────────────────────────────────────────┘
↕
Internet
Summary
Router = Devices that transfer data between different networks
Main role:
→ Routing( Selection for the best route)
→ Border for network
→ NAT( Sharing one IP by multiple PCs)
→ Packet filtering
The difference of Router and Switch:
Router → Layer 3・IP address・ Between different NWs
Switch → Layer 2・MAC address・ Between same NWs
Routing kinds:
Static → manual・ for small scale
Dynamic → automatic・ for large scale
OSI Layer: Layer 3(Network Layer)
Conclusion
When I started to study for them, I couldn't remember each functions of these devices.
Once I connected each function to a familiar real-world example, everything fell into place. Understanding the difference between routers and switches makes these types of questions much easier to handle.
Top comments (0)