Online admissions open for the SEO, Web Development and Networking & Security courses. Enquire for the next batch.

Routing and Switching Explained for Beginners

4 min read Updated By the SkillNewton team

What is the difference between routing and switching?

Switching moves frames between devices on the same local network using MAC addresses, while routing moves packets between different networks using IP addresses. A switch builds a MAC address table to decide which port to use; a router consults a routing table to choose the next hop. Together they carry traffic from a laptop on one floor to a server across the world.

How a switch forwards frames

A switch learns by watching traffic. When a frame arrives, it records the source MAC address against the incoming port in its MAC address table. It then looks up the destination MAC address. If the address is known, the switch sends the frame out of that one port; if not, it floods the frame out of every port in the same VLAN except the one it came in on.

Switch# show mac address-table
VLAN    Mac Address       Type      Ports
10      0050.56a1.1b2c    DYNAMIC   Gi0/3
10      0050.56a1.4d5e    DYNAMIC   Gi0/7
20      0050.56a1.9f00    DYNAMIC   Gi0/12

In this output, a frame in VLAN 10 destined for 0050.56a1.4d5e leaves through port Gi0/7 only. Entries age out after a period of inactivity, so the table stays current as devices move.

VLANs, trunks and Spanning Tree

A VLAN splits one physical switch into separate broadcast domains. A college might put staff in VLAN 10, students in VLAN 20 and CCTV cameras in VLAN 30, so that traffic and broadcasts stay apart and security rules can differ per group.

  • Access ports belong to one VLAN and connect end devices such as PCs and printers.
  • Trunk ports carry several VLANs between switches, adding an 802.1Q tag to each frame to mark its VLAN.
  • Spanning Tree Protocol (STP), usually Rapid PVST+ or RSTP today, blocks redundant paths so that frames cannot loop endlessly, and reopens them if the active link fails.

How a router decides where to send a packet

A router reads the destination IP address of each packet and compares it with its routing table. When several entries match, the router chooses the most specific one, the longest prefix match. If nothing matches and there is no default route, the packet is dropped.

Here is the routing table of a small Linux host, shown with ip route:

default via 192.168.1.1 dev eth0 proto dhcp metric 100
10.10.0.0/16 via 192.168.1.254 dev eth0
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.20
  • A packet for 192.168.1.50 matches the directly connected /24, so the host delivers it on the local link using ARP.
  • A packet for 10.10.5.7 matches 10.10.0.0/16, so it goes to the next hop 192.168.1.254.
  • A packet for any other address, such as a public DNS server, falls through to the default route via 192.168.1.1.

Reading a router routing table

On a Cisco router, show ip route adds a code letter showing where each route came from:

Gateway of last resort is 203.0.113.1 to network 0.0.0.0
S*   0.0.0.0/0 [1/0] via 203.0.113.1
C    192.168.10.0/26 is directly connected, GigabitEthernet0/0
L    192.168.10.1/32 is directly connected, GigabitEthernet0/0
O    10.20.0.0/16 [110/20] via 192.168.10.2, 00:12:44, GigabitEthernet0/0
CodeMeaningWhat to notice
S*Static default routeUsed for every destination not listed elsewhere
CConnected networkThe subnet configured on the interface itself
LLocal addressThe address of the router interface itself, as a /32 host route
OLearned through OSPFIn brackets, administrative distance first, then metric

In [110/20], 110 is the administrative distance, which ranks how trusted a route source is, and 20 is the OSPF cost. When two sources offer the same prefix, the lower administrative distance wins; when one protocol offers two paths, the lower metric wins.

Static and dynamic routing

ApproachHow it worksWhere it fits
Static routesAn administrator types each route by handSmall networks, default routes, stub sites
OSPFLink-state protocol that calculates shortest paths using costEnterprise networks within one organisation
EIGRPAdvanced distance-vector protocol from CiscoNetworks built mainly on Cisco equipment
BGPPath-vector protocol that exchanges routes between autonomous systemsInternet service providers, large enterprises and cloud connections

Dynamic protocols adapt when links fail, but they need careful configuration and authentication so that a misconfigured or rogue device cannot inject bad routes.

Inter-VLAN routing

Devices in different VLANs are in different subnets, so they need a router to talk. Two common designs are router-on-a-stick, where one router interface carries several VLANs over a trunk using subinterfaces, and a Layer 3 switch, which routes between VLANs internally using switched virtual interfaces (SVIs). Larger networks prefer the Layer 3 switch because it routes at hardware speed.

Building these topologies in Cisco Packet Tracer is the quickest way to learn them. They also map onto the OSI layers: switching at Layer 2, routing at Layer 3. When you are ready for structured, project-based practice, consider an online course in networking and security from SkillNewton.

Common mistakes

  • Forgetting to allow a VLAN on the trunk, so devices in that VLAN cannot reach other switches.
  • Expecting devices in different VLANs to communicate without any routing configured.
  • Adding a static route with the wrong next hop, which sends traffic into a black hole.
  • Disabling Spanning Tree to fix a slow link and creating a broadcast storm instead.
  • Ignoring longest prefix match and assuming the first route listed is the one used.

Frequently asked questions

Is a home Wi-Fi router a router or a switch?

Usually both. A typical home unit combines a router, a small switch, a Wi-Fi access point, a DHCP server and NAT in one box.

Do I need real Cisco hardware to learn?

No. Packet Tracer and other simulators cover most beginner and intermediate topics. Real or virtual devices help later for advanced features.

Which routing protocol should I learn first?

Start with static routes and OSPF, because they teach the core ideas of next hops, metrics and convergence. Study BGP once those are comfortable.

How does routing relate to security?

Segmentation with VLANs and access control lists on routers limits how far an incident can spread, a principle covered in our guide to securing networks.

Want to Learn This Properly?

The Online Networking & Security Course turns guides like this into practised skills, with projects on real websites.

WhatsApp Call Us Now