DEV Community

Tejas Shinkar
Tejas Shinkar

Posted on

Routers — How ARP and Routing Work Together

🌐 Routers — Part 2

How ARP + Routing Work Together

Series: Networking Fundamentals for Cloud & DevOps

This part mainly explains how ARP + routing work together when Host A sends data to Host C through R1 and R2.

Before following the journey, keep these two tables separate:

Table Layer Main Question
Routing Table L3 Where should I send the packet next?
ARP Table L2 What MAC address do I need for the next hop?

So:

Routing Table:
Destination IP/network → where to send next

ARP Table:
IP address → MAC address
Enter fullscreen mode Exit fullscreen mode

This distinction is extremely important.


Example: A → C

Consider this network:

       10.0.44.0/24        10.0.55.0/24        10.0.66.0/24

A                         R1                    R2                    C
10.0.44.9                 .1                    .2                 10.0.66.7
MAC a9a9                  eee1                  eee2                  c7c7

       ────────────────────────┬───────────────────────┬──────────────────────
                                │                       │
Enter fullscreen mode Exit fullscreen mode

More simply:

A ───────── R1 ───────── R2 ───────── C
Enter fullscreen mode Exit fullscreen mode

With:

A:
IP  = 10.0.44.9
MAC = a9a9

R1:
IP  = 10.0.44.1
MAC = eee1

R2:
IP  = 10.0.55.2
MAC = eee2

C:
IP  = 10.0.66.7
MAC = c7c7
Enter fullscreen mode Exit fullscreen mode

A wants to send data to C.

The destination is:

10.0.66.7
Enter fullscreen mode Exit fullscreen mode

Step 1 — A Creates the L3 Packet

The destination IP remains C's IP:

SRC IP = 10.0.44.9
DST IP = 10.0.66.7
Enter fullscreen mode Exit fullscreen mode

A checks its routing information and realizes:

10.0.66.7 is outside my local network.
Enter fullscreen mode Exit fullscreen mode

So A needs to send the packet to its default gateway, R1.

The important point is:

The final destination IP is C, but the next hop is R1.


Step 2 — A Needs R1's MAC

A knows R1's IP:

R1 IP = 10.0.44.1
Enter fullscreen mode Exit fullscreen mode

But A doesn't know R1's MAC yet:

10.0.44.1 → ??? MAC
Enter fullscreen mode Exit fullscreen mode

So A sends an ARP Request:

"Who has 10.0.44.1?"
Enter fullscreen mode Exit fullscreen mode

R1 replies:

10.0.44.1 → eee1
Enter fullscreen mode Exit fullscreen mode

A stores this mapping in its ARP table.

ARP Table

10.0.44.1 → eee1
Enter fullscreen mode Exit fullscreen mode

Now A knows the Layer 2 destination needed for the first hop.


Step 3 — A Sends the Frame to R1

A can now construct the Layer 2 frame.

L2

SRC MAC = a9a9
DST MAC = eee1
Enter fullscreen mode Exit fullscreen mode

L3

SRC IP = 10.0.44.9
DST IP = 10.0.66.7
Enter fullscreen mode Exit fullscreen mode

Notice the important thing:

MAC destination = R1

IP destination = C

So the frame goes:

A ─────────────────→ R1
Enter fullscreen mode Exit fullscreen mode

while the IP packet still says:

10.0.44.9 → 10.0.66.7
Enter fullscreen mode Exit fullscreen mode

Step 4 — R1 Receives It

R1 receives the frame because:

DST MAC = eee1
Enter fullscreen mode Exit fullscreen mode

which is R1's MAC address.

R1 removes/discards the old Layer 2 header.

The IP information is still:

SRC IP = 10.0.44.9
DST IP = 10.0.66.7
Enter fullscreen mode Exit fullscreen mode

R1 checks its routing table:

10.0.66.0/24 → 10.0.55.2
Enter fullscreen mode Exit fullscreen mode

The meaning is:

To reach C's network, send the packet to R2 at 10.0.55.2.

This is the Layer 3 routing decision.


Step 5 — R1 Needs R2's MAC

R1 knows R2's IP:

10.0.55.2
Enter fullscreen mode Exit fullscreen mode

but it needs R2's MAC:

10.0.55.2 → ??? MAC
Enter fullscreen mode Exit fullscreen mode

So R1 sends ARP:

"Who has 10.0.55.2?"
Enter fullscreen mode Exit fullscreen mode

R2 replies:

10.0.55.2 → eee2
Enter fullscreen mode Exit fullscreen mode

R1 stores:

ARP Table

10.0.55.2 → eee2
Enter fullscreen mode Exit fullscreen mode

Now R1 knows the Layer 2 destination for the next hop.


Step 6 — R1 Sends a NEW Layer 2 Frame

This is the most important concept in this entire example.

R1 creates a new Layer 2 header:

L2:

SRC MAC = eee1
DST MAC = eee2
Enter fullscreen mode Exit fullscreen mode

But the Layer 3 addresses remain:

L3:

SRC IP = 10.0.44.9
DST IP = 10.0.66.7
Enter fullscreen mode Exit fullscreen mode

Notice:

MAC addresses → CHANGED

10.0.44.9 → 10.0.66.7
IP addresses → STAY THE SAME
Enter fullscreen mode Exit fullscreen mode

The frame is now:

R1 ─────────────────→ R2
Enter fullscreen mode Exit fullscreen mode

The IP packet is still ultimately going to C.


Step 7 — R2 Receives It

