DEV Community

Tejas Shinkar
Tejas Shinkar

Posted on Edited on

Routers — How ARP and Routing Work Together

🌐 Routers — Part 2

How ARP + Routing Work Together

Series: Networking Fundamentals for Cloud & DevOps — Part 5 of 6

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?

Routing Table: destination IP/network → where to send next.
ARP Table: IP address → MAC address.

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, 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

A wants to send data to C, at destination 10.0.66.7.


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.

A checks its routing information and realizes 10.0.66.7 is outside its local network. 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 (10.0.44.1) but doesn't know R1's MAC yet. So A sends an ARP Request:

"Who has 10.0.44.1?"

R1 replies 10.0.44.1 → eee1, and A stores this mapping in its ARP table (10.0.44.1 → eee1). 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
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, while the IP packet still says 10.0.44.9 → 10.0.66.7.


Step 4 — R1 Receives It

R1 receives the frame because DST MAC = eee1, 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.

R1 checks its routing table: 10.0.66.0/24 → 10.0.55.2.

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) but needs R2's MAC. So R1 sends ARP:

"Who has 10.0.55.2?"

R2 replies 10.0.55.2 → eee2. R1 stores this in its ARP table (10.0.55.2 → eee2). 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, while the Layer 3 addresses remain unchanged:

L2:  SRC MAC = eee1         DST MAC = eee2
L3:  SRC IP  = 10.0.44.9    DST IP  = 10.0.66.7   (unchanged)
Enter fullscreen mode Exit fullscreen mode

MAC addresses → changed. IP addresses (10.0.44.9 → 10.0.66.7) → stay the same.

The frame is now R1 ─────────────────→ R2. The IP packet is still ultimately going to C.


Step 7 — R2 Receives It

R2 receives the frame because DST MAC = eee2, which is R2's MAC address. R2 removes the Layer 2 header and checks the destination IP (DST IP = 10.0.66.7).

R2's routing table says 10.0.66.0/24 → Left interface — C is directly connected to R2. So R2 now needs C's MAC address. It sends ARP:

"Who has 10.0.66.7?"

C replies 10.0.66.7 → c7c7. R2 stores this in its ARP table (10.0.66.7 → c7c7).


Step 8 — R2 Sends the Frame to C

R2 creates another new Layer 2 header, while the Layer 3 information remains the same:

L2:  SRC MAC = eee4         DST MAC = c7c7
L3:  SRC IP  = 10.0.44.9    DST IP  = 10.0.66.7
Enter fullscreen mode Exit fullscreen mode

So R2 ─────────────────→ C. C receives the frame because DST MAC = c7c7, and checks the destination IP (DST IP = 10.0.66.7) — that's C's own IP.

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

At every router hop: L2/MAC header → changes. L3/IP header → stays the same.


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?" — e.g. 10.0.66.0/24 → 10.0.55.2. The router uses this information to select the next hop/interface.

ARP Table answers: "What MAC address do I need for that next hop?" — e.g. 10.0.55.2 → eee2.

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.

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:

  • Routing Table → Where should the packet go?
  • ARP Table → What MAC gets me to the next hop?
  • IP → Final destination
  • MAC → Current hop

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.

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)