Routing protocols

How routers choose every path

Routing decides where every packet goes, and almost every outage I have fixed came down to one router choosing a path nobody expected. This page shows how a router decides, how OSPF, EIGRP and BGP work, and how I find the fault when a route goes missing.

  • Longest prefix match
  • Static and IP SLA
  • OSPF
  • EIGRP
  • BGP
  • Redistribution
  • VRF
  • Multicast
  • QoS
Routers sharing routes and forwarding on the best path Four routers share routing updates. Traffic from a branch to the data centre takes the lowest cost path through the core, while a slower backup path stands by. cost 10 cost 10 cost 100 cost 100 BranchOSPF area 1 Corearea 0 Backup4G router Data centreBGP edge lowest total cost wins
Live view · updates flow, traffic takes the cheapest path
How a router decides

The most specific route always wins first

Every forwarding decision follows the same order. First the longest prefix that matches the destination. If two sources offer the same prefix, the lower administrative distance. If one protocol offers two paths, the lower metric. Try it: pick a destination and watch the router choose.

Longest prefix match in a routing table A router has four routes: a default route to the internet, 10.0.0.0/8 to the WAN core, 10.1.0.0/16 to the data centre and 10.1.20.0/24 to a branch office. A packet for 10.1.20.15 matches all four, and the router sends it to the branch because /24 is the longest match. Routerlooks up the route Internet0.0.0.0/0 WAN core10.0.0.0/8 Data centre10.1.0.0/16 Branch office10.1.20.0/24 to 10.1.20.15

Swipe sideways to see the whole diagram.

Animation
PrefixLearned byADMatches?
10.1.20.0/24EIGRP90yes
10.1.0.0/16eBGP20yes
10.0.0.0/8OSPF110yes
0.0.0.0/0Static1yes

10.1.20.15 matches four routes. The longest is /24, so it goes to the branch office. The low AD (administrative distance) of the other routes does not matter, because they are different prefixes.

Administrative distance

When two protocols offer exactly the same prefix, the router trusts the one with the lower administrative distance (AD). These are Cisco's defaults. Juniper calls it route preference and uses different numbers: static 5, OSPF internal 10, BGP 170.

SourceADSourceAD
Connected interface0OSPF110
Static route1IS-IS115
EIGRP summary5RIP (Routing Information Protocol)120
External BGP (eBGP)20EIGRP external170
EIGRP internal90Internal BGP (iBGP)200
From routing protocols to the forwarding table Three protocols each offer a route to 10.1.20.0/24. The routing table keeps the one with the lowest administrative distance, EIGRP at 90. The route is copied into the forwarding table, with the next hop's MAC address already resolved, so packets are switched in hardware. If the EIGRP route is withdrawn, the OSPF route takes its place. EIGRPAD 90 OSPFAD 110 iBGPAD 200 Routing tableRIB: best per prefix Forwarding tableFIB and adjacencynext hop MAC ready installed: EIGRP, AD 90 installed: OSPF, AD 110 Next hopout of Gi0/0/2 switched in hardware Three offers for 10.1.20.0/24

Swipe sideways to see the whole diagram.

Step 1
  1. Each routing protocol keeps its own table and offers its best route for each prefix to the routing table. Here EIGRP, OSPF and iBGP all know 10.1.20.0/24.

  2. The routing table, the RIB (routing information base), keeps the offer with the lowest administrative distance. EIGRP at 90 wins. show ip route lists it with the AD and metric in brackets, such as [90/3072], and show ip route 10.1.20.0 spells out the distance and metric.

  3. The winner is copied into the FIB (forwarding information base) with the next hop's MAC (media access control) address already resolved. Cisco calls this CEF (Cisco Express Forwarding). Packets are switched in hardware without the CPU. show ip cef 10.1.20.15 detail shows the result.

  4. If EIGRP loses the route, the next best offer, OSPF at 110, is installed at once. The routes a protocol offers but does not win stay in its own table, ready.

Equal cost paths

When one protocol has several paths with the same metric, the router installs them all, up to maximum-paths: 4 by default for OSPF and EIGRP on IOS, 1 for BGP. CEF shares traffic per flow by hashing addresses, so packets in one flow stay in order.

Metric comes last

A metric only compares routes from the same protocol. OSPF uses cost, EIGRP a composite of bandwidth and delay, BGP its path attributes. Comparing an OSPF cost with an EIGRP metric means nothing.

Which protocol where

An IGP (interior gateway protocol) such as OSPF, IS-IS or EIGRP inside one network, for fast convergence. BGP at the edges: providers, the WAN (wide area network), cloud and data centre fabrics, where policy and scale matter more than speed.

Static routes

Simple routes that still notice a failure

A static route never changes by itself. It stays in the table as long as its next hop looks reachable, even if the path beyond has failed. On a branch with two links, I tie the primary route to a probe and keep a floating static as the backup.

Floating static failover with IP SLA tracking A branch router has a primary default route through its main circuit and a floating static default route with administrative distance 250 through a 4G backup. An IP SLA probe pings an address beyond the provider every five seconds. When the probes fail, the track goes down, the primary route is removed and the floating static takes over. When the probes succeed again, traffic moves back after a delay. Branch routertwo default routes Provider 4G Internetprobe target Default routes in the table S* 0.0.0.0/0 [1/0] via provider, track 10floating: [250/0] via 4G, standing by S* 0.0.0.0/0 [1/0] via provider, track 10probes failing, delay down 10 s S* 0.0.0.0/0 [250/0] via 4Gprimary removed: track 10 is down Probes succeed, primary in use Provider fails beyond the next hop Track down: floating static installed Traffic on 4G Probes back: return after 30 s

Swipe sideways to see the whole diagram.

Step 1
  1. The primary default route has distance 1 and is tied to track 10. The backup is a floating static: the same prefix with distance 250, so it stays out of the table while the primary is there. An IP SLA (service level agreement) probe pings an address beyond the provider every 5 seconds, sourced from the primary interface.

  2. The provider fails upstream, but the link to its router stays up. A plain static route would stay in the table and black hole traffic. The probes start to fail.

  3. After the down delay, track 10 goes down and the primary route is removed. The floating static, at distance 250, is now the best route and is installed.

  4. Traffic leaves through 4G. On a firewall or NAT (network address translation) edge, sessions may need to restart, because their source address has changed.

  5. When the probes succeed again, an up delay of 30 seconds stops the route flapping before traffic moves back. I also add a host route so the probe always uses the primary link.

