Network Layer & IPv4 — Gateways and Delivery
How does a host know where to send a packet? It performs one simple test — a bitwise AND — and that single decision separates local delivery from remote delivery. This lesson shows the test, the ARP that follows, and the full hop-by-hop timeline.
The default gateway
A host on a network can reach devices on its own subnet easily: it just sends a frame directly on the local link. But what about a server on a different network, or on the Internet? The host cannot put that traffic directly on the wire, because the destination is not reachable locally.
The answer is the default gateway: the router interface that connects the host’s local network to all other networks. A host is configured with three things:
- Its own IP address.
- Its subnet mask (how big the local network is).
- Its default gateway (the router to send off-net traffic to).
Two rules are essential and tested:
- The default gateway must be a router interface on the same subnet as the host. If it is not reachable on the local link, the host cannot use it.
- Every host that needs to reach other networks needs a gateway. Without one, the host can talk only to its own subnet.
On a typical home network the gateway is the router’s LAN address, such as
192.168.1.1, and hosts are 192.168.1.10, .11, and so on. The
router then forwards traffic toward the Internet.
Local or remote? The AND test
How does a host decide whether a destination is local or remote? It compares the network portion of the destination with its own, using the subnet mask. The method is a bitwise AND. A host does two ANDs:
2. Destination network = (destination IP) AND (my mask).
If the two results are equal → the destination is LOCAL.
If the two results differ → the destination is REMOTE.
When two IPs, ANDed with the same mask, yield the same network number, they are on the same subnet. When the network numbers differ, the destination is on a different subnet and must be reached through the gateway.
Worked example. Host: 192.168.1.10, mask
255.255.255.0 (/24). The host’s own network is 192.168.1.0.
- Destination
192.168.1.25AND255.255.255.0=192.168.1.0→ equal → LOCAL. - Destination
10.0.0.20AND255.255.255.0=10.0.0.0→ different → REMOTE.
This test is the host’s entire routing decision. If the destination is local, send directly. If it is remote, hand the packet to the default gateway and let the router deal with it.
What the host ARPs for
Once the host decides local or remote, it must build a Layer 2 frame, which needs a destination MAC address. It learns that MAC with ARP (Address Resolution Protocol, RFC 826). The crucial detail is what it ARPs for:
| Case | What the host ARPs for | Frame sent to |
|---|---|---|
| LOCAL destination | The MAC of the destination host itself | The destination host, directly on the local link |
| REMOTE destination | The MAC of the default gateway | The gateway router (the destination IP is still the remote host) |
The counter-intuitive part: when the destination is remote, the host never ARPs for the remote host. It cannot — ARP only works on the local link, and the remote host is not there. So the host ARPs for its gateway’s MAC and builds a frame addressed, at Layer 2, to the router. The packet’s destination IP remains the remote host; only the frame’s destination MAC is the gateway.
A packet to an off-site server
Now follow a real example. Host A (192.168.1.10, MAC AA) sends to a
server (10.0.0.20, MAC SRV) on a different network. The router has two
interfaces: G0/0 = 192.168.1.1 (MAC R1) and G0/1 = 10.0.0.1
(MAC R2).
- Build the packet. Data is encapsulated up the stack. The IP header has
source
192.168.1.10and destination10.0.0.20. - AND test. Destination
10.0.0.20is not in192.168.1.0/24→ REMOTE → use the gateway. - ARP for the gateway. Host A sends an ARP request for
192.168.1.1; the router replies with its MACR1. - Frame 1. Host A builds an Ethernet frame: source MAC
AA, destination MACR1. Source IP192.168.1.10, destination IP10.0.0.20. Sent to the router. - Router decides. The router de-encapsulates the frame, reads the IP
destination
10.0.0.20, and consults its routing table. It finds10.0.0.0/24is reachable outG0/1. - ARP for the server. The router ARPs for
10.0.0.20on the second LAN (or uses its cache) and learns MACSRV. - Frame 2. The router builds a brand-new Ethernet frame: source MAC
R2, destination MACSRV. The IP header is untouched — source192.168.1.10, destination10.0.0.20. - Server receives it. Server sees a frame to its own MAC, de-encapsulates, and finds an IP packet addressed to itself.
The router rewrites the frame
The figure shows both frames for the same packet. Notice the frame changes; the packet does not.
Media independence of IP
One of the network layer’s greatest strengths is that it does not care how a link carries bits. IP is media independent: the same IP packet can be carried over any Layer 2 technology, because each link builds its own frame around the packet.
- Ethernet — wired LANs and Metro Ethernet.
- Wi-Fi (802.11) — wireless LANs.
- PPP — point-to-point serial links (WAN circuits).
- Fibre / optical — long-haul and backbone links.
Each of these has a different frame format and a different maximum frame size, yet the IP packet inside is identical. That is why a packet can start on Wi-Fi at your home, cross fibre in an ISP backbone, and arrive over Ethernet at a data centre. The network layer provides a common language that lets different physical networks interoperate — the property that makes the Internet a network of networks.
It also means the network layer is connectionless, best-effort in IP’s core design: it does not guarantee delivery, ordering, or error recovery. Those are left to higher layers (TCP), while IP simply makes the best effort to move each packet hop by hop.
Common pitfalls
- ARPing for a remote host. A host ARPs for the gateway, never for a host on another subnet.
- Placing the gateway off-subnet. If the gateway is not on the host’s subnet, the host cannot reach it on the local link.
- Thinking the destination MAC is the final server. For remote destinations, the first frame’s destination MAC is the gateway.
- Believing the IP header changes per hop. IP source/destination are constant end to end; MACs change every hop.
- Forgetting media independence. The same IP packet rides inside different Layer 2 frames on each link.
Review
Check what you have learned with these review questions.
Sources & references
- Braden, R. RFC 1122: Requirements for Internet Hosts — Communication Layers (1989). Subnet masks, local vs. remote delivery, and default gateway behaviour. rfc-editor.org/rfc/rfc1122.
- Plummer, D. RFC 826: An Ethernet Address Resolution Protocol (1982). rfc-editor.org/rfc/rfc826.
- Cisco. CCNA (200-301) Exam Topics, IP Connectivity and IPv4 Addressing. cisco.com.
Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.