ITNuvoAkademiya
Academy homePackagesPlaylistsToolsSubnet calculatorSearchGlossary
CiscoCCNA · CCNA: networking fundamentals1. Introduction2. Network Fundamentals3. Network Access4. IP Connectivity5. IP Services6. IPv67. Security Fundamentals8. AutomationCCNP: Enterprise networks · coming soon
LinuxLinux: system administrator üçün · Linux for system administrators1. Getting to know Linux2. Working with text3. Users and permissions4. Processes and packages5. Inside the system6. Monitoring and logs7. NetworkingRed Hat Enterprise Linux · Red Hat Enterprise Linux: from beginner to advanced1. Getting started2. Packages3. Users and permissions4. SELinux5. Services6. Storage7. Networking8. Building services9. Boot and recovery10. DevOps11. Security and monitoring
FortinetFortiGate Administrator · FortiGate Administrator: from first login to ZTNA1. Getting to know FortiGate2. Routing, policy and NAT3. Security profiles4. Users and logs5. Resilience, SD-WAN and automation6. VDOM7. VPN and ZTNA8. Proxy9. DMZ
MonitoringZabbix · Zabbix: from installation to alerts1. Introduction2. Installation and the database3. Basics: groups, templates, users4. Connecting devices5. Alerts, Grafana and the API
VirtualizationProxmox VE · coming soonVMware ESXi · coming soon
My account / Sign in
AZENRU
← itnuvo.com

Routers and the routing table: how an IP packet is forwarded

Lesson 4.19 minBeginnerNovember 4, 2026
Open

This lesson is open to everyone. The other lessons open with a package: sign in or sign up, then choose a package.

Key points

  • A switch forwards frames by destination MAC address (Data Link, layer 2); a router forwards packets by destination IP address (Network, layer 3).
  • MAC addresses are not hierarchical (flat 48 bits), so switching does not scale. A router knows a whole network with one entry: 1 entry instead of 400 MACs.
  • A switch uses a MAC address table, a router a routing table. A new router's routing table only holds the networks of its directly connected interfaces (C = connected).
  • A computer checks with its own IP address and mask: if the destination is in another subnet, it sends the packet to its default gateway. The router looks up the destination IP in its routing table and sends the packet out the matching interface.
  • ping tests connectivity, traceroute shows the routers a packet passes through. Windows tracert sends ICMP echo, Cisco IOS traceroute sends UDP probes.

A switch "switches", a router "routes"

You already know that switches "switch" Ethernet frames based on MAC address information. A switch's only concern is this: when a frame enters one of its interfaces, look at the destination MAC address and know which interface to send it out of. Switches make decisions based on Data Link layer (layer 2) information.

Routers have a similar task, but this time we look at IP packets. IP lives on the Network layer (layer 3). A router looks at the destination IP address in an IP packet and sends it out the correct interface.

Why not switch with MAC addresses everywhere?

Both MAC addresses and IP addresses are unique per device. So why don't we just switch everywhere?

Switches only: each switch has to learn 400 MAC addressesSwitchSwitch200 computers200 computersWith routers: each router keeps 1 network entry for the other sideRouter ARouter B192.168.1.0 /24192.168.2.0 /24192.168.2.0/24 → B192.168.1.0/24 → A
Figure 1 · MAC addresses are flat, so switching does not scale; a router knows a whole network with a single entry

There are two switches, each with 200 computers connected. If all 400 computers want to talk to each other, each switch has to learn 400 MAC addresses.

Now think about a really large network, for example the Internet. There are millions of devices! Could you keep millions of entries in a MAC address table, one for every device on the Internet? No way!

The problem with switching is that it is not scalable: there is no hierarchy, just flat 48-bit MAC addresses.

Now look at the same example with routers. The 200 computers on the left are connected to Router A and are in the 192.168.1.0 /24 network. Router B has 200 computers behind it, using 192.168.2.0 /24.

Routers "route" based on IP information. All Router A needs to know is that 192.168.2.0 /24 is behind Router B. Router B only needs to know that 192.168.1.0 /24 is behind Router A. Instead of 400 MAC addresses, each router needs a single entry for the other side's network.

SwitchRouter
Address it looks atDestination MAC addressDestination IP address
OSI layerLayer 2 (Data Link)Layer 3 (Network)
TableMAC address tableRouting table

The routing table: only connected networks at first

When you take a brand new router out of the box it builds a routing table, but the only information in it is the directly connected interfaces. Let's start with a simple example:

ComputerA192.168.1.1ComputerB192.168.2.2Router192.168.1.0 /24192.168.2.0 /24Fa0/0 .254Fa1/0 .254gateway .1.254gateway .2.254Routing TableC 192.168.1.0/24Fa0/0C 192.168.2.0/24Fa1/0
Figure 2 · Once the interfaces have an IP address and subnet mask, the router lists both networks as "C" (connected)
  • ComputerA: IP address 192.168.1.1, default gateway 192.168.1.254.
  • ComputerB: IP address 192.168.2.2, default gateway 192.168.2.254.
  • Router: 192.168.1.254 on FastEthernet 0/0, 192.168.2.254 on FastEthernet 1/0.
  • Because a subnet mask is configured with each IP address, the router knows the network addresses and stores them in its routing table.