The configuration

ip sla 10 with icmp-echo 203.0.113.10 source-interface Gi0/0/0 and frequency 5, started with ip sla schedule 10 life forever start-time now, then track 10 ip sla 10 reachability with delay down 10 up 30, then ip route 0.0.0.0 0.0.0.0 198.51.100.1 track 10 and the backup ip route 0.0.0.0 0.0.0.0 192.0.2.1 250.

Null0 routes

A static route to Null0 discards traffic. A summary pointing at Null0 stops loops when part of the summary is missing, and a static to Null0 plus a BGP network statement advertises a stable aggregate.

Next hop or interface

A static route through an Ethernet interface alone relies on proxy ARP (address resolution protocol), so I always give a next hop address. BFD (Bidirectional Forwarding Detection) can also watch a static route's next hop and remove it within a second.

OSPF

A map of the network on every router

OSPF (Open Shortest Path First) is a link state protocol. Every router in an area floods LSAs (link state advertisements) describing its links, so all of them hold the same database, and each runs the SPF (shortest path first) algorithm with itself at the root. Areas keep that flooding contained.

OSPF areas, router types and LSA flooding Area 0 is the backbone. Two area border routers join it to area 1 and area 2. An autonomous system boundary router in area 0 brings in external routes. Type 1 and 2 LSAs stay inside each area, type 3 summaries cross areas at the ABRs, and type 5 externals flood everywhere except stub areas and NSSAs. A stub area blocks type 4 and 5 and receives a default route instead. An NSSA allows a local external route as type 7, which the ABR converts to type 5. AREA 0 · BACKBONE AREA 1 AREA 2 AREA 2 · STUB AREA 2 · NSSA ASBRbrings in externals BGP or static ABR 1area 0 and 1 ABR 2area 0 and 2 Internalrouter Internalrouter Internalrouter Internalrouter NSSA ASBRlocal external Types 1 and 2 stay in the area Types 3, 4 and 5 arrive from ABR types 4 and 5 blocked default route as a type 3 LSA type 7 inside, type 5 at the ABR

Swipe sideways to see the whole diagram.

Areas and router types. Every area joins area 0, and traffic between areas crosses it. An ABR (area border router) sits in area 0 and another area, and summarises one into the other. An ASBR (autonomous system boundary router) brings in routes from outside OSPF. A change inside area 1 runs SPF only in area 1. Other areas just see a changed type 3 summary, or nothing at all if the ABR summarises.

Stub and totally stubby. A stub area blocks type 4 and type 5 LSAs, and its ABR sends a default route instead. A totally stubby area, a Cisco extension, also blocks type 3 summaries except that default. Routers in the area keep small tables and only need to know the way out. No ASBR may sit in a stub area.

NSSA. A not so stubby area blocks types 4 and 5 like a stub, but allows a local ASBR, for example a router redistributing a partner's static routes. Its routes travel as type 7 LSAs inside the area, and the ABR converts them to type 5 for everyone else. An NSSA gets no default route automatically: I add one with area 2 nssa default-information-originate, or use a totally NSSA with no-summary.

Animation
LSA typeNameSent byFloods toIn the routing table
1RouterEvery routerIts own areaO
2NetworkThe DR on a shared segmentIts own areaO
3SummaryABROther areasO IA (inter area)
4ASBR summaryABROther areas, to say where the ASBR isnot a route itself
5AS externalASBREvery area except stub and NSSA areasO E1 or O E2
6Group membershipMulticast OSPF, which was never widely usedNot supported by Cisconone
7NSSA externalASBR inside an NSSAThe NSSA only, converted to type 5 at the ABRO N1 or O N2

Cost and reference bandwidth

Cost is the reference bandwidth divided by the interface bandwidth. IOS defaults to 100 Mb/s, so 1, 10 and 100 Gb/s links all cost 1. I set auto-cost reference-bandwidth 100000 on every router, the same everywhere. NX-OS defaults to 40 Gb/s.

E1 and E2

E2, the default, keeps the cost set at the ASBR. E1 adds the internal cost to reach the ASBR, which picks the nearest exit when two ASBRs advertise the same route. OSPF always prefers intra area, then inter area, then E1, then E2, whatever the cost.

Summarising

OSPF summarises only at ABRs (area 1 range) and ASBRs (summary-address). The router adds a Null0 discard route for the summary. Two ABRs advertising the same summary can black hole traffic if one loses part of the range.

Filtering OSPF

Routers in one area must hold the same database, so OSPF filters only where it summarises. On an ABR, area 1 filter-list prefix BLOCK in stops chosen type 3 summaries entering area 1, and area 1 range ... not-advertise hides a range. A distribute-list prefix BLOCK in under the process is different: the LSAs still flood and stay in the database, and only this router's own routing table leaves them out.

Virtual links

Every area must touch area 0. When a new area can only reach the backbone through another area, area 1 virtual-link 2.2.2.2 on both ABRs builds a logical area 0 link through area 1, the transit area, which must not be a stub. It also repairs a backbone split in two. I treat it as a temporary fix and plan a real link to area 0.

Router ID

The router ID comes from the router-id command, else the highest loopback address, else the highest active interface address. It is fixed when the process starts. I always set it to a loopback. Duplicate router IDs cause strange, intermittent faults.

Default route into OSPF

default-information originate advertises a default only while the router has one itself, so it withdraws when the upstream fails. Adding always can black hole traffic. I tie the router's own default to tracking.

Faster failover and graceful drains

A link that stays up but stops forwarding waits out the 40 second dead timer, so I add BFD with ip ospf bfd, with bfd interval 300 min_rx 300 multiplier 3 set on the interface. SPF throttling (timers throttle spf) stops a flapping link causing constant recalculation. Before maintenance, max-metric router-lsa makes traffic route around the router first.

OSPF on NX-OS

