Routing to Local and Remote Networks
A host does not randomly spray packets onto the wire. It runs a short, fixed procedure for every packet: decide whether the destination is local or remote, find the right MAC address, and hand a frame to the switch. Understand this procedure and you understand the heart of Layer 3 forwarding.
- List the steps a host follows when sending an IP packet.
- Use ANDing to decide whether a destination is local or remote.
- Explain when a host ARPs for the destination versus for the default gateway.
- Describe how a router re-encapsulates a packet with a new Layer 2 header.
- State the golden rule: IP addresses stay, MAC addresses change every hop.
The question every host asks
Before a host can put anything on the medium, it must answer one question: is the destination on my own network, or on some other network? The answer changes everything about how the packet is addressed at Layer 2. If the destination is local, the host resolves and uses the destination’s own MAC address. If the destination is remote, the host cannot reach it directly, so it sends to its default gateway — a router that knows how to leave the local network.
The logic is the same on every operating system, from Windows to Linux to a Cisco router. The detail that trips people up is how a host decides local versus remote: it uses the subnet mask and a bitwise operation called ANDing.
Step 1 — build the packet
The transport layer hands down a segment. IP wraps it in an IPv4 header carrying the source IP (this host) and the destination IP (the final target), a TTL, and a protocol number. The result is a packet. Crucially, at this moment the destination IP is the final destination — it is not the router, even if the router is the next device the packet will physically reach. The packet is now ready to be placed inside a frame.
Step 2 — local or remote? (ANDing)
The host performs a bitwise AND between the mask and the destination address, and a second AND between the mask and its own address. If the two results match, the destination is local; if they differ, it is remote. ANDing compares bit by bit: 1 AND 1 = 1, and any zero in either operand gives 0.
Take a host at 192.168.1.10/24 (mask 255.255.255.0):
Host address 192.168.1.10 AND 255.255.255.0 = 192.168.1.0 (my network)
Destination A 192.168.1.20 AND 255.255.255.0 = 192.168.1.0 = LOCAL
Destination B 192.168.2.10 AND 255.255.255.0 = 192.168.2.0 = REMOTE
Destination A produces the same network (192.168.1.0), so it is local. Destination B
produces 192.168.2.0, a different network, so it is remote. Notice that the mask does the
work: guessing from “the first three numbers” fails as soon as the mask is not a /24.
Step 3 — resolve the destination MAC
The packet has IP addresses, but the wire carries frames, and a frame needs MAC addresses. The host now does one of two things:
- Local destination: the host looks up the destination IP in its ARP cache. If the entry is missing, it broadcasts an ARP request (“who has 192.168.1.20?”) and the destination replies with its MAC. The frame’s destination MAC is the destination host itself.
- Remote destination: the host looks up the default gateway IP and ARPs for that. The frame’s destination MAC is the router’s interface MAC, not the remote host’s MAC. The remote host’s MAC is irrelevant here — it lives on another link entirely.
The host then builds a Layer 2 frame: source MAC = its own, destination MAC = resolved above, carrying the packet as payload with an FCS trailer. (ARP itself is covered in the data-link week; recall that it maps IP to MAC only within a local network.)
Step 4 — the switch forwards the frame
The host places the frame on the medium. The local switch reads only the Layer 2 header. It notes the source MAC and the port it arrived on (learning), then looks up the destination MAC in its MAC address table and forwards the frame out the matching port. For remote traffic, that destination MAC is the router’s, so the frame is delivered to the router. The switch never opens the IP header and never sees the destination IP address — that is not its job.
Step 5 — the router decides the path
The router receives the frame, checks the FCS, and strips the Layer 2 header. Now it reads the packet’s destination IP and looks it up in its routing table using longest-prefix match (Lesson 11). The lookup names an outgoing interface and usually a next-hop address. This is the only place in the journey where the IP destination is examined to choose a path.
Before forwarding, the router decrements the packet’s TTL and recomputes the IPv4 header checksum. If the TTL reaches zero, the packet is dropped and an ICMP message is sent back. The router does not change the source or destination IP address.
Step 6 — re-encapsulate for the next hop
To put the packet back on a wire, the router must build a brand-new Layer 2 frame. The new frame uses the router’s exit-interface MAC as the source, and the next device’s MAC as the destination (found by ARP on that link). The entire old frame — header and trailer — is discarded. Only the packet survives, unchanged except for the decremented TTL and recomputed checksum.
Step 7 — repeat at every hop
Each router along the path repeats steps 5 and 6: strip the frame, read the IP destination, look it up, decrement TTL, and build a new frame. The packet hops from link to link until it reaches a router that is directly attached to the destination network. That last router ARPs for the final host and sends the packet in a frame addressed to the host’s MAC. The destination host strips the frame, then the IP header, and delivers the segment to the correct application.
A worked two-hop example
Host A (192.168.1.10) sends to Host B (192.168.2.10). The default gateway is 192.168.1.1, the router’s LAN-side interface. Follow the addresses in each frame:
| Hop | Source MAC | Destination MAC | Source IP | Destination IP |
|---|---|---|---|---|
| 1 Host A → Router | 00:11:22:33:44:AA (Host A) | 00:11:22:33:44:11 (Router G0/0) | 192.168.1.10 | 192.168.2.10 |
| 2 Router → Host B | 00:11:22:33:44:22 (Router G0/1) | 00:11:22:33:44:BB (Host B) | 192.168.1.10 | 192.168.2.10 |
Read the IP columns: they never change. Read the MAC columns: every value is different in the two hops. That is the whole lesson in one table. With more routers you would simply add more rows, each with fresh MAC addresses and the identical IP pair.
The default gateway, defined
The default gateway is the router interface on the host’s own subnet that the host sends packets to when the destination is remote. It is configured on the host (manually or via DHCP) and must be an address on the host’s own subnet, otherwise the host could not reach it without a gateway — a chicken-and-egg problem. Every host has exactly one default gateway per IP configuration; a router, by contrast, has a routing table full of next hops.
Verify your IP parameters (Windows, macOS, Linux)
Objective 1.10 asks you to verify IP parameters for the client OS — the address, mask, default gateway, and DNS servers a host is actually using. The commands differ by operating system, but they report the same four facts. Learn one per platform and recognise them all.
| What you want to see | Windows | macOS | Linux |
|---|---|---|---|
| IP address & mask | ipconfig | ifconfig en0 | ip addr show |
| Full detail (gateway, DNS, MAC) | ipconfig /all | networksetup -getinfo Wi-Fi | ip -c addr and ip route |
| Default gateway | ipconfig (shows it) / route print | netstat -rn or route -n get default | ip route show |
| DNS servers | ipconfig /all or nslookup | scutil --dns | cat /etc/resolv.conf or resolvectl status |
| Test reachability | ping / tracert | ping / traceroute | ping / traceroute |
| MAC / ARP cache | getmac / arp -a | arp -a | ip link / ip neigh |
ipconfig /all
Shows the IPv4 address, subnet mask, default gateway, DHCP server, DNS servers, and
the physical (MAC) address. ipconfig /release and ipconfig /renew drop and
re-request the DHCP lease; ipconfig /flushdns clears the DNS resolver cache.
ifconfig and networksetup
ifconfig en0 prints the address, mask, and status: active for the Wi-Fi/Ethernet
interface (en0, en1…). networksetup -getinfo Wi-Fi adds the
router (default gateway) and DNS servers. scutil --dns lists the resolver configuration.
ip
The modern tool is ip: ip addr show (address and mask),
ip route show (the default gateway is the line beginning default via),
ip link (interface and MAC), and ip neigh (the ARP/neighbour table). The older
ifconfig and route -n still appear on many systems.
255.255.255.0); macOS and Linux usually
show a prefix length (/24). Same information, two notations — convert as needed
using the subnetting method from Week 7.
The vocabulary you need
Every term below appears in the lesson text above. Select one to read its definition, then use the quiz at the end to check what stuck.
Review
Check what you have learned with these review questions.
Sources & references
- Cisco. CCNA (200-301) Exam Topics. cisco.com.
- IETF. Request for Comments (RFCs). rfc-editor.org.
- IANA. Internet Assigned Numbers Authority registries. iana.org.
Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.