IP Forwarding: How a Packet Finds Its Next Stop
Suppose your laptop sends a request to a website. The request leaves your home network through a router, but the router has a smaller job than planning the whole trip. It needs to choose the next stop.
That handoff is IP forwarding: receiving a packet, a small piece of network data, and sending it toward its destination. IP means Internet Protocol, the rules for moving that data between networks.
The packet carries a destination address. A router reads it, checks where the packet can go and sends it through the appropriate network connection. The next router repeats the job. A long journey is built from these local decisions.
For this trip, the laptop is using IPv4, one version of IP, to send data to a single destination.
Hub, Switch or Router: What's the Difference?
The router's directions
First, the router checks whether the packet is addressed to the router itself. If so, the packet has reached its destination. A request traveling to a website elsewhere needs to move on.
To choose where, the router consults its routing table. This holds information about paths to different destination networks. An entry tells the router which network connection to use and where to send the packet next. The outgoing connection is called an interface. The next stop, or next hop, may be another router.
The table doesn't need a separate entry for every computer on the internet. It can describe ranges of addresses. A default route provides a next step for destinations without a more specific matching entry.
- Get five gigabit ports and a fast ARM processor for the price of a basic home router.
- Practice real routing at your desk on gear that network pros also deploy.
- Tuck it beside your modem: it takes up almost no room.
Suppose the table has one route covering a large range of addresses and another covering a smaller part of that range. If the website's address fits both, the smaller, more specific range wins. Engineers call this longest-prefix matching, because a longer matching part of the address identifies a narrower range.
With a route selected, the router checks whether it can forward the packet and sends it onward. The IPv4 router requirements set out this sequence.
Routing builds and updates these directions. Forwarding uses them for the packet that has just arrived. If no entry matches and there's no usable default route, the router can't send the packet onward.
Why packets have a travel limit
Directions can go wrong. In a routing loop, routers pass a packet around instead of getting it to the destination. Without a limit, that packet could keep consuming resources on a trip going nowhere.
IPv4 gives each packet a value called time to live, or TTL. Routers reduce the value as they forward the packet. When it runs out, the packet is discarded.
How Routers Learn the Way on Their Own
A home router may change the address, too
Our laptop's journey can involve another job at the same device. A home network sharing one public IP address uses network address translation, or NAT, to change addresses as traffic passes through.
For example, the laptop may send its packet with a private source address used inside the home. The router replaces that address with the shared public address before sending it toward the internet. The shared-address form also translates port numbers, which help separate one network conversation from another. Records of these changes let the router direct the reply back to the laptop.
Translation keeps track of which addresses and ports to substitute. Forwarding moves the packet along. The technical description of NAT explains the separate translation work.
- Start tonight: the board, case, power supply and memory card are all in the box.
- Run a home lab, an ad blocker or a practice server on one small computer.
- Learn Linux hands-on without risking your main machine.
When a computer becomes a way through
A general-purpose computer can forward traffic, too. Linux has an ip_forward setting that lets packets pass between its network interfaces. The Linux documentation notes that changing this setting also resets other network settings to their host or router defaults, so it deserves more care than a casual troubleshooting switch.
Once forwarding is enabled, other devices can use that computer as a way through to another network, provided the necessary routes exist. Packet filters and firewalls can control which traffic is allowed to cross. Forwarding itself doesn't encrypt the traffic or establish that its sender is trustworthy.
That switch changes the computer's job: it can now carry traffic for someone else. The routes and access rules need to suit that job.
What Does a Router Do? Follow a Packet to Its Next Stop

Static Routing: A Written Instruction for the Next Hop

Time to Live: Why Packet TTL and DNS TTL Count Different Things

QUOTE:
"Amateurs hack systems, professionals hack people."