feature ospf first, then a named process such as router ospf UNDERLAY. Interfaces join with ip router ospf UNDERLAY area 0.0.0.0, not network statements.

OSPF neighbours

From first hello to full adjacency

Two OSPF routers move through a fixed set of states before they share routes. When an adjacency will not form, the state it sticks in tells me where to look. OSPF runs over IP protocol 89, sending to 224.0.0.5 for all OSPF routers and 224.0.0.6 for the DR and BDR.

The OSPF neighbour states Two routers, R1 with router ID 1.1.1.1 and R2 with router ID 2.2.2.2, form an adjacency. They move from Down to Init when the first hello arrives, then to 2-Way when each sees itself in the other's hello. In ExStart R2 becomes master, and in Exchange they swap database descriptions. In Loading R1 requests and receives missing LSAs, and they reach Full when both databases match. R1router ID 1.1.1.1 R2router ID 2.2.2.2 Down Init 2-Way ExStart Exchange Loading Full no hellos heard yet hello from R1 arrives at R2 each lists the other: DR and BDR elected empty DBDs: R2 is master (higher ID) DBDs carry LSA headers and the MTU R1 sends an LSR, R2 replies with an LSU databases match, hellos every 10 s If it sticks here No hellos accepted: not in OSPF, passive, area, mask, timers, auth or stub differ, an ACL, or Layer 2 down. One way only: R1 never hears R2's hellos. An ACL in one direction, a one way link, or lost multicast. Normal between two routers that are neither DR nor BDR. On a point to point link, check the network type. Almost always an MTU mismatch. Then a duplicate router ID, or unicast blocked. Requested LSAs not arriving: MTU in the path, or a corrupt or rejected LSA. Full but a route is missing: check the database, filters and area types.

Swipe sideways to see the whole diagram.

Step 1
  1. No hello has been heard from the neighbour. On a broadcast link, hellos go every 10 seconds and the neighbour is dead after 40.

  2. R2 has received a hello from R1, but R1 does not yet list R2 in its hellos. To be accepted, the hellos must agree on area, subnet and mask, hello and dead timers, authentication and the stub flags.

  3. Each router sees its own router ID in the other's hello, so the link works both ways. On a shared segment, the DR (designated router) and BDR (backup DR) are elected here. Two routers that are neither stay in 2-Way, which is normal.

  4. The routers agree who leads the database exchange. The higher router ID becomes master. The DBD (database description) packets carry the interface MTU (maximum transmission unit), and a mismatch stalls here.

  5. Each router sends DBD packets listing the headers of every LSA it holds, so the other can see what it is missing.

  6. R1 sends an LSR (link state request) for the LSAs it lacks. R2 answers with an LSU (link state update), and R1 acknowledges it with an LSAck (link state acknowledgement).

  7. Both databases match. The routers run SPF, install routes and keep sending hellos. show ip ospf neighbor shows FULL/DR, FULL/BDR, or FULL/ - on a point to point link.

DR and BDR election

On a shared segment, every router would otherwise form a full adjacency with every other. Instead all routers go Full with the DR and BDR only. The highest priority wins, 1 by default and 0 for never, then the highest router ID. The election does not preempt, so a new router with a higher priority waits.

Network types

Broadcast elects a DR. Point to point does not, and forms the adjacency faster, so I set ip ospf network point-to-point on routed links between two switches. Non broadcast and point to multipoint networks use 30 and 120 second timers.

The MTU trap

When a new circuit or subinterface has a different MTU, the adjacency cycles through ExStart and Exchange while traffic falls back to the backup. debug ip ospf adj shows "Nbr ... has larger interface MTU" on the router with the smaller MTU. I fix the MTU and use ip ospf mtu-ignore only as a short, recorded workaround.

EIGRP and IS-IS

A backup path ready before it is needed

EIGRP (Enhanced Interior Gateway Routing Protocol) is Cisco's advanced distance vector protocol. Its DUAL algorithm (diffusing update algorithm) keeps a loop free backup route in its topology table, so it can switch over without asking anyone.

EIGRP successor and feasible successor Router A reaches a network through three neighbours. Through B the total distance is 20 and B reports 10, so B is the successor. Through C the total is 25 and C reports 15, which is less than 20, so C is a feasible successor. Through D the total is 30 and D reports 25, which is not less than 20, so D is not. When the link to B fails, A switches to C at once. When C also fails, the route goes active and A queries its neighbours before using D. Router Atopology table Breports 10 Creports 15 Dreports 25 Network N10.50.0.0/16 10105 Topology table for N via B: 20, reports 10successor via C: 25, reports 15feasible via D: 30, reports 25not feasible Traffic uses the successor, B Feasibility: reported 15 under 20 B lost: C takes over at once No feasible successor: go active

Swipe sideways to see the whole diagram.

Step 1
  1. A knows three ways to network N. The best total distance, the feasible distance, is 20 through B. B is the successor and its route is installed.

  2. A neighbour is a feasible successor if the distance it reports is lower than A's current feasible distance. C reports 15, under 20, so its path cannot loop back through A. D reports 25, so it might, and is not a feasible successor.

  3. When the link to B fails, A installs the path through C straight away. No queries are needed, which is why EIGRP converges so fast.

  4. If C fails too, there is no feasible successor. The route goes active and A queries its neighbours. When the replies arrive it installs the path through D. A query that never gets a reply leaves the route stuck in active, after 3 minutes by default.

EIGRP essentials

IP protocol 88, multicast 224.0.0.10, hellos every 5 seconds on fast links with a 15 second hold time. The classic metric uses the lowest bandwidth and the total delay along the path (K values K1 and K3). K values must match for neighbours to form. Summaries and stub routers limit how far queries travel.

Unequal cost sharing

EIGRP can share traffic over paths with different metrics. variance 2 installs any feasible successor whose metric is under twice the best, and traffic is split in proportion to the metrics. Only feasible successors qualify, so the extra paths are still loop free.

Stub routers

eigrp stub connected summary on a branch router tells its neighbours not to query it when a route goes active. Queries stop at the hub, which keeps convergence fast and stops a remote site causing stuck in active routes. A stub also never offers itself as a transit path between two hubs.

