Routing Protocols (RIP, OSPF, BGP)

RIP, OSPF and BGP are routing protocols that decide how packets are forwarded across networks. RIP is a distance vector protocol limited to 15 hops, OSPF is a link state protocol used inside a single organization's network, and BGP routes traffic between independent networks across the internet based on policy and business relationships.

4 min read

Routing protocols are the concrete, real-world implementations of routing algorithms, deployed on actual routers to decide how packets get forwarded. RIP, OSPF, and BGP each operate at a different scale and solve a different real problem.

RIP (Routing Information Protocol)

A distance vector protocol that uses hop count (the number of routers a packet passes through) as its only metric for choosing a route, and caps hop count at 15, treating anything requiring 16 or more hops as unreachable. This makes RIP simple to configure but limits it to small networks; it's rarely used in serious networks today, having largely been replaced by OSPF.

OSPF (Open Shortest Path First)

A link state protocol used widely within a single organization's network (an "interior gateway protocol"). Every router builds a complete map of the network and computes shortest paths using Dijkstra's algorithm, considering configurable link costs (which can reflect real bandwidth, not just hop count), and converges quickly after a change. OSPF is the standard choice for internal routing in mid-size to large enterprise and ISP networks today.

BGP (Border Gateway Protocol)

The protocol that runs the internet's backbone, deciding how traffic moves between different autonomous systems (large networks independently operated by ISPs, cloud providers, and large organizations). Rather than optimizing purely for shortest path, BGP routing decisions are heavily influenced by business relationships and policy (which provider peers with which, who pays whom for transit), not just technical distance. BGP is classified as an "exterior gateway protocol," specifically because it routes between separate organizations' networks rather than within one.

A worked example

A company's internal network, spanning its own offices and data centers, uses OSPF to route traffic efficiently between its own routers, since OSPF's fast convergence and cost-aware routing suit an environment the company fully controls. When that company's traffic needs to leave its own network and reach the wider internet (say, a user's request going out to a different company's website), it's handed off to the company's ISP, and from there, BGP takes over, deciding the path across the many independent autonomous systems that make up the rest of the internet, based on the peering and business relationships between those different networks.

Where this matters in real systems

Almost every large enterprise or ISP network runs OSPF (or a similar interior protocol) internally while relying on BGP for anything crossing into another organization's network, this internal-vs-external split is precisely why RIP, OSPF, and BGP coexist rather than one simply replacing the others: they're solving genuinely different problems at genuinely different scales. Real, widely reported internet outages have been caused by BGP misconfigurations, where one network mistakenly announced ownership of address ranges it didn't actually control, which is a direct consequence of BGP trusting the routing announcements it receives from other networks rather than independently verifying them.

What interviewers actually ask about RIP, OSPF, and BGP

  • "What kind of protocol is RIP, and what's its main limitation?" A distance vector protocol using hop count as its metric, limited to a maximum of 15 hops, making it unsuitable for large networks.
  • "Why is OSPF preferred over RIP in most modern networks?" OSPF is a link state protocol with faster convergence, more accurate cost-based routing (not just hop count), and no hop-count ceiling, all better suited to larger, more complex networks.
  • "What makes BGP different from OSPF?" BGP routes between separate organizations' networks (an exterior gateway protocol) and factors in business/policy relationships, not just technical shortest-path distance, while OSPF routes within a single organization's own network.
  • "Why can a BGP misconfiguration cause a real internet outage?" BGP largely trusts the route announcements it receives from other networks; if a network mistakenly (or maliciously) announces ownership of address ranges it doesn't control, other networks can end up routing traffic incorrectly.

Key takeaways

  • RIP is a simple, distance vector protocol limited to small networks by its 15-hop ceiling.
  • OSPF is a link state protocol used for fast, cost-aware routing within a single organization's network.
  • BGP routes traffic between independent networks across the internet, factoring in business relationships, not just technical distance.
  • Real internet infrastructure runs an interior protocol like OSPF internally and relies on BGP for anything crossing into other organizations' networks.
All 101 Computer Networks interview questions

Log in to save which topics you've read across every subject.

Frequently asked questions

What kind of protocol is RIP, and what's its main limitation?

A distance vector protocol using hop count as its metric, limited to a maximum of 15 hops, making it unsuitable for large networks.

Why is OSPF preferred over RIP in most modern networks?

OSPF is a link state protocol with faster convergence, more accurate cost-based routing (not just hop count), and no hop-count ceiling, all better suited to larger, more complex networks.

What makes BGP different from OSPF?

BGP routes between separate organizations' networks (an exterior gateway protocol) and factors in business/policy relationships, not just technical shortest-path distance, while OSPF routes within a single organization's own network.

Why can a BGP misconfiguration cause a real internet outage?

BGP largely trusts the route announcements it receives from other networks; if a network mistakenly (or maliciously) announces ownership of address ranges it doesn't control, other networks can end up routing traffic incorrectly.