I have seen people using terms “Switch” and “Router” interchangeably. But please note that they are completely different.
Switch is used to create a network whereas Router is used to link different networks. They might look similar in appearance but they are different.
I will not explain the difference in terms of layers because that gets confusing and you have to have a good understanding of network layers for that. But to simplify things:
- Switch takes the decision of which interface to send the packet based on MAC address whereas Router takes the decision based on IP Address.
- A router can send two packets with same destination IP on different interfaces but a switch cannot send two packets with same destination MAC on different interfaces. One MAC will bind to one interface.
- If you care to know then Switch operates at Data Link Layer and Router operates at
Practical scenarios to understand it better:
- Imagine if you and your friends want to play Counter Strike but there’s no common LAN and none of you have wifi but all of you have Ethernet. Then to play the game a switch will be useful for you. You will have to do a bit of configuration but it will work out.
Image Source: http://www.gridgit.com/
Your network will now look somewhat similar to this. (Ignore the printers and scanners).
- Now imagine, 5 of your friends are sitting together. A free wifi connection is available but only one of you has wifi on their machine, rest have ethernet only. But you guys are carrying a switch, how can you all access Internet? Lets say friend X has wifi and ethernet both on their laptop. Now everyone including X will connect their lan port with switch using a lan cable. Now everyone will configure X’s IP as the gateway IP and then X’s laptop will act as a Router. So you used a Switch to create a network and you used a Router to connect this newly created network with another network. Image Source: http://www.gridgit.com/
You have made something like this where one of your friend’s computer act as a “Router”.
I hope this explains the difference between a switch and a router clearly.