Routing Protocols and Configuration Questions
How traffic finds its path across networks: route selection basics (administrative distance, longest-prefix match, control plane versus forwarding plane), static and default routing, interior gateway protocols (OSPF, IS-IS, EIGRP, RIP), BGP, and multicast routing. Covers protocol selection and migration, OSPF area and IS-IS level design, EIGRP feasible successors, BGP path selection, communities, route reflectors and policy, route redistribution, summarization and filtering, VRF-Lite and VRF route leaking, convergence tuning with BFD, ECMP path selection, BGP-based inbound and outbound traffic engineering, multi-homed internet edge and full-table scale, RPKI origin validation and containing route leaks, route flap and oscillation analysis, graceful maintenance drains, first-hop gateway redundancy (HSRP, VRRP, GLBP), and verifying and troubleshooting routing on real devices. Excludes network-wide topology and MPLS or segment-routing backbone design, Layer 2 switching and VLANs, general layered fault isolation and packet capture, cloud VPC routing, and firewall or ACL security.
Why do iBGP networks use route reflectors and how do they work? Cover client versus non-client behavior, loop prevention and the problems they can introduce.
Sample Answer
Direct answer
iBGP routers do not re-advertise routes learned from one iBGP peer to another iBGP peer (RFC 4271 section 9.2), so without help every router needs a session with every other. A route reflector (RR) is allowed to break that rule, so routers connect only to the reflector. Clients send their routes to the RR, which reflects them to other clients and non-clients. It scales but adds path-hiding, suboptimal-routing and loop risks you must design for.
Why they exist (computed)
A full mesh of n routers needs n(n-1)/2 sessions. With reflectors:
| Routers | Full mesh sessions | 2 RRs + clients (each client peers with both RRs, plus 1 RR-to-RR session) |
|---|---|---|
| 20 | 190 | 18 x 2 + 1 = 37 |
| 100 | 4,950 | 98 x 2 + 1 = 197 |
How reflection works (RFC 4456)
- A client is an iBGP peer that you tell the RR to reflect routes to and from (on Cisco, with
neighbor <ip> route-reflector-client). It needs a session only with its RR, not with other clients. A non-client is an ordinary iBGP peer of the RR that follows the normal iBGP rules. An RR together with its clients forms a cluster, and each cluster has a CLUSTER_ID (a 4-byte identifier). - A route from a non-client is reflected to all clients. A route from a client is reflected to all non-clients and also to the other clients. The non-client peers themselves must be fully meshed, but clients need not be.
- An RR advertises only its best path per prefix, not all paths.
- It should not modify NEXT_HOP (the address to forward traffic to), AS_PATH (the list of ASNs the route crossed), LOCAL_PREF (the preference shared inside the AS) or MED (a hint from a neighbouring AS about its preferred entry point), so clients still need IGP reachability to the real next hop.
Loop prevention
Two attributes replace the "no iBGP to iBGP" rule:
- ORIGINATOR_ID carries the BGP identifier of the route's originator in the AS. A router that sees its own ID ignores the route.
- CLUSTER_LIST records the reflection path. Each RR prepends its CLUSTER_ID, and an RR that finds its own CLUSTER_ID in the list ignores the route. Route selection also prefers the shorter CLUSTER_LIST.
Redundant RRs in one cluster share a CLUSTER_ID so that an RR discards routes from the other RRs in the same cluster.
Problems and mitigations
The first two rows follow directly from reflecting only a best path, so they come with every RR design. The others come from specific design choices.
| Problem | Why it happens | Mitigation |
|---|---|---|
| Path hiding (visibility) | the RR reflects only its best path, so clients see one path per prefix and cannot load-balance or fail over quickly | Cisco best-external (advertise the best external path even when an internal one is best) or BGP Additional Paths (RFC 7911: several paths per prefix, each with a Path Identifier) |
| Suboptimal routing | the RR picks the best path from its own IGP view, which may differ from the client's | place RRs in the topology and keep the reflection topology congruent with the physical one (RFC 4456 recommendation) |
| Single point of failure | one RR | at least two RRs per cluster, same CLUSTER_ID |
| Loops and oscillations (routers keep switching their best path and never settle) | bad RR topology, inconsistent clients | follow a hierarchy (clients, then RRs, then a meshed top level) and keep IGP costs consistent |
| Next hop unreachable | RR does not change next hop | carry next hops in the IGP |
Worked example
Names are illustrative. A 20-router network has two RRs, RR1 and RR2, sharing one CLUSTER_ID, and 18 clients including C1, C2 and C3. Every client peers with both RRs, and RR1 and RR2 peer with each other: 18 x 2 + 1 = 37 sessions instead of 190.
Client route: C1 learns an external route and sends it to RR1 and RR2. RR1 selects its best path and, because the route came from a client, reflects it to all other clients (C2, C3 and the rest) and to its non-client peers. It adds ORIGINATOR_ID = C1's ID and CLUSTER_LIST = its CLUSTER_ID. C2 can now use the route without any session to C1. The copy RR1 sends to RR2 carries the shared CLUSTER_ID, so RR2 finds its own ID in the list and discards it, and still has C1's own advertisement. If a copy ever reached C1, C1 would ignore it because ORIGINATOR_ID is its own.
Non-client route: now suppose a 21st router N1, outside the 20-router example above, is a non-client peer of RR1 and advertises a route to it. RR1 reflects it only to its clients (C1 to C18), not to other non-clients (RR2 included). N1 must therefore be fully meshed with the other non-clients itself, which is why the non-client side of a design stays small.
Pitfalls
- If the client-to-RR design differs from the physical topology, forwarding loops are possible.
- Clients do not see all paths, so a failure needs the RR to re-run best-path selection before the client recovers.
Two Cisco routers are the default gateways for a user subnet, with virtual IP 10.50.0.1. Configure HSRP so Router1 is preferred and takes back the role after recovering. What role transitions occur when Router1 fails and returns?
Sample Answer
Direct answer
HSRP (Hot Standby Router Protocol) lets two routers share one virtual gateway address, 10.50.0.1, with one router Active (forwarding) and one Standby (ready to take over). To make Router1 preferred and to make it reclaim the role after it recovers, give it a higher priority than Router2 and enable preempt on it. On failure, Router2 goes Standby to Active; on recovery, Router1 goes through Init, Listen and Speak and then takes Active back (with the 60 second preempt delay configured below it normally waits as Standby first), and Router2 returns to Standby.
Configuration
Router1 (preferred):
interface GigabitEthernet0/0/0
ip address 10.50.0.2 255.255.255.0
standby 1 ip 10.50.0.1
standby 1 priority 110
standby 1 preempt delay minimum 60
Router2 (default priority):
interface GigabitEthernet0/0/0
ip address 10.50.0.3 255.255.255.0
standby 1 ip 10.50.0.1
standby 1 preempt
- Priority range is 1 to 255 and the default is 100, so 110 beats Router2's 100.
preemptmakes a router with a higher priority than the current Active take over. Preempt is not implied by a higher priority alone: it has to be configured.delay minimum 60makes Router1 wait 60 seconds before taking over the Active role, so routing and switching have time to settle after a reboot. The delay range is 0 to 3600 seconds and the default is 0.- Hosts use 10.50.0.1 as default gateway. With HSRP version 1, group 1 uses virtual MAC 0000.0C07.AC01 (the Layer 2 address that goes with the virtual IP), and the new Active router takes over that same MAC, so the ARP entry hosts cache (their IP-to-MAC mapping) stays valid through a failover.
- Router2 also gets
preemptso the pair behaves symmetrically: if Router1 is Active but its priority later falls below 100 (for example through tracking, covered in the pitfalls), Router2 can only take the role from it if Router2 has preempt configured. - Defaults: hello 3 seconds, hold time 10 seconds.
Role transitions
HSRP states are Init, Learn, Listen, Speak, Standby and Active.
| Event | Router1 | Router2 |
|---|---|---|
| Both up, stable | Active | Standby |
| Router1 loses power at t=0 | down | no hellos from Router1 for the 10 s hold time, then Standby to Active (takes 10.50.0.1 and the virtual MAC) |
| Router1 shut down cleanly | sends a Resign message | takes over immediately, without waiting for the hold time |
| Router1 boots | Init, then Listen (hears Router2's hellos), then Speak, then Standby once no Standby hello has been heard for the hold time (the RFC 2281 Standby timer expires) | Active, keeps forwarding |
| Preempt delay (60 s) expires, Router1 has priority 110 against 100 | sends a Coup message and becomes Active | on the Coup (or an Active hello from a higher priority router) moves to Speak and sends a Resign, then settles into Standby |
| Stable again | Active | Standby |
What the messages mean (RFC 2281): a Hello says the router is running and can become Active or Standby, a Coup says it wants to become Active, and a Resign says it no longer wants to be Active. Speak is the state where a router sends hellos and takes part in electing Active and Standby. A router that has not yet learned the virtual IP waits in Learn; here the address is configured, so Router1 goes straight from Init to Listen.
Timing of the failure case: Router2 declares Router1 dead 10 seconds after the last hello it received. Hellos arrive every 3 seconds, and Router1 can fail anywhere in that interval, so takeover happens between 7 and 10 seconds after the failure. If you need faster takeover, shorten hello and hold times (Cisco's command reference allows millisecond hello timers from 15 to 999 ms and recommends hold times under 250 ms only on Cisco 7200-class or better platforms and on Fast Ethernet or faster interfaces).
Verification
show standby brief on both routers. Expected stable output on Router1: group 1, priority 110, state Active, virtual IP 10.50.0.1. show standby gives the long form, including Preemption enabled and the Active virtual MAC address. After failing Router1, Router2's state should read Active. Test by pinging 10.50.0.1 from a host during the event.
Pitfalls
- Forgetting
preempton Router1: when it returns it stays Standby and Router2 keeps the Active role indefinitely, which is the opposite of what was asked. - Preempt with no delay: Router1 can become Active before its uplink routing is ready, black-holing traffic (accepting packets it cannot forward, so they vanish). Tracking an object that follows the uplink (
standby 1 track <object> decrement 20, which lowers the priority by 20 while the tracked object is down, taking 110 to 90, below Router2's 100) makes it give up Active when its uplink fails. - HSRP watches the interface it runs on, not the path beyond it; without tracking, hosts keep sending to an Active router that has lost its uplink.
You must migrate a large network from one IGP to another (for example an old RIP network, or OSPF to IS-IS) with minimal disruption. Outline the plan: how both run side by side, how metrics map, the cutover sequence, testing and rollback.
Sample Answer
Direct answer. Run the new IGP (interior gateway protocol, the routing protocol inside one organization) next to the old one on the same links, with the new one deliberately losing in the routing table until you choose to flip it. Router by router, then site by site, you move the preference, watch, and keep the old protocol running as a one-line rollback until a soak period (a fixed observation time with no further changes) ends. Only then do you remove it. The same method covers RIP (Routing Information Protocol) to OSPF (Open Shortest Path First), RIP to EIGRP (Enhanced Interior Gateway Routing Protocol), and OSPF to IS-IS (Intermediate System to Intermediate System).
How two protocols coexist: administrative distance
Each protocol builds its own database and offers routes to the routing table. When two protocols offer the same prefix, the lower administrative distance (AD, a trust ranking) wins. Cisco defaults: EIGRP internal 90, OSPF 110, IS-IS 115, RIP 120, EIGRP external 170. That drives the plan:
- RIP to OSPF or EIGRP: both have a lower AD than RIP (110 and 90 against 120), so the new protocol wins the moment it learns a route. Raise the new protocol's AD first so RIP keeps winning during staging; for OSPF, Cisco's form is
distance ospf intra-area 130, with theinter-areaandexternalkeywords given matching values. - OSPF to IS-IS: OSPF (110) beats IS-IS (115) by default, so IS-IS starts out as the silent backup. Cutover is lowering IS-IS's distance below OSPF's with
distance 100underrouter isis(Cisco's generic form,distance <AD-value>under a routing process, changes that process's distance; check the optional keywords your release offers with?), and rollback is removing that line.
Metric mapping
RIP counts hops, with 16 meaning unreachable and 15 the longest usable path (RFC 2453). OSPF and IS-IS use link costs. They rank paths differently, so a straight swap can change real traffic paths. Choose deliberately, in this order:
- List the paths that matter (data center to each site, site to site, any intentionally preferred backup).
- Set the new protocol's link costs so that these paths come out the same as before. OSPF
ip ospf costsets a link's cost explicitly; for OSPF setauto-cost reference-bandwidthto the same value on every router (default 100 Mbps). For IS-IS enablemetric-style widefirst. - Worked case (illustrative): a site reaches the data center either over one hop on a 2 Mbps link or over two hops on 1 Gbps links. RIP picks the one-hop path. With
auto-cost reference-bandwidth 100000OSPF costs are 100000 / 2 = 50,000 for the slow link and 100000 / 1000 = 100 per fast link, so 2 x 100 = 200 for the two-hop path, and OSPF would switch traffic to the fast path. To keep the old path you would setip ospf coston the slow link below 200; to take the better path you leave the computed costs alone and record the change. - Where RIP's hop count picked a worse path than cost would (a one-hop slow link beating a two-hop fast pair), decide whether to keep the old behavior or fix it, and write it down as an intended change.
During partial migration, where some sites are still on the old protocol, a border router redistributes between them, meaning it copies routes learned from one protocol into the other. Route-map the redistribution (a route-map is an ordered rule list that matches routes and permits, denies or changes them) and tag it (a tag is a number attached to a route as a label):
router ospf 1
redistribute rip subnets metric 100 route-map RIP-TO-OSPF
router rip
version 2
redistribute ospf 1 metric 5 route-map OSPF-TO-RIP
!
route-map RIP-TO-OSPF deny 10
match tag 200
route-map RIP-TO-OSPF permit 20
set tag 100
route-map OSPF-TO-RIP deny 10
match tag 100
route-map OSPF-TO-RIP permit 20
set tag 200
Line by line: the redistribute rip subnets metric 100 route-map RIP-TO-OSPF line copies RIP routes into OSPF with a seed metric of 100 (the starting metric given to routes copied into the new protocol), passing each through the route-map; in RIP-TO-OSPF, sequence 10 denies anything tagged 200 and sequence 20 permits everything else and tags it 100; the RIP side repeats this with seed metric 5 and the tags swapped. Routes that came from RIP get tag 100 as they enter OSPF, and OSPF-to-RIP redistribution denies tag 100, so they never return; the reverse holds for tag 200. This stops the loop that appears when two border routers redistribute both ways. The seed metric into RIP must be 15 or less (5 here), because 16 is infinity. The tags only work if they travel inside RIP updates: the route tag field is defined by RIP version 2 (RFC 2453 section 4.2) and a RIPv1 message has only a must-be-zero field in that place, so a RIPv1 network cannot carry the tags and must be moved to version 2 first, or the loop guard has to be done differently (for example with prefix lists at the border). Hold redistribution to the border routers and remove it when the last site moves.
Phases (the 200-router RIP case)
Take 200 routers moving from RIP to OSPF.
- Design. Inventory every router's RIP configuration: network statements, passive interfaces, static routes redistributed, summaries, route filters. Define the OSPF target: area plan (a single area may suffice for 200 routers, or a backbone plus regions), router IDs, link costs from the mapping above, summarization points, authentication. Write the success criteria (every prefix in the old tables is reachable, same next-hop path for the listed critical flows) and the rollback trigger (for example, any critical prefix missing for more than 5 minutes).
- Staging. Rebuild a representative slice in a lab or virtual topology (one site of each type, the data center, the WAN edge). Run the exact configs and the cutover and rollback commands. Capture
show ip routebefore and after for comparison. - Pilot. Enable OSPF on every router of one low-risk site and its upstream with the raised distance (130), so RIP still carries traffic. Check
show ip ospf neighbor(every adjacency FULL) andshow ip ospf database(every router and prefix present). Then flip only the pilot site's distance below RIP, run a full business cycle, and compare route tables and application tests with the staged expectations. - Cutover. In waves of about 20 routers (10 waves for 200), lower OSPF's distance below 120 per wave, validating after each wave with the same checks plus a traceroute set. The change per router is one line and can be pushed by a change tool. Keep RIP configured and running.
- Rollback. At any point, raise OSPF's distance back to 130 on the affected routers: RIP, still running, immediately has the best route again. Because both protocols stayed up, rollback needs no rebuild.
- Decommission. After a soak period with no rollbacks, remove redistribution, then remove RIP router by router (
no router rip), then remove the raised-distance lines, and update monitoring and documentation.
The same sequence applies to OSPF to IS-IS: enable IS-IS on every link while OSPF (distance 110) still wins over IS-IS (115), set the IS-IS link metrics (with metric-style wide) so the critical paths come out as they do under OSPF, check that the IS-IS table holds the same prefixes with the same next hops, then lower IS-IS's distance with distance 100 wave by wave, with rollback being removal of that line.
Testing checklist for each wave
- Adjacencies at expected count; LSDB prefix count equals the inventory.
- Compare route tables before and after: same prefixes, same exit interface for the critical list.
- Failure test on the pilot: shut one link and verify convergence and that RIP's backup role works.
- Monitor for the first full business day, including batch jobs.
Pitfalls
- Leaving the new protocol at its default distance: RIP-to-OSPF flips routing on every router the moment its first OSPF adjacency forms, with no staging.
- Redistributing both ways at two places without tags: it creates a loop that looks like random reachability loss.
- Mismatched OSPF reference bandwidth between routers, so the same path has different costs depending on who computes it.
- Removing the old protocol on the same day as cutover: it removes the rollback.
On a Cisco IOS router, configure a static route to 192.168.10.0/24 via 10.0.0.2 and a default route toward your ISP at 10.0.0.1. How do you verify both are installed and working, and how would you add a backup default route that only takes over when the primary next-hop disappears?
Sample Answer
Direct answer
A static route is one ip route line: destination, mask, next hop. The default route is the same line with 0.0.0.0 0.0.0.0. Verify with show ip route, and test with ping and traceroute. A backup default route toward your ISP (internet service provider) is a second default with a higher administrative distance (AD, the trust ranking between route sources), called a floating static route. By itself it only takes over when the primary is removed from the routing table, which does not happen when a next hop on Ethernet simply stops answering. Tie the primary to an IP SLA probe (a router-generated ping using ICMP, the protocol behind ping) with track so it disappears when the ISP gateway stops answering. A track object is a small named flag inside the router that is Up or Down according to the probe result, and a static route that carries track 1 is installed only while that flag is Up.
Configuration (Cisco IOS)
ip route 192.168.10.0 255.255.255.0 10.0.0.2
!
ip sla 1
icmp-echo 10.0.0.1
frequency 5
ip sla schedule 1 life forever start-time now
track 1 ip sla 1 reachability
!
ip route 0.0.0.0 0.0.0.0 GigabitEthernet0/0 10.0.0.1 track 1
ip route 0.0.0.0 0.0.0.0 GigabitEthernet0/1 10.0.1.1 250
- The first line sends traffic for 192.168.10.0/24 to the internal router at 10.0.0.2 (AD 1 by default).
- The primary default goes to the ISP at 10.0.0.1 and is installed only while track object 1 is up. The
ip slaoperation pings 10.0.0.1 every 5 seconds forever, and the track object reports reachability. - Reading the probe lines:
ip sla 1creates probe number 1,icmp-echo 10.0.0.1makes it a ping to the ISP gateway, andfrequency 5repeats it every 5 seconds. A probe does nothing until it is scheduled:life foreverkeeps it running indefinitely andstart-time nowstarts it immediately.track 1 ip sla 1 reachabilitycreates track object 1, which is Up while probe 1 succeeds and Down when it fails. - The backup default goes to a second gateway (10.0.1.1 on another interface in this example) with AD 250. It sits idle because the primary has a lower AD (1).
- Naming both the outgoing interface and the next hop on each route avoids a static route whose next hop is resolved through some other route, which can keep a failed primary installed. Resolving through another route (a recursive lookup) means the router sees a next hop that is not on a directly connected network and looks that address up in the routing table again; if some other, broader route still covers it, the static route stays installed even though the real neighbor is gone.
- Choose a backup AD higher than every dynamic protocol you run (the highest default AD among dynamic protocols here are EIGRP external 170 and iBGP 200) and below 255, because 255 means unknown and is never installed. 250 satisfies both.
Verify
show ip route 192.168.10.0: the static route to the internal router, with next hop 10.0.0.2.show ip route static: the active default should readS* 0.0.0.0/0 [1/0] via 10.0.0.1, GigabitEthernet0/0. (show ip route 0.0.0.0prints the detailed form instead, with a line such asKnown via "static", distance 1, metric 0, candidate default path.) The*marks a candidate default, a route the router may use as its default route, and[1/0]is AD 1, metric 0. The Gateway of last resort line is the router's current choice of default next hop for destinations it has no specific route for, and it also names 10.0.0.1.show track: track 1 should say Up.show ip sla configurationshows how probe 1 is configured (target, frequency), so use it to confirm the probe settings, not the track state.ping 192.168.10.1andping <internet address>thentraceroute: first hops should match 10.0.0.2 and 10.0.0.1.
Prove the backup works
Make the ISP gateway stop answering without dropping your interface (for example, block ICMP from your router on the ISP-facing switch port, or shut the far-end port behind a switch). Then show track should change to Down, and show ip route static should show S* 0.0.0.0/0 [250/0] via 10.0.1.1, GigabitEthernet0/1. Restore it: track returns Up and the route reverts to the primary.
Why the tracking is needed
A floating static route is installed only when the primary is gone from the routing table. A static route with a next hop stays installed as long as the router still has a route to that next hop. With an Ethernet link through a switch, the interface stays up when the ISP router dies, so the primary stays and the backup never installs. Tracking removes the primary when the probe fails.
Trade-offs and pitfalls
- Pinging only the ISP gateway proves the first hop. A more representative target is a stable address inside the ISP network, pinned with its own /32 static route through the primary link so the probe cannot escape through the backup.
- Probing a single remote host that is often down creates false failovers, so pick a stable target.
- Flapping tracking can bounce the default route. Test the probe frequency and failure handling before deploying.
- The static route to 192.168.10.0/24 has no tracking, so a dead 10.0.0.2 stays in the table. Track it too if that matters.
A router receives the same prefix from several BGP neighbors. How does it choose the single best path, in what order are the criteria checked, and how would you check which rule decided on a real device?
Sample Answer
Direct answer
BGP picks one best path by walking a fixed list of tie-breakers and stopping at the first one that leaves a single winner. On Cisco IOS the order is: 1 highest weight (Cisco-originated and local to the router; it is not in RFC 4271, and some other implementations such as FRRouting also offer it), 2 highest LOCAL_PREF (default 100), 3 locally originated paths (network, aggregate or redistributed), 4 shortest AS_PATH, 5 lowest origin type (IGP, then EGP, then incomplete), 6 lowest MED (multi-exit discriminator), compared only between paths from the same neighbouring AS, 7 eBGP over iBGP, 8 lowest IGP metric to the next hop, 9 multipath determination, 10 oldest path when both are external, 11 lowest router ID, 12 shortest cluster list (route reflector environments), 13 lowest neighbour address. On a real device you check the deciding rule with show ip bgp <prefix> best-path-reason.
You do not need to hold all 13 at equal weight. Steps 1 to 2 are what you set on your own router, steps 4 to 6 are what the neighbours supplied, and steps 7 and 8 reflect the topology, so policy, AS_PATH length, MED and IGP metric are the ones you reason about when you design or debug. Steps 9 to 13 only matter when everything before them is equal.
RFC 4271's tie-break list is shorter: LOCAL_PREF, AS_PATH length, ORIGIN, MED, eBGP over iBGP, IGP cost to the next hop, then lowest BGP Identifier and lowest peer address. Weight is a vendor feature, the oldest-path step is an extension (RFC 5004) and the cluster-list step comes from route reflection (RFC 4456).
What each step is for
- Weight and LOCAL_PREF are policy you set. Weight stays on one router, LOCAL_PREF is shared inside the AS.
- Locally originated prefers a route your own router created over one heard from neighbours.
- AS_PATH, origin and MED are attributes the neighbours supplied. A shorter path is a proxy for a shorter route, and MED lets a neighbouring AS say which of its entry points it prefers. ORIGIN records how the prefix first entered BGP (RFC 4271): IGP means the prefix is interior to the originating AS, EGP means it was learned via the old EGP protocol, and incomplete means it was learned some other way. Lower wins, in the order IGP, EGP, incomplete.
- eBGP over iBGP and IGP metric push traffic out of the AS the closest way (hot-potato routing: hand traffic to the neighbour as early as possible).
- Multipath allows more than one path to be installed when they tie on the earlier steps. By default Cisco's value is 1, so one path.
- Oldest, router ID, neighbour address are final tie-breakers. Oldest path is used to avoid flapping between equal external paths. Router ID and address make the result deterministic. A route reflector adds ORIGINATOR_ID and CLUSTER_LIST, and the shorter CLUSTER_LIST (the list of route reflectors the route has passed through) is preferred.
Worked example
Router R1 hears 198.51.100.0/24 from three neighbours (illustrative, no weight set, LOCAL_PREF at its default of 100):
| Path | Neighbour | AS_PATH | Origin | Type |
|---|---|---|---|---|
| A | 192.0.2.1 | 65010 65020 | IGP | eBGP |
| B | 192.0.2.5 | 65011 | incomplete | eBGP |
| C | 10.255.0.3 | 65012 65020 65030 | IGP | iBGP |
| Weight and LOCAL_PREF tie and none is locally originated, so step 4 decides: B has an AS_PATH length of 1, A has 2, C has 3. B wins at step 4, even though its origin is the worst, because origin (step 5) is never reached. |
Change the inputs and the deciding step moves:
| Scenario | What is compared | Winner and deciding step |
|---|---|---|
| B is withdrawn | A has length 2, C has length 3 | A, step 4 (shortest AS_PATH) |
| B is also withdrawn, and A and C both have length 2 and origin IGP | MED is skipped because A comes via AS 65010 and C via AS 65012, different neighbouring ASes. A is eBGP and C is iBGP | A, step 7 (eBGP over iBGP), so the IGP cost to the next hop is never consulted |
| A and a second eBGP path A2 tie on every step through 8, multipath off | Both are external, so the age of the path is compared | The path received first, step 10 (oldest). If both arrived together, the lower router ID wins at step 11 |
How to check the deciding rule on a device
show ip bgp 198.51.100.0 best-path-reason adds a Best Path Evaluation: line to each path in the entry, naming why that path lost or won. Plain show ip bgp 198.51.100.0 shows the paths without the reasons. This is a trimmed copy of the example in Cisco's command reference (the addresses are Cisco's, not ours):
Device# show ip bgp 192.168.3.0 best-path-reason
BGP routing table entry for 192.168.3.0/24, version 72
Paths: (2 available, best #2, table default)
10.0.101.1 from 10.0.101.1 (10.0.101.1)
Origin IGP, localpref 100, valid, external
Best Path Evaluation: Path is younger
10.0.96.254 from 10.0.96.254 (10.0.96.254)
Origin IGP, localpref 100, valid, external, best
Best Path Evaluation: Overall best path
Read it from the top. Paths: (2 available, best #2 ...) says two paths exist and the second one listed is the winner, which the word best on its attribute line also marks. Each path's Origin IGP, localpref 100, ... external line shows the attributes the steps compare, here identical on both paths. The line under the loser says Path is younger: it lost the oldest-path step (step 10) because the winner was received earlier. The line under the winner says Overall best path. If a loser instead shows an AS_PATH or MED reason, that step decided, and you map it back to the 13-step list above.
Pitfalls
- MED is only comparable between paths from the same neighbouring AS, so it does not rank paths across different ISPs.
- Weight is not part of RFC 4271 and not every vendor implements it, so a policy built on it may not carry to other vendors.
- Oldest-path makes the result depend on arrival order, so the same table can pick differently after a restart.
Unlock Full Question Bank
Get access to all Routing Protocols and Configuration interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.