Named mode and wide metrics

Named mode puts everything under one place: router eigrp CAMPUS, then address-family ipv4 unicast autonomous-system 100, with per interface settings under af-interface. It uses wide 64 bit metrics, so 10 Gb/s, 40 Gb/s and 100 Gb/s links get different metrics instead of all looking the same.

IS-IS

IS-IS (Intermediate System to Intermediate System) is a link state protocol like OSPF, but it runs directly over Layer 2, not IP. Level 1 routes inside an area and Level 2 is the backbone. Its AD is 115. It runs many service provider cores and the hidden underlays of Cisco ACI (Application Centric Infrastructure), SD-Access and FabricPath.

Comparing the IGPs

OSPF is the open, multi vendor default inside an enterprise. EIGRP converges fast and is easy to run, but it is mainly found on Cisco estates. IS-IS scales well and is common in large fabrics. BGP joins all of them at the edges.

BGP

The protocol that joins networks to each other

BGP (Border Gateway Protocol) is a path vector protocol. It runs over TCP (Transmission Control Protocol) port 179, carries a list of autonomous systems (AS) with every route to stop loops, and lets me apply policy to every path. It carries the internet's table, about a million IPv4 routes, and the routes between my sites, providers and clouds.

How a BGP session comes up A router in AS 65010 peers with a provider in AS 64500. The session moves from Idle to Connect while TCP port 179 opens. If TCP fails it falls to Active and retries. Once TCP is up, each side sends an OPEN message in OpenSent, confirms with a KEEPALIVE in OpenConfirm, and in Established they exchange UPDATE messages carrying routes. My edgeAS 65010 ProviderAS 64500 ACL179 Idle Connect Active OpenSent OpenConfirm Established not trying yet, or held down after an error TCP SYN to port 179 TCP failed: retrying OPEN: AS, hold time, router ID, capabilities OPEN accepted, KEEPALIVE sent UPDATEs carry routes, keepalives every 60 s If it sticks here Idle: shut down, maximum prefix exceeded, no route to the neighbour, or backing off after an error. Active: TCP never completes. Wrong neighbour address, update source, multihop, ACL, firewall or MD5. A bad OPEN gets a NOTIFICATION: usually a wrong AS number, a bad router ID or a capability mismatch. Established but no routes: filters, missing network statements or an address family not activated.

Swipe sideways to see the whole diagram.

Step 1
  1. The session is not trying to connect: it is shut down, it exceeded its maximum prefix limit, it has no route to the neighbour, or it is waiting after an error. show ip bgp summary shows Idle (Admin) or Idle (PfxCt) for the first two.

  2. BGP opens a TCP connection to port 179. Neighbours are configured by hand on both sides, and the source address must match what the other side expects.

  3. Despite the name, Active means the TCP connection failed and BGP is retrying. A session stuck in Active almost always means TCP 179 is blocked or the addressing is wrong. telnet 192.0.2.1 179 /source-interface Loopback0 proves it quickly.

  4. TCP is up, and each side sends an OPEN message with its AS number, hold time, router ID and capabilities, such as the address families it supports. A bad OPEN, such as the wrong AS number, gets a NOTIFICATION and the session closes.

  5. The OPEN was accepted. Each side sends a KEEPALIVE, and the first KEEPALIVE received moves the session to Established.

  6. The routers exchange UPDATE messages carrying routes and their attributes. Keepalives go every 60 seconds and the hold time is 180 seconds by default on Cisco, so BFD is needed for fast failure detection.

eBGP, iBGP and how iBGP scales

Full mesh, route reflectors and confederations Inside one AS, iBGP routers do not pass on routes learned from another iBGP peer, so they need a full mesh: five routers need ten sessions. Route reflectors pass routes on to their clients, so each client needs only two sessions. A confederation splits the AS into sub ASes that peer with each other like eBGP but look like one AS from outside. 5 routers: 10 sessions 100 routers: 4,950 sessions Each client: 2 sessions SUB AS 65001 SUB AS 65002 AS 64512 from outside R1 External peersees AS 64512 RR 1reflector RR 2reflector R2 R3 R4 R5

Swipe sideways to see the whole diagram.

Full mesh. An iBGP router never passes a route learned from one iBGP peer to another. That is iBGP split horizon, and it prevents loops inside an AS. So every iBGP router must peer with every other: n(n−1)/2 sessions, which grows fast.

Route reflectors. A route reflector (RFC 4456) may pass routes to its clients. Each client peers with two reflectors for resilience. Two attributes, ORIGINATOR_ID and CLUSTER_LIST, stop reflected routes looping. A reflector passes on only its own best path, which can hide alternatives.

Confederation. The AS is split into sub ASes with private numbers. Inside each one, iBGP rules apply. Between them, sessions behave like eBGP for loop prevention but keep the next hop, local preference and MED (multi exit discriminator). From outside, the whole thing looks like one AS. It is common after mergers and in large providers.

Animation

eBGP and iBGP

eBGP runs between ASes, usually between directly connected addresses, with a TTL (time to live) of 1 (ebgp-multihop changes that). iBGP runs inside an AS between loopbacks, with update-source Loopback0. eBGP sets itself as next hop. iBGP leaves the next hop alone, so I use next-hop-self or carry the edge subnets in the IGP.

Filtering and limits

Every eBGP session is filtered in both directions with prefix lists and route maps, and AS path filters such as ^$ so I never become a transit for a provider. neighbor 192.0.2.1 maximum-prefix 500 80 restart 15 drops a session that suddenly sends far too many routes.

Communities

A community is a tag on a route, written AA:NN, that policy can match later. Well known ones include NO_EXPORT, NO_ADVERTISE, GRACEFUL_SHUTDOWN (RFC 8326), which drains traffic before maintenance, and BLACKHOLE (RFC 7999), which asks a provider to drop traffic to an address under attack.

Fast failure detection

A 180 second hold time is far too slow for a WAN. BFD (RFC 5880) runs alongside BGP, OSPF or a static route and detects a failed path in under a second, for example 300 ms with a multiplier of 3. Single hop BFD uses UDP (User Datagram Protocol) port 3784.

