Putting It Together
How a router bridges two networks — intra-network vs inter-network delivery
This is an applied recap — no big new theory, just watching everything from the last few chapters work together. We will set up two real networks joined by one router and trace two deliveries: one within a network, one across networks.
By the end you will see exactly why the subnet mask, the network/host split, and the default gateway all exist.
Two networks, one router
Our setup: Network A is 192.168.1.0/24 with hosts A1 (.2), A2 (.3), A3 (.4). Network B is 192.168.2.0/24 with hosts B1 (.2), B2 (.3), B3 (.4). Both use the mask 255.255.255.0. A single router sits between them and holds an IP in each network.
A router has many interfaces
The important insight: a router (default gateway) has multiple network interfaces, each with its own IP on a different network. One interface might face your home network, another face your ISP (Jio, Airtel, etc.). This is what lets a router connect separate networks.
A1 → A3: run the mask
A1 wants to reach A3. It ANDs its own IP (192.168.1.2) with the mask → 192.168.1.0, and ANDs A3’s IP (192.168.1.4) with the mask → 192.168.1.0. The last octet is zeroed out in both. The results match — same network.
A1 → A3: direct delivery
Because they are on the same network, A1 sends straight to A3 — the router is not needed for this one. (In practice a switch inside the network helps, with negligible latency.)
Intra-network: Same network = direct delivery. The gateway sits idle.
A1 → B3: run the mask
Now A1 wants to reach B3 (192.168.2.4). A1 ANDs B3’s IP with the mask → 192.168.2.0, which does not equal A1’s own 192.168.1.0. Different networks — A1 cannot deliver this directly.
A1 → B3: via the gateway
So A1 forwards the packet to its default gateway (the router), essentially saying "I do not know where this IP is." The router looks at its interfaces, sees that Network B is on its other interface, and forwards the packet through to B3.
Inter-network: Different networks = hand to the gateway, which bridges the two sides.
What is still missing
We have glossed over one thing: to actually place a packet on the wire toward the next device, we need that device’s physical (MAC) address. And there is much more ahead.
- MAC address
- The physical address of a device’s interface — next chapter.
- ARP
- How a device finds a MAC from an IP.
- NAT & hop-by-hop routing
- How private networks share a public IP and how packets change at each hop.