Routing Protocols Interview Questions: RIP, OSPF, BGP and Shortest Path Examples
Last updated 2026-11-19
Routing questions test whether you understand how routers decide where to send a packet and how they learn the network. Interviews ask you to compare distance vector with link state, explain the count-to-infinity problem, say why BGP exists on top of OSPF, and run Dijkstra or Bellman-Ford on a small graph. This page works both algorithms with a graph you can redraw, and the longest-prefix-match lookup that every router performs.
Addressing questions that feed into routing live on IP addressing and subnetting. For the layer context see OSI model interview questions, and for the overall subject computer networks interview questions. Study tips are in how to crack a computer networks interview.
| Algorithms | Bellman-Ford (distance vector), Dijkstra (link state) |
|---|---|
| Protocols | RIP, OSPF, EIGRP, IS-IS, BGP |
| Numericals | Dijkstra on a 6-node graph, distance-vector update, longest prefix match |
Typical administrative distances (Cisco defaults)
- Connected 0, static route 1, eBGP 20, EIGRP 90, OSPF 110, RIP 120, iBGP 200.
- When two protocols offer a route to the same prefix, the lower administrative distance wins. Within one protocol, the lower metric wins.
Routing Protocols Interview Questions: questions with worked answers
1 What is the difference between routing and forwarding?
easyRouting is the control-plane process of building the routing table, deciding paths using protocols such as OSPF and BGP. Forwarding is the data-plane action of looking at each arriving packet's destination, finding the matching route and sending it out the right interface, done in hardware at line rate. Routing runs rarely, forwarding for every packet.
2 Compare static and dynamic routing.
easyStatic routes are configured by hand: no protocol overhead, predictable and secure, suited to small networks and default routes, but they do not adapt to failures and become unmanageable at scale. Dynamic routing protocols exchange information so routers learn the topology and reroute automatically after a failure, at the cost of CPU and bandwidth for updates and more complex configuration.
3 Compare distance vector and link state routing.
mediumDistance vector routers (RIP, EIGRP) send their whole table of destination and distance to neighbours only, using Bellman-Ford; they know direction and distance but not the topology, converge slowly and can suffer count-to-infinity. Link state routers (OSPF, IS-IS) flood a description of their own links to all routers in the area, so each builds the same map and runs Dijkstra; this converges faster and loop-free but needs more memory and CPU.
4 Numerical: Run Dijkstra from A. Edges: A-B 7, A-C 9, A-F 14, B-C 10, B-D 15, C-D 11, C-F 2, D-E 6, E-F 9.
mediumStart with A = 0. Settle B = 7 and C = 9 (F tentative 14). Settle B (7): D tentative 7 + 15 = 22. Settle C (9): via C, F = 9 + 2 = 11 (better than 14), D = 9 + 11 = 20 (better than 22). Settle F (11): E = 11 + 9 = 20. Settle D (20) and E (20) with no improvements. Distances from A: B 7, C 9, F 11, D 20, E 20. Paths: A-B, A-C, A-C-F, A-C-D, A-C-F-E. The complexity is O((V + E) log V) with a priority queue.
textSettled Tentative distances after settling A (0) B7 C9 F14 B (7) C9 F14 D22 C (9) F11 D20 F (11) D20 E20 D (20) E20 E (20) done5 Numerical: Router A has neighbours B (cost 2) and C (cost 5). B advertises D = 5 and E = 7, C advertises D = 1 and E = 9. Compute A's table for D and E.
mediumBellman-Ford: cost(A to X) = min over neighbours of link cost + neighbour's advertised cost. To D: via B 2 + 5 = 7, via C 5 + 1 = 6, so 6 via C. To E: via B 2 + 7 = 9, via C 5 + 9 = 14, so 9 via B. A also learns B at 2 and C at 5 directly. If C later advertises D = 10 or the link to C fails, A recomputes and might switch to B with cost 7.
6 What is the count-to-infinity problem and how is it mitigated?
mediumWhen a link fails, distance vector routers may keep exchanging stale routes: A thinks B can reach a failed network at cost 2, B thinks A can, and each advertises an increasing cost back and forth until it reaches infinity, so routing loops form for a long time. Mitigations: define a small infinity (RIP uses 16, so the maximum usable hop count is 15), split horizon (do not advertise a route out the interface you learned it from), poison reverse (advertise it back with infinite cost), triggered updates and hold-down timers.
7 Describe RIP: metric, timers and limits.
mediumRIP is a distance vector protocol that uses hop count as its metric and treats 16 as unreachable, so networks can be at most 15 hops across. RIPv1 is classful and broadcasts; RIPv2 carries masks and multicasts to 224.0.0.9. Routers send their full table every 30 seconds, and a route is invalid after 180 seconds with no update. It is simple but converges slowly and ignores link bandwidth, so it is used only in small networks and labs.
8 How does OSPF work?
mediumOSPF is a link state protocol. Routers discover neighbours with Hello packets (multicast 224.0.0.5), form adjacencies, exchange link-state advertisements (LSAs) and each build an identical link-state database for their area. Each runs Dijkstra to compute the shortest path tree using cost as the metric, by default derived from interface bandwidth (reference bandwidth divided by link bandwidth, with 100 Mbps as the reference by default, so 100 Mbps links cost 1 and 10 Mbps cost 10). It converges quickly and supports VLSM.
9 What are OSPF areas and the DR and BDR?
mediumOSPF divides a large network into areas, all connected to the backbone, area 0, to limit the size of the database and flooding scope; area border routers summarise routes between areas. On a multi-access network such as Ethernet, routers elect a designated router (DR) and a backup (BDR) to which all others send updates, so adjacencies grow linearly (n to the DR) instead of as a full mesh of n(n-1)/2. Election is by highest priority, then highest router ID.
10 What is BGP and why is it used between organisations?
mediumThe Border Gateway Protocol is the path-vector protocol of the internet, exchanging reachability between autonomous systems (AS), each identified by an AS number. Routes carry the list of ASes they cross (the AS path), used for loop prevention, and routing is chosen by policy (local preference, AS path length, MED) rather than only by shortest metric, since commercial agreements decide who carries traffic. eBGP runs between ASes and iBGP inside one. It runs over TCP port 179 and is slow to converge by design.
11 Compare interior and exterior gateway protocols.
mediumInterior gateway protocols (RIP, OSPF, EIGRP, IS-IS) route inside one autonomous system under common administration and optimise for metrics such as speed and convergence. The exterior gateway protocol, BGP, routes between autonomous systems and optimises for policy and scalability, carrying about a million prefixes on the global table. A large enterprise often runs OSPF inside and BGP at its edge.
12 Numerical: A router has routes 10.0.0.0/8, 10.1.0.0/16, 10.1.2.0/24 and a default route 0.0.0.0/0. Where do packets to 10.1.2.5, 10.1.9.9, 10.9.9.9 and 8.8.8.8 go?
mediumThe router uses longest prefix match, the most specific route that matches. 10.1.2.5 matches /8, /16, /24 and the default, so the /24 wins. 10.1.9.9 matches /8 and /16 but not 10.1.2.0/24 (third octet 9), so the /16 wins. 10.9.9.9 matches only the /8 (and the default), so the /8 wins. 8.8.8.8 matches only the default route. Administrative distance only matters between different sources of the same prefix.
13 What is the role of TTL in an IP packet and what happens at 0?
mediumTTL (hop limit in IPv6) is an 8-bit counter that every router decrements. When it reaches 0 the router discards the packet and sends an ICMP time-exceeded message to the source. This stops packets looping forever during routing loops, and it is the mechanism traceroute uses to discover each hop. Typical starting values are 64, 128 or 255.
14 What is the difference between a router and a layer 3 switch?
hardBoth forward packets between IP subnets using routing tables. A traditional router has flexible interfaces (WAN, serial, cellular) and rich features such as NAT, VPN and complex policy, and forwards with specialised processors. A layer 3 switch has many Ethernet ports and forwards between VLANs in hardware at very high speed, so it is used for inter-VLAN routing inside campuses and data centres, but typically has fewer WAN and security features.
15 What is a routing loop and how do link state protocols avoid it?
hardA routing loop occurs when routers' tables send a packet around a cycle. It arises from inconsistent views during convergence, mostly in distance vector protocols. Link state protocols avoid it by giving every router the same complete database and computing a shortest-path tree, which is loop-free by construction once the databases are synchronised; transient loops can still occur briefly while LSAs are still propagating. BGP avoids loops by rejecting any route whose AS path already contains its own AS number.
16 What is Bellman-Ford's complexity and how does it compare with Dijkstra's?
hardBellman-Ford relaxes all E edges V - 1 times, giving O(V x E), but tolerates negative edge weights and detects negative cycles; in distance vector routing it runs in a distributed way, each router using only its neighbours' vectors. Dijkstra needs the whole graph and non-negative weights and runs in O((V + E) log V) with a heap. That is why link state protocols compute centrally on every router while distance vector spreads the computation. See also graph interview questions.
Frequently asked questions
Which routing protocol is best?
It depends: OSPF or IS-IS for large enterprise and provider interiors, EIGRP in Cisco-only networks, RIP only for tiny networks, BGP for internet edges and multi-homing, and static routes for stubs and defaults.
What is an autonomous system?
A collection of IP networks under one administrative control with a common routing policy, identified by an AS number (ASN), for example an ISP or a large company.
What is the difference between a routing table and a forwarding table?
The routing table holds all learned routes from all protocols. The forwarding table (FIB) is the optimised result of selecting the best routes, used by hardware to forward packets.
What is convergence?
The state in which all routers have consistent routing information after a change. Convergence time is how long that takes, and faster is better because traffic is dropped or looped meanwhile.
Related guides
- IP Addressing and Subnetting Interview Questions with Worked Solutions
- Computer Networks Interview Questions with Worked Answers and Numericals
- OSI Model Interview Questions: Layers, PDUs, Devices and Encapsulation
- TCP/IP Interview Questions: Handshake, Congestion Control and Numericals
- Network Security Interview Questions: Cryptography, Firewalls and Attacks
- Graph Interview Questions and Answers
More in CS Fundamentals Interview Questions
- SDLC and Agile Interview Questions
- Shell Scripting Interview Questions with Bash Examples
- SOLID Principles Interview Questions with Examples
- System Design Interview Questions for Freshers
- System Design Interview Questions with Worked Designs
- TCP vs UDP Interview Questions with Socket Code and Numericals
- TCP/IP Interview Questions: Handshake, Congestion Control and Numericals
- Transactions and ACID Interview Questions
- What Happens When You Type a URL in the Browser: The Complete Answer
- Abstraction and Encapsulation Interview Questions
- Cache Memory and Computer Organization Interview Questions with Numericals
- Caching Interview Questions and Answers