Policy without a reset

After changing inbound policy, clear ip bgp 192.0.2.1 soft in asks the neighbour to resend its routes using the route refresh capability, so the session stays up. The older neighbor 192.0.2.1 soft-reconfiguration inbound keeps an unfiltered copy of every received route in memory. I use it only where a peer lacks route refresh, or when I need received-routes.

Aggregation and dampening

aggregate-address 10.1.0.0 255.255.0.0 summary-only advertises one summary once at least one component route is in the BGP table, and hides the rest. Route flap dampening adds a penalty of 1,000 each time a route flaps and suppresses it above 2,000 until the penalty decays below 750, with a 15 minute half life.

Origin validation

RPKI (Resource Public Key Infrastructure) lets an edge router check whether an AS may originate a prefix. How I use it is on the security page.

BGP path selection

How BGP picks one path out of many

BGP compares paths to the same prefix one attribute at a time, in a fixed order, and stops at the first difference. Step through three paths to 203.0.113.0/24 to see where each one drops out.

BGP best path selection, step by step Three paths reach 203.0.113.0/24: from provider A, from provider B and from an iBGP peer. They tie on next hop and weight. The iBGP path drops out on local preference, 100 against 200. A and B tie on AS path length, origin and MED, which is not compared because they come from different ASes. Both are eBGP and have the same IGP cost. Path A has been up longest and wins. Attribute Provider A Provider A Provider B iBGP peer 1 · Next hop reachableyesyesyes 2 · Highest weight (Cisco, local)000 3 · Highest local preference200200100 4 · Locally originated, then shortest AS path2 ASes2 ASes· 5 · Lowest origin (IGP, EGP, incomplete)IGPIGP· 6 · Lowest MED (same neighbour AS only)not comparednot compared· 7 · eBGP over iBGP, then lowest IGP costeBGPeBGP· 8 · Oldest eBGP path, then lowest router IDup 40 daysup 2 days· Best path: provider A

Swipe sideways to see the whole diagram.

Step 1
  1. Only paths with a reachable next hop, and without my own AS in the AS path, are considered. All three qualify.

  2. Weight is Cisco only and never leaves the router. Higher wins. It is 0 for learned routes, so they tie.

  3. Local preference is shared across my AS, and higher wins. I set 200 on routes from both providers, so the iBGP path at the default of 100 drops out. This is how I choose the exit for outbound traffic.

  4. A route I originate myself would win here. Next comes the shortest AS path: both providers show two ASes, so they tie.

  5. IGP beats EGP (exterior gateway protocol, the predecessor of BGP), which beats incomplete. Routes redistributed into BGP show as incomplete. Both are IGP.

  6. MED (multi exit discriminator), lower wins, is only compared between paths from the same neighbouring AS by default. These come from different providers, so it is skipped.

  7. eBGP beats iBGP, then the lowest IGP cost to the next hop. Both are eBGP over direct links, so they still tie. With maximum-paths 2 and bgp bestpath as-path multipath-relax, needed because the two AS paths are different, BGP could now use both.

  8. The oldest eBGP path wins, which keeps traffic stable. Then the lowest router ID, the shortest cluster list and the lowest neighbour address. Provider A has been up for 40 days and is chosen.

Controlling outbound and inbound traffic with BGP An enterprise in AS 65010 connects to provider A and provider B. For outbound traffic, a local preference of 200 on routes from provider A sends all traffic out through A. For inbound traffic, the enterprise prepends its AS three times towards provider B, so the internet sees a shorter path through A and sends return traffic that way. My networkAS 65010 Provider AAS 64500 Provider BAS 64501 Interneteveryone else local preference 200 in from Adefault 100 from B to B: AS path 65010 65010 65010 65010to A: AS path 65010

Swipe sideways to see the whole diagram.

Outbound: I decide. A route map on the session to provider A sets local preference 200 on every route received, so every router in my AS sends internet traffic out through A. Provider B stays as the backup at the default of 100. Weight does the same on a single router only.

Inbound: I can only ask. Other networks choose how to reach me. Prepending my AS several times towards B makes that path look longer, so most traffic returns through A, though more than three or four prepends rarely helps. Other tools: MED towards one provider with two links, communities the provider publishes, and more specific prefixes, down to /24 for IPv4 on the internet.

Animation

Four kinds of attribute

Well known mandatory attributes are in every update: ORIGIN, AS_PATH and NEXT_HOP. Well known discretionary ones every router understands but need not send: LOCAL_PREF, used only inside an AS, and ATOMIC_AGGREGATE. Optional transitive ones pass on even if a router does not understand them: COMMUNITY and AGGREGATOR. Optional non transitive ones are dropped by a router that does not understand them, and never travel far: MED, ORIGINATOR_ID and CLUSTER_LIST.

NEXT_HOP

The address to forward traffic to for the route. An eBGP speaker sets it to itself. An iBGP speaker passes it on unchanged, so every router in the AS must be able to reach it, through the IGP or with next-hop-self at the edge. An unreachable next hop means the route is never used.

ATOMIC_AGGREGATE and AGGREGATOR

When a router summarises routes and drops the AS paths of the parts, it adds ATOMIC_AGGREGATE to warn that path detail is lost. AGGREGATOR records the AS and router ID that made the summary. aggregate-address ... as-set keeps the AS numbers instead, which avoids loops but makes the summary change whenever a part changes.

Redistribution

Joining two routing domains without a loop

Redistribution copies routes from one protocol into another. It is common during migrations and mergers, and it is where many routing loops come from, especially when two routers redistribute in both directions.

A two point redistribution loop and the tag fix An EIGRP domain and an OSPF domain are joined by two routers, R1 and R2, which both redistribute in both directions. A route that is external in EIGRP is redistributed into OSPF by R1. R2 learns it through OSPF with distance 110, which beats the EIGRP external distance of 170, so R2 points the route back into OSPF and redistributes it into EIGRP again. Traffic loops. Tagging routes on the way in and refusing that tag on the way back breaks the loop. EIGRP DOMAIN OSPF DOMAIN Site routerEIGRP external R1redistributes R2redistributes OSPF corerouters 192.168.50.0/24: EIGRP external, AD 170 R1 puts it into OSPF as type 5, E2 R2 prefers OSPF at 110 over 170: loop set tag 100 in, deny tag 100 back out

