When you open a website, your device sends packets into a system of local networks, routers, gateways, internet providers, and destination servers. The trip takes milliseconds, but several different mechanisms have to cooperate along the way. This guide follows one request from a laptop to a server and uses that journey to explain routing tables, gateways, NAT, routing protocols, and subnets.
Router: the next-hop decision maker
A router receives packets, reads their destination IP addresses, and chooses where to send them next. It rarely knows the complete physical path to the destination. It only needs a useful next hop.
That decision comes from a routing table. Each entry usually contains:
- A destination network, such as
192.168.1.0/24 - A next-hop address or outgoing interface
- A metric or preference used when multiple routes match
Routers compare the destination IP against the routes they know and select the most specific match. A home router may have only a few routes. Internet routers can handle huge tables and millions of packets every second.
Static and dynamic routes
Static routes are entered by an administrator and stay in place until someone changes them. They are predictable and useful in small or stable networks.
Dynamic routes are learned from routing protocols. They adapt when links fail, networks appear, or a better path becomes available. That flexibility costs memory, CPU time, and operational complexity, but it is essential for larger networks.
Gateway: the way out of a network
A gateway is a role played by a device or service at the boundary between systems. Your laptop's default gateway is the next device that receives traffic for destinations outside the local subnet. At home, that is normally the router.
The term can also describe a system that translates between protocols or application formats, such as an API gateway, email gateway, or voice gateway. This is why "router" and "gateway" overlap without meaning exactly the same thing.
| Router | Gateway |
|---|---|
| Primarily forwards IP packets between networks | Connects systems or networks at a boundary |
| Usually makes Layer 3 forwarding decisions | Can operate at several layers, depending on its job |
| Uses routes and next hops | May route, filter, proxy, or translate protocols |
| Often supports static and dynamic routing | May be hardware, software, or a cloud service |
A home router is usually several things in one box: router, default gateway, NAT device, DHCP server, Wi-Fi access point, and firewall.
How a request reaches a server
Assume a laptop at 192.168.1.24 opens a connection to a server at 203.0.113.42 on HTTPS port 443.
1. The device creates the packet
The operating system adds a source IP and source port, such as 192.168.1.24:53112, plus the destination 203.0.113.42:443. The port lets the device keep simultaneous connections separate.
2. The device chooses the default gateway
The laptop compares the destination with its own subnet. The server is not local, so the laptop sends the frame to the MAC address of its default gateway. The packet's destination IP still points to the remote server.
3. The home router applies NAT
Private IPv4 addresses such as 192.168.x.x are not routed across the public internet. The router replaces the private source address and port with its public address and a translated port, then records the mapping:
192.168.1.24:53112 -> 198.51.100.8:62001
This port-aware form is often called PAT or NAT overload. It allows many local devices to share one public IPv4 address.
4. The router makes a routing decision
The home router looks for the best route to 203.0.113.42. It usually finds no specific entry, so it uses a default route, written as 0.0.0.0/0, and forwards the packet to the ISP.
5. ISP and internet routers forward it
Each router repeats the same basic operation: inspect the destination, find the best matching route, and forward the packet to a next hop. The path may cross several networks before reaching the server.
6. The response finds the original device
The server sends its response to the router's public address and translated port. The home router finds the NAT mapping, restores 192.168.1.24:53112, and forwards the packet to the laptop.
The return path is often similar to the outbound path, but the internet does not guarantee perfect symmetry. Routing policies can send the response through different networks.
How routing tables are built
Real routing tables combine directly connected networks, manually configured routes, and routes learned from protocols.
RIP
Routing Information Protocol shares reachability information periodically and measures distance in hop count. It is simple, but its small hop limit and slow convergence make it unsuitable for large modern networks.
OSPF
Open Shortest Path First is a link-state protocol used inside an organization or autonomous system. Routers share information about links, build a topology map, and calculate shortest paths using configured costs.
BGP
Border Gateway Protocol exchanges routes between autonomous systems. It is policy-driven. Operators can prefer or reject paths based on business relationships, path attributes, and operational goals, so the selected route is not always the geographically shortest one.
EIGRP
Enhanced Interior Gateway Routing Protocol is commonly associated with Cisco environments. It considers metrics such as bandwidth and delay and is mainly used for routing within an organization.
Dynamic protocols let routers react to topology changes. Administrators can still filter routes, change preferences, or add static routes where precise control is required.
Subnets: dividing a network deliberately
Subnetting divides one address block into smaller networks. It helps conserve addresses, organize devices, limit broadcast domains, and enforce security boundaries.
In CIDR notation, the prefix length tells us how many bits identify the network. For example, /24 means the first 24 bits are the network portion and the remaining 8 bits identify addresses inside that network. Its dotted-decimal mask is 255.255.255.0.
To split 192.168.1.0/24 into four equal subnets, borrow two host bits:
| Subnet | Address range | Traditional usable host range | Broadcast |
|---|---|---|---|
192.168.1.0/26 | .0 to .63 | .1 to .62 | .63 |
192.168.1.64/26 | .64 to .127 | .65 to .126 | .127 |
192.168.1.128/26 | .128 to .191 | .129 to .190 | .191 |
192.168.1.192/26 | .192 to .255 | .193 to .254 | .255 |
Each /26 contains 64 addresses. In traditional IPv4 subnetting, the first address identifies the network and the last is the broadcast address, leaving 62 usable host addresses.
The general planning process is:
- Start with a base network and prefix.
- Decide how many subnets or host addresses are required.
- Borrow enough host bits to create those subnets.
- Calculate each new network boundary.
- Reserve the network and broadcast addresses where the IPv4 design requires them.
- Assign hosts and define routing and firewall policies between the subnets.
The mental model
Routers answer, "Which next hop gets this packet closer to its destination?" A default gateway answers, "Where should this device send traffic that is not local?" NAT keeps a translation table so private devices can share a public IPv4 address. Routing protocols keep network paths current, and subnetting gives the address space useful structure.
Once those responsibilities are separated, the internet feels less like a black box. It becomes a chain of small, repeatable decisions performed very quickly.