Explore plans starting at ₹699/mo →
Networking

How Routing Works Between Networks

S
ServerRaja
8 min read
#Infrastructure#Datacenter#Networking#Guide#BGP#Routing
How Routing Works Between Networks

Routing is the process of forwarding packets from a source network to a destination network. Every time you access a website, send an email, or transfer data, routers along the path make forwarding decisions that guide your packets to their destination.

Routing Tables

Every router (and every networked device) maintains a routing table: a list of known network destinations and how to reach them. Each entry contains: - Destination network (IP range) - Next hop (the next router to forward to) - Interface (the network port to send through) - Metric (a cost value for route selection)

When a packet arrives, the router looks up the destination IP in its routing table and forwards the packet to the appropriate next hop.

Longest Prefix Match

When multiple routing table entries match a destination IP address, the router uses the longest prefix match rule: the entry with the most specific match (longest subnet mask) wins.

For example, if the routing table contains both 10.0.0.0/8 and 10.0.1.0/24, a packet destined for 10.0.1.50 matches both entries. The /24 route is more specific and is chosen.

Static Routing

Static routes are manually configured entries in the routing table. They are simple and predictable but require manual updates when the network changes.

Static routing is appropriate for: - Simple network topologies - Default routes (send everything else to this gateway) - Stub networks with a single exit point

Dynamic Routing

Dynamic routing protocols allow routers to automatically exchange routing information and adapt to network changes.

BGP (Border Gateway Protocol)

BGP is the routing protocol of the internet. It exchanges routing information between autonomous systems (AS) networks operated by different organizations. BGP makes routing decisions based on path attributes, policies, and prefix length.

BGP is also used within large data center networks (iBGP) for routing between spine and leaf switches.

OSPF (Open Shortest Path First)

OSPF is an interior gateway protocol used within a single organization's network. It calculates the shortest path to each destination using link-state information.

How Internet Routing Works

When you access a website: 1. Your server sends the packet to its default gateway 2. The gateway router checks its routing table and forwards toward the destination 3. Each subsequent router repeats this process 4. BGP routing decisions guide traffic between different networks (autonomous systems) 5. Eventually, the packet reaches the destination network's edge router 6. The edge router forwards the packet to the destination server

This hop-by-hop routing process typically involves 5 to 20 routers and takes 1 to 100 milliseconds depending on geographic distance.

Routing in Cloud Infrastructure

Cloud platforms use software-defined networking to manage routing. When you create a virtual network, the platform automatically configures routing between your virtual machines, between your network and the internet, and between your cloud and on-premises networks.

Understanding routing helps you troubleshoot connectivity issues and design network architectures that meet your application requirements. ## Key Takeaways

  • Every router along a packet's path independently consults its own routing table to decide the next hop — there is no single end-to-end path pre-computed
  • Static routes work well for simple topologies and default gateways; dynamic protocols (BGP, OSPF) are essential for networks that change or scale
  • Internet routing relies on BGP to exchange reachability information between autonomous systems, typically spanning 5 to 20 hops between source and destination
  • Cloud platforms abstract routing with software-defined networking, but understanding the fundamentals helps you troubleshoot connectivity and design efficient architectures
How Routing Works Between Networks | ServerRaja