Swipe sideways to see the whole diagram.

Step 1
  1. A site router puts a static route into EIGRP. Inside EIGRP it is an external route, with administrative distance 170.

  2. R1 redistributes EIGRP into OSPF, so the route enters OSPF as a type 5, E2 route. Every OSPF router learns it, including R2.

  3. R2 hears the route two ways: EIGRP external at 170 and OSPF at 110. It prefers OSPF, and redistributes that route back into EIGRP as a new external route. If EIGRP routers now see a better metric through R2, traffic circles through R2, the OSPF core and R1. Traceroute bounces until the TTL runs out.

  4. On every redistributing router I tag routes on the way in, with set tag 100 in a route map, and deny that tag on the way back with match tag 100. Summarising at the boundary, or changing the distance of external routes, helps too.

Seed metrics

Each protocol needs a starting metric for redistributed routes. OSPF uses 20 as E2, and 1 for routes from BGP. EIGRP needs a metric set, or the routes are silently left out, apart from connected and static. Older IOS also needs the subnets keyword into OSPF.

BGP and the IGP

Redistributing OSPF into BGP takes internal routes only, unless I match externals too. I never redistribute a full BGP table into an IGP. I advertise a default or a few summaries instead.

Finding a loop

show ip route 192.168.50.0 repeated a few seconds apart shows the source changing. The route tag is in the output, and show ip ospf database external shows who is advertising it.

VRF and PBR

Several routing tables in one router

A VRF (virtual routing and forwarding instance) gives a router a separate routing table for each segment, so tenants or zones stay apart even if their addresses overlap. Policy based routing (PBR) overrides the routing table for chosen traffic.

VRFs keeping routing tables apart One router holds two VRFs, RED and BLUE, both using 10.0.0.0/24 without conflict. In the leaking view, a shared services VRF is reachable from both through imported routes. In the firewall view, traffic between VRFs goes through a firewall instead, which is how I prefer to join zones. ONE ROUTER VRF RED10.0.0.0/24 VRF BLUE10.0.0.0/24 again Tenant RED10.0.0.10 Tenant BLUE10.0.0.10 Shared servicesDNS, NTP, directory imported by route target Firewallbetween VRFs every flow checked no route between them

Swipe sideways to see the whole diagram.

Separate tables. Each interface belongs to one VRF, and each VRF has its own routing table, so the same 10.0.0.0/24 can exist twice. Without MPLS this is VRF Lite: one subinterface and one routing process or address family per VRF on each link. On IOS XE: vrf definition RED with address-family ipv4, then vrf forwarding RED on the interface, then the IP address again, because adding the VRF removes it.

Route leaking. Shared services such as DNS (domain name system) and NTP (network time protocol) can be reached by importing their routes into each VRF. Route targets with MP-BGP (multiprotocol BGP) do this, or a static route that points into the other table. It works, but it bypasses inspection, so I treat every leak as a design decision with an owner, and the return route must leak too.

Through a firewall. My preferred design joins VRFs through a firewall, which checks and logs every flow between zones. A VLAN, or its equivalent in a data centre fabric, is one segment. A VRF is a zone that holds many segments. Zones meet at the firewall.

Animation

Policy based routing

An ACL (access control list) matches the traffic, a route map sets the next hop with set ip next-hop, and ip policy route-map applies it on the incoming interface. Traffic that does not match routes normally. PBR does not show in the routing table, so I document it carefully.

Checking a VRF

show vrf, show ip route vrf RED and ping vrf RED 10.0.0.1. On NX-OS, management traffic lives in VRF management, so ping 10.9.9.1 vrf management.

VRFs in MPLS and fabrics

In an MPLS VPN (virtual private network) each customer is a VRF on the provider edge. In a VXLAN EVPN fabric (Virtual Extensible LAN with an Ethernet VPN control plane) each tenant VRF maps to a Layer 3 VNI (VXLAN network identifier). Both are covered on the WAN page and the VXLAN EVPN page.

Multicast

One stream, only where it is wanted

Multicast sends one copy of a stream, such as market data, video or a building system update, to every receiver that asks for it. Hosts join with IGMP (Internet Group Management Protocol), and routers build the delivery tree with PIM (Protocol Independent Multicast). Group addresses come from 224.0.0.0/4.

PIM sparse mode with a rendezvous point A receiver joins group 239.1.1.1 with IGMP. Its router sends a PIM join towards the rendezvous point, building a shared tree. The source's first router registers the stream with the rendezvous point, and traffic flows down the shared tree. The receiver's router then joins the source directly, and traffic switches to the shortest path tree. RPrendezvous point Sourcesends to 239.1.1.1 First hoprouter Last hoprouter Receiverwants the stream IGMP join for 239.1.1.1 PIM join to the RP: shared tree (*,G) Source registers, stream via the RP Switch to the shortest path (S,G)

Swipe sideways to see the whole diagram.

Step 1
  1. The receiver sends an IGMP report for group 239.1.1.1 to its router. Switches with IGMP snooping note the port, so the stream reaches only that port.

  2. The last hop router sends a PIM join towards the RP (rendezvous point), building a shared tree for the group, written (*,G). Each router sends the join out of the interface its unicast table uses to reach the RP. Multicast is then accepted only on that interface, the RPF (reverse path forwarding) check, which stops loops.

  3. The source's first hop router wraps the first packets in unicast register messages to the RP. The RP joins back towards the source, and the stream flows down the shared tree to the receiver.

  4. Once the stream arrives, the last hop router joins the source directly, a source tree written (S,G), and traffic moves off the RP. Cisco does this after the first packet by default. Source specific multicast, in 232.0.0.0/8, skips the RP altogether.

Static RP

ip pim rp-address 10.0.0.1 on every router. It is simple and predictable, but every router needs changing if the RP moves, so I pair it with Anycast RP for resilience.

Auto-RP

Cisco's own method. Candidate RPs announce themselves to 224.0.1.39, and a mapping agent picks one per group and sends the result to 224.0.1.40. In a sparse mode network those two groups need ip pim autorp listener to reach every router.

BSR

The bootstrap router (BSR) method, the open standard in PIM version 2 (RFC 5059). Candidate RPs report to the elected BSR, which floods the RP set hop by hop to every PIM router. It works across vendors.

Anycast RP

Two or more RPs share one loopback address, so each router joins the nearest and a failed RP simply drops out of routing. The RPs tell each other about active sources with MSDP (Multicast Source Discovery Protocol), as in RFC 3446, or with PIM itself, as in RFC 4610.

IPv6 routing

The same ideas, with a few new habits

IPv6 routing follows the same rules: longest match, distance, metric. What changes is how neighbours and gateways are found, and some commands. Addressing itself is on the IP addressing page.

Turn it on

On IOS, routers do not forward IPv6 until ipv6 unicast-routing is set. Hosts find their gateway through router advertisements, part of NDP (Neighbor Discovery Protocol), which also replaces ARP.

Link local next hops

Routing protocols use the neighbour's link local address, in fe80::/10, as the next hop. That is why a static route over Ethernet often needs both the interface and the link local address.

The protocols

OSPFv3 runs per interface and carries IPv6, and with address families IPv4 too. EIGRP and IS-IS support IPv6 directly. BGP carries IPv6 as a separate address family, so the neighbour must be activated under address-family ipv6.

QoS

Deciding what waits when the link is full

Queues form where a fast link meets a slower one, which is usually the WAN edge. QoS (quality of service) decides which traffic goes first, which gets a guaranteed share, and what is dropped. It only helps during congestion. It never creates bandwidth.

Queuing and shaping at the WAN edge A gigabit LAN feeds a WAN router whose circuit is 100 megabits. Traffic is classified by its DSCP marking. Voice goes to a strict priority queue, other classes get guaranteed shares, and best effort is dropped early when its queue fills. A shaper on the gigabit port holds the total to 100 megabits, so the provider never drops traffic at random. 1 Gb/s LAN Classifymatch DSCP Queues Priority: voice EF Guaranteed: video, business Best effort, early drop 100 Mb/s circuit 1 Gb/s into 100 Mb/s: a queue forms Each packet sorted by its marking Voice first, shares for the rest Shaper holds the port to 100 Mb/s

Swipe sideways to see the whole diagram.

Step 1
  1. The LAN runs at 1 Gb/s but the circuit is 100 Mb/s. When traffic bursts, packets must wait. Without QoS, the queue is first in, first out, and voice waits behind a file copy.

  2. The router sorts each packet into a class by its DSCP (differentiated services code point) marking, set at the campus edge. Classification and marking happen as close to the source as possible.

  3. LLQ (low latency queuing) gives voice, marked EF (expedited forwarding), a strict priority queue, policed to its rate so it cannot starve the rest. CBWFQ (class based weighted fair queuing) guarantees each other class a share. WRED (weighted random early detection) drops a little best effort traffic early, so TCP slows down smoothly.

  4. When a 1 Gb/s port connects to a 100 Mb/s service, the router would send faster than the provider accepts and the provider would drop at random. A parent shaper holds the port to 100 Mb/s, and the queuing policy runs inside it. This is hierarchical QoS.

Policing and shaping

A policer drops or remarks traffic above a rate at once, which makes TCP back off hard. A shaper buffers the excess and sends it later, adding delay but fewer drops. Providers police, so I shape before their policer.

Checking it works

show policy-map interface Gi0/0/0 shows matches, queue depth and drops for each class. Drops in the priority class mean voice is over its budget. Drops in best effort during busy hours are expected.

One policy end to end

The markings and classes in the campus, on the WAN and in the data centre must agree. A provider that remarks traffic, or a tunnel that hides the marking, breaks it.

Troubleshooting

Routing faults and how I find them

Most routing faults are a neighbour that will not form, a route that never arrives, or traffic that returns a different way. Pick a symptom to see what I check, with commands for IOS and IOS XE, and NX-OS where they differ.

OSPF neighbour never appearsDown or stuck in Init
What I see
The neighbour is missing from show ip ospf neighbor, because parameters differ and hellos are dropped, or it shows INIT on one side only, because hellos are lost in one direction.
Likely causes
Area, subnet or mask, hello and dead timers, authentication, network type or stub flags differ. The interface is passive or not in OSPF. An ACL or firewall drops protocol 89 or 224.0.0.5. Duplicate router IDs.
What I check
show ip ospf interface Gi0/0/1 on both ends side by side, show ip ospf interface brief, show ip protocols, show logging | include OSPF. NX-OS: show ip ospf neighbors and show ip ospf interface brief.
Fix
Correct the side that drifted from the standard, under change.
Prevention
Both ends of every link in the same change, from a template.
OSPF stuck in ExStart or ExchangeUsually an MTU mismatch
What I see
The neighbour cycles between EXSTART and EXCHANGE, often after a circuit migration, and traffic is on the backup path.
Likely causes
The interface MTU differs at each end, so database descriptions are rejected. If both routers match, something in between, such as a carrier switch, has a lower MTU. Then a duplicate router ID, or unicast blocked.
What I check
show interfaces Gi0/0/1 | include MTU on both ends, ping 172.16.0.2 size 1500 df-bit stepping down, debug ip ospf adj briefly, then undebug all.
Fix
Align mtu and ip mtu with what the circuit really carries, then confirm FULL and traffic back on the primary.
Prevention
An MTU check in the migration runbook.
A route is missingNeighbour up, prefix absent
What I see
Neighbours are FULL or Established, but one prefix is not in the routing table.
Likely causes
OSPF: the source interface is not in OSPF, an ABR filter or range, an area type that blocks externals, or redistribution not matching. In the database but not the table: a distribute list, or a lower AD from another source. BGP: see the BGP entries.
What I check
show ip route 10.1.20.15 (the longest match it really uses), show ip ospf database | include 10.1.20.0, show ip protocols for filters and distances, show ip ospf border-routers.
Fix
Correct the origin, filter, area type or distance.
Prevention
Documented summaries, and redistribution only through tagged route maps.
BGP stuck in ActiveTCP 179 never completes
What I see
show ip bgp summary shows Active for the neighbour, often after a firewall change.
Likely causes
Wrong neighbour address, or the far end not configured for mine. Wrong update source. Missing ebgp-multihop. An ACL, control plane policing (CoPP) or a firewall blocking TCP 179 in either direction. MD5 (message digest 5) authentication set on one side only. NAT changing the source.
What I check
ping 192.0.2.1 source Loopback0, telnet 192.0.2.1 179 /source-interface Loopback0 (open means a BGP setting, refused means the far end is not configured, timeout means dropped), show tcp brief | include 179, show logging | include BGP|BADAUTH. NX-OS: show bgp ipv4 unicast summary.
Fix
Correct addressing, update source, multihop, filter or password, or roll back the firewall change.
Prevention
A list of routing peers that cross each firewall, checked after every firewall change, and alerts on BGP neighbour down, not just interface down.
BGP stuck in IdleNot even trying to connect
What I see
Idle, Idle (Admin) or Idle (PfxCt) in the summary.
Likely causes
Shut down. Maximum prefix exceeded. No route to a loopback peer. eBGP to an address that is not directly connected without multihop. Backing off after a NOTIFICATION, such as a wrong AS number.
What I check
show ip bgp neighbors 192.0.2.1 | include BGP state|Last reset, show ip route 192.0.2.1, show logging | include NOTIFICATION|MAXPFX.
Fix
no neighbor 192.0.2.1 shutdown, fix the prefix source or raise the limit under change, restore the route to the peer, or correct the AS.
Prevention
Maximum prefix with a warning threshold and a restart timer on every eBGP session.
BGP Established but no routesSession up, nothing exchanged
What I see
The session is Established but zero prefixes are received or sent, or a route is in the BGP table but not the routing table.
Likely causes
A network statement that does not exactly match a route in the table. An outbound or inbound filter, with its implicit deny. The address family not activated. iBGP split horizon. A next hop that is not reachable. RIB failure, where a static or OSPF route wins on distance.
What I check
show ip bgp neighbors 192.0.2.1 advertised-routes and received-routes (which needs soft-reconfiguration inbound), show ip bgp 203.0.113.0, show ip bgp rib-failure, show route-map, show ip prefix-list.
Fix
Correct the network statement, filter, activation or next hop, or remove the overriding route.
Prevention
Peer checks after every change: prefixes sent and received against a known count.
Some sessions fail after a failoverAsymmetric routing through a stateful firewall
What I see
Ping works, but TCP sessions fail or reset, often after an HSRP (Hot Standby Router Protocol) or link failover.
Likely causes
Outbound traffic leaves through one firewall and the reply returns through another, which has no session and drops it. Causes include gateway and routing preference on different switches, ECMP (equal cost multipath) across firewalls that do not share state, PBR or a static sending replies another way, or strict uRPF (unicast reverse path forwarding).
What I check
traceroute in both directions, show standby brief, show ip route for the user subnet on the upstream router, and the firewall's drop reasons, such as show asp drop on an ASA (no SYN seen).
Fix
Make the return path follow the active gateway, using the same tracking for both, or use a firewall cluster that shares state.
Prevention
A design rule for symmetric paths through stateful devices.
Routes keep changing, traceroute bouncesRedistribution loop
What I see
A prefix changes source every few seconds, traceroute bounces between two routers until TTL runs out, and CPU rises from repeated SPF or DUAL runs.
Likely causes
Two point redistribution without tags, so a route returns into its own domain with a better distance.
What I check
show ip route 192.168.50.0 a few times (source and tag), show ip ospf database external | include Tag|Link State ID, show ip protocols.
Fix
Tag and deny route maps on every redistributing router, summaries at the boundary, and deliberate distance changes.
Prevention
One standard redistribution template, applied everywhere.
Traffic takes a slow pathSuboptimal OSPF routing
What I see
Traffic crosses a slow link while a faster one sits idle.
Likely causes
The default reference bandwidth makes 1 and 10 Gb/s links equal. Routers disagree on reference bandwidth. A leftover ip ospf cost. Intra area preferred over inter area regardless of cost. E2 ignoring internal cost.
What I check
traceroute 10.1.20.15 source Loopback0, show ip ospf interface brief on each hop for cost, show ip cef exact-route 10.9.1.1 10.1.20.15 for which ECMP member is used.
Fix
Align the reference bandwidth everywhere, set explicit costs, or move the link to the right area, with before and after paths in the change record.
Prevention
Reference bandwidth in the base template.

My general method, from defining the problem to closing the record, is on the troubleshooting page.

Projects

Where I have used these protocols

OSPF, BGP and MPLS (Multiprotocol Label Switching) run through my career, from enterprise WANs to provider and peering edges, and my home lab runs an MPLS core on physical routers.

Home lab

An MPLS core with three customer sites

My home lab runs an MPLS core, provider edge routers with customer VRFs, DMVPN (Dynamic Multipoint VPN) backup across a simulated internet built from VRFs, and a default route out to the real internet, all on physical routers.

Vodafone · 2024

Routing security at the peering edge

Defined routing security policy for the peering and transit edge: RPKI and ROA (route origin authorisation) origin validation, and RIPE NCC (the European regional internet registry) resource governance.

Manx Telecom · 2016

Provider address space and AS numbers

Managed provider IP space and AS numbers with RIPE NCC, including RPKI ROAs, for a Tier 3 data centre serving over 300 customer sites.

AVEVA · 2020 to 2021

A secure, consolidated internet edge

Secured the consolidated internet edge with RPKI based BGP origin validation and cleaned up the RIR (regional internet registry) records across the merged address space.

BT Group · 2013

Enterprise WAN designs

High and low level designs for enterprise customers including Rolls Royce, Virgin Money, Rio Tinto and Primark.

Passport Telecom · 2004 to 2007

Where it started

Cisco based telecoms infrastructure for over 4,000 clients across East Africa and South America.

Backed by CCNP Enterprise, CCNP Routing and Switching, CCDP, the Cisco Enterprise Advanced Infrastructure specialist certification and the CCIE Routing and Switching written exam. See all credentials