ComputerA → ComputerB, step by step

1ComputerA builds a packet: dst 192.168.2.22Checks with its mask: other subnet → sends to the default gateway3Router looks in the routing table: 192.168.2.0/24 → Fa1/04ComputerB receives the packet
Figure 3 · ComputerA → ComputerB: the packet reaches the other subnet through the default gateway
  1. ComputerA sends an IP packet with destination IP address 192.168.2.2.
  2. ComputerA checks its own IP address and subnet mask and concludes that 192.168.2.2 is in another subnet. So it forwards the packet to its default gateway.
  3. The router receives the packet, checks the destination IP address and scans its routing table. 192.168.2.2 matches the 192.168.2.0 /24 entry, and the router sends the packet out its FastEthernet 1/0 interface.
  4. ComputerB receives the packet.

Configuring it on a real router

The computers' configuration:

text
C:\Documents and Settings\ComputerA>ipconfig
   IP Address. . . . . . . . . . . . : 192.168.1.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.254

C:\Documents and Settings\ComputerB>ipconfig
   IP Address. . . . . . . . . . . . : 192.168.2.2
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.2.254

On the router we just configure IP addresses on the interfaces:

text
Router(config)#interface fastEthernet 0/0
Router(config-if)#no shutdown
Router(config-if)#ip address 192.168.1.254 255.255.255.0
Router(config-if)#exit
Router(config)#interface FastEthernet 1/0
Router(config-if)#no shutdown
Router(config-if)#ip address 192.168.2.254 255.255.255.0

Let's check the routing table:

text
R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       ...

Gateway of last resort is not set

C    192.168.1.0/24 is directly connected, FastEthernet0/0
C    192.168.2.0/24 is directly connected, FastEthernet1/0

The router knows both directly connected networks. The letter C means "connected".

Note (Cisco IOS 15 and later): newer IOS versions also show a /32 entry with the code L (local) for the interface's own IP address next to each connected network, for example L 192.168.1.254/32. Don't be surprised when you see it in Packet Tracer.

Testing with ping

Let's ping from ComputerA to ComputerB:

text
C:\Users\ComputerA>ping 192.168.2.2

Pinging 192.168.2.2 with 32 bytes of data:
Reply from 192.168.2.2: bytes=32 time<1ms TTL=128
Reply from 192.168.2.2: bytes=32 time<1ms TTL=128
Reply from 192.168.2.2: bytes=32 time<1ms TTL=128
Reply from 192.168.2.2: bytes=32 time<1ms TTL=128

Ping statistics for 192.168.2.2:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

The ping works: we just routed our first IP packet!

Be aware: when you ping from one Windows computer to another, the firewall might be blocking ICMP traffic.

traceroute: which routers does the packet pass?

When you reach a server on the Internet you go through many routers. You can see which routers your packets travel through with traceroute. From the book author's computer to www.cisco.com:

text
C:\Users\Computer>tracert www.cisco.com

Tracing route to e144.dscb.akamaiedge.net [95.100.128.170]
over a maximum of 30 hops:

  1    <1 ms    <1 ms    <1 ms  192.168.154.2
  2    <1 ms    <1 ms    <1 ms  192.168.81.254
  3     9 ms     7 ms     9 ms  10.224.124.1
  ...
 10    12 ms    11 ms    11 ms  95.100.128.170

Trace complete.

Here the packet passes 10 routers. You see the routers' IP addresses; the computer also did a hostname lookup, so you see the names of some routers too.

Traceroute also exists on Cisco routers: type the traceroute command and the IP address you want to reach.

Unlike the book: the book says "Traceroute uses the ICMP protocol". According to the Cisco documentation, the Windows tracert command sends ICMP echo requests as probes, while Cisco IOS traceroute sends UDP probe packets. In both cases the replies come back as ICMP messages.

Check yourself

5 questions · answers are shown instantly · 3 correct answers complete the lesson

1What information do a switch and a router base their decisions on?

A switch works at the Data Link layer with MAC addresses, a router at the Network layer with IP addresses.

2Why isn't switching alone used in a large network such as the Internet?

MAC addresses have no hierarchy, so the MAC address table would need millions of entries. A router knows a whole network with one entry.

3You configured IP addresses and masks on a new router's interfaces. What will the routing table show?

At first a router only knows the networks of the interfaces that have an IP address and mask.

4ComputerA (192.168.1.1 /24) sends a packet to 192.168.2.2. Who does it hand the packet to first?

ComputerA checks with its mask: 192.168.2.2 is in another subnet. So the packet goes to the default gateway.

5What does the Cisco IOS traceroute command send as probes?

According to the Cisco documentation, Cisco routers send UDP probes; Windows tracert uses ICMP echo requests.
Was this lesson useful?

Comments

Sign in to comment.