R2 receives the frame because:

DST MAC = eee2
Enter fullscreen mode Exit fullscreen mode

which is R2's MAC address.

R2 removes the Layer 2 header and checks the destination IP:

DST IP = 10.0.66.7
Enter fullscreen mode Exit fullscreen mode

R2's routing table says:

10.0.66.0/24 → Left interface
Enter fullscreen mode Exit fullscreen mode

C is directly connected to R2.

So R2 now needs C's MAC address.

It sends ARP:

"Who has 10.0.66.7?"
Enter fullscreen mode Exit fullscreen mode

C replies:

10.0.66.7 → c7c7
Enter fullscreen mode Exit fullscreen mode

R2 stores:

ARP Table

10.0.66.7 → c7c7
Enter fullscreen mode Exit fullscreen mode

Step 8 — R2 Sends the Frame to C

R2 creates another new Layer 2 header:

L2:

SRC MAC = eee4
DST MAC = c7c7
Enter fullscreen mode Exit fullscreen mode

The Layer 3 information remains:

L3:

SRC IP = 10.0.44.9
DST IP = 10.0.66.7
Enter fullscreen mode Exit fullscreen mode

So:

R2 ─────────────────→ C
Enter fullscreen mode Exit fullscreen mode

C receives the frame because:

DST MAC = c7c7
Enter fullscreen mode Exit fullscreen mode

C checks the destination IP:

DST IP = 10.0.66.7
Enter fullscreen mode Exit fullscreen mode

That's C's own IP.

Therefore:

C accepts the packet.


The Entire Journey

The complete journey can be visualized as:

A                         R1                         R2                         C
│                          │                          │                          │
│── ARP R1 ──────────────→│                          │                          │
│←─ 10.0.44.1 / eee1 ────│                          │                          │
│                          │                          │                          │
│── a9a9 → eee1 ─────────→│                          │                          │
│      IP: A → C           │                          │                          │
│                          │                          │                          │
│                          │── ARP R2 ──────────────→│                          │
│                          │←─ 10.0.55.2 / eee2 ─────│                          │
│                          │                          │                          │
│                          │── eee1 → eee2 ─────────→│                          │
│                          │      IP: A → C           │                          │
│                          │                          │                          │
│                          │                          │── ARP C ───────────────→│
│                          │                          │←─ 10.0.66.7 / c7c7 ────│
│                          │                          │                          │
│                          │                          │── eee4 → c7c7 ─────────→│
│                          │                          │      IP: A → C           │
Enter fullscreen mode Exit fullscreen mode

The key pattern is:

At every router hop:

L2 / MAC header → CHANGES
L3 / IP header   → STAYS THE SAME
Enter fullscreen mode Exit fullscreen mode

Routing Table vs ARP Table

This is one of the most important distinctions to remember.

Routing Table

Answers:

"Where should I send this packet next?"

Example:

10.0.66.0/24 → 10.0.55.2
Enter fullscreen mode Exit fullscreen mode

The router uses this information to select the next hop/interface.

ARP Table

Answers:

"What MAC address do I need for that next hop?"

Example:

10.0.55.2 → eee2
Enter fullscreen mode Exit fullscreen mode

So the relationship is:

Destination network
        ↓
Routing Table
        ↓
Next-hop IP
        ↓
ARP Table
        ↓
Next-hop MAC
        ↓
Build Layer 2 frame
        ↓
Send
Enter fullscreen mode Exit fullscreen mode

The One Thing to Remember

At every router hop:

L2 / MAC header → CHANGES
L3 / IP header   → STAYS THE SAME
Enter fullscreen mode Exit fullscreen mode

For this example:

Hop Source MAC Destination MAC Source IP Destination IP
A → R1 a9a9 eee1 10.0.44.9 10.0.66.7
R1 → R2 eee1 eee2 10.0.44.9 10.0.66.7
R2 → C eee4 c7c7 10.0.44.9 10.0.66.7

This table captures the whole concept:

Routing table tells the router WHERE to send the packet.

ARP table tells the router WHICH MAC address is needed for the next hop.


Final Mental Model

ROUTER
│
ā”œā”€ā”€ Routing Table
│     └── Destination network → Next hop / Interface
│
ā”œā”€ā”€ ARP Table
│     └── Next-hop IP → MAC address
│
└── Forwarding process
      │
      ā”œā”€ā”€ Check destination IP
      │
      ā”œā”€ā”€ Routing table decides next hop
      │
      ā”œā”€ā”€ ARP resolves next-hop MAC
      │
      ā”œā”€ā”€ Build a NEW L2 frame
      │
      └── Forward to next hop
Enter fullscreen mode Exit fullscreen mode

And the simplest possible memory rule is:

Routing Table
→ Where should the packet go?

ARP Table
→ What MAC gets me to the next hop?

IP
→ Final destination

MAC
→ Current hop
Enter fullscreen mode Exit fullscreen mode

This is the connection between everything we've learned so far:

IP + Routing
      ↓
Which network should the packet reach?

ARP
      ↓
Which MAC address gets the frame to the next hop?

Ethernet / Layer 2
      ↓
Move the frame across the current hop
Enter fullscreen mode Exit fullscreen mode

For Cloud + DevOps, this mental model becomes especially useful when understanding VPC route tables, subnets, gateways, next hops, and connectivity troubleshooting.


Part 5 of 6 — Networking Fundamentals for Cloud & DevOps

Next: deeper router behavior and how routing decisions are made.

Top comments (0)