Routing Metrics – Concepts, Calculations, and Configuration
1. What Is a Routing Metric?
A routing metric is a numerical value that a routing protocol assigns to each route it knows about. It represents the “cost” of using that path to reach a destination network. When a router learns multiple paths to the same destination from the same routing protocol, it compares their metrics and installs the route with the lowest metric in the routing table.
Each protocol calculates its metric differently — RIP counts routers, OSPF measures bandwidth, EIGRP weighs bandwidth and delay together, and BGP uses a policy-driven set of path attributes. Because the scales are incompatible, metrics are only meaningful within the same protocol. When two different protocols both know a route, the router uses Administrative Distance (AD) to decide which protocol to trust first, and only then does metric come into play.
Two paths to 10.1.0.0/24 via OSPF:
Path A: R1 → R2 → R4 OSPF cost = 20 ← INSTALLED (lower)
Path B: R1 → R3 → R4 OSPF cost = 30 ← kept as backup
Same destination, OSPF vs RIP:
OSPF AD = 110 ← INSTALLED (lower AD wins; metric not compared)
RIP AD = 120
Related pages:
Administrative Distance |
Route Sources |
OSPF Overview |
EIGRP Overview |
BGP Overview |
RIP Concepts |
Default Routes |
show ip route |
show ip protocols |
OSPF Configuration |
EIGRP Configuration
2. Metric vs. Administrative Distance
These two values are often confused. The key distinction is the scope at which each one operates:
| Feature | Metric | Administrative Distance (AD) |
|---|---|---|
| Scope | Compares paths within one routing protocol | Compares routes between different routing protocols (or sources) |
| Lower value preferred? | Yes | Yes |
| Decision order | Second — only applied after AD has selected the protocol | First — eliminates all but the most trusted source |
| Typical range | Protocol-dependent (e.g., 1–15 for RIP, 1–65535 for OSPF cost) | 0 (connected) to 255 (unreachable) |
| Cross-protocol comparison? | No — an OSPF cost of 10 and a RIP hop count of 3 cannot be compared | Yes — AD is designed specifically to compare across protocols |
| Example | OSPF selects path via R2 (cost 20) over path via R3 (cost 30) | Router prefers OSPF route (AD 110) over RIP route (AD 120) to same destination |
See also: Administrative Distance – Full Guide
3. How Routers Use Metrics to Select the Best Path
The full route selection decision sequence a Cisco router follows is:
- Longest prefix match — the most specific route always wins first, regardless of metric or AD (e.g., /30 beats /24 for a matching address).
- Administrative Distance — if the same prefix is known by multiple protocols or sources, the one with the lowest AD is preferred. All others are discarded from the routing table.
- Metric — once the winning protocol is chosen, the route(s) with the lowest metric from that protocol are installed.
- ECMP — if two or more routes share the exact same metric (and protocol), all are installed and traffic is load-balanced across them.
Routing table decision flow for prefix 10.0.0.0/24:
Source AD Metric Action
────────── ── ────── ──────────────────────────────
Connected 0 0 Would win (if directly connected)
OSPF 110 20 ← WINS (lowest AD among known protocols)
RIP 120 4 Discarded (higher AD)
If two OSPF paths exist:
OSPF via R2 110 20 ← INSTALLED
OSPF via R3 110 30 Kept in OSPF topology, not in routing table
4. RIP – Hop Count
RIP (Routing Information Protocol) uses the simplest possible metric: hop count, the number of routers that a packet must traverse to reach the destination.
| Property | Detail |
|---|---|
| Metric type | Hop count (integer) |
| Minimum value | 1 (directly adjacent router) |
| Maximum usable value | 15 hops |
| Unreachable indicator | 16 — any route with metric 16 is considered unreachable and removed |
| Bandwidth awareness | None — a 10-hop path over 10 Gbps links is preferred over a 2-hop path over 56 kbps links if hop count is lower |
| Maximum network diameter | 15 hops; unsuitable for large networks |
Destination: 10.2.0.0/24
R1 → R2 → R3 → R4 → R5 RIP metric = 4 hops ← preferred
R1 → R6 → R5 RIP metric = 2 hops ← actually preferred!
(Even if R6 is a slow 56k link — RIP does not know or care)
See also: RIP Concepts | RIP Configuration
5. OSPF – Cost
OSPF uses cost as its metric, calculated from interface bandwidth. Unlike RIP, OSPF favours higher-bandwidth paths because higher bandwidth produces a lower cost. See: OSPF Overview
| Property | Detail |
|---|---|
| Formula | Cost = Reference Bandwidth ÷ Interface Bandwidth |
| Default reference bandwidth | 100 Mbps (results in cost = 1 for any link ≥ 100 Mbps) |
| Path cost | Sum of outgoing interface costs along the entire path |
| Minimum cost per interface | 1 (cost is always rounded up; never 0) |
| Problem with default reference | FastEthernet (100 Mbps), GigabitEthernet (1 Gbps), and 10 GigabitEthernet all calculate cost = 1 — no differentiation between them |
| Fix for modern networks | Raise the reference bandwidth to 1,000 Mbps (1 Gbps) or 10,000 Mbps (10 Gbps) with auto-cost reference-bandwidth |
! Common OSPF cost values at default reference (100 Mbps)
! Serial (1.544 Mbps) → cost = 100 / 1.544 = 64
! FastEthernet (100 Mbps) → cost = 100 / 100 = 1
! GigabitEthernet (1000 Mbps) → cost = 100 / 1000 = 0.1 → rounded to 1
! 10 GigabitEthernet (10000 Mbps) → cost = 100 / 10000 = 0.01 → rounded to 1
! Fix: raise reference bandwidth for modern high-speed networks
router ospf 1
auto-cost reference-bandwidth 10000 ! 10 Gbps reference
! Override cost on a specific interface
interface GigabitEthernet0/1
ip ospf cost 5
! Verify per-interface OSPF cost
Router# show ip ospf interface GigabitEthernet0/1
See also: OSPF Single-Area Configuration | OSPF Areas & LSAs | Step-by-Step: OSPF
6. EIGRP – Composite Metric
EIGRP uses a composite metric that can incorporate up to five components, though in practice only bandwidth and delay are used by default (K1 = 1, K3 = 1; K2, K4, K5 = 0).
| Component | K-value | Default Active? | Description |
|---|---|---|---|
| Bandwidth | K1 = 1 | Yes | Minimum bandwidth (kbps) along the path — the bottleneck link |
| Load | K2 = 0 | No | Link utilisation (1–255); unstable in practice — not recommended |
| Delay | K3 = 1 | Yes | Cumulative delay (µs) of all outgoing interfaces along the path (tens of microseconds) |
| Reliability | K4 = 0 | No | Link reliability (1–255); also unstable — not recommended |
| MTU | K5 = 0 | No | Minimum MTU along the path; tracked but not used in metric calculation |
Classic EIGRP metric formula (default K-values):
Metric = [ (10^7 / min-bandwidth-kbps) + (sum-of-delays / 10) ] × 256
Example:
Path has minimum bandwidth = 100,000 kbps (100 Mbps FastEthernet)
Cumulative delay = 200 (in units of tens of microseconds = 2000 µs total)
Metric = [ (10,000,000 / 100,000) + (200 / 10) ] × 256
= [ 100 + 20 ] × 256
= 120 × 256
= 30,720
! View EIGRP topology table (shows composite metric and component values)
Router# show ip eigrp topology
Router# show ip eigrp topology 10.1.0.0/24
! Modify delay on an interface (in tens of microseconds)
interface GigabitEthernet0/1
delay 100
! Modify bandwidth (affects metric calculation; does not change actual speed)
interface GigabitEthernet0/1
bandwidth 500000
See also: EIGRP Overview | EIGRP Configuration | Step-by-Step: EIGRP
7. BGP – Path Attributes
BGP does not use a single numeric metric. Instead, it uses a set of path attributes that are evaluated in a specific order (the BGP best-path selection algorithm). BGP is primarily policy-driven rather than topology-driven. See: BGP Overview
| Attribute | Type | Preference | Description |
|---|---|---|---|
| Weight | Cisco proprietary; local to router | Higher is better | First tiebreaker; not advertised to peers; default = 0 (32768 for locally originated) |
| LOCAL_PREF | Well-known discretionary | Higher is better | Shared within AS; used to prefer exit points; default = 100 |
| AS_PATH | Well-known mandatory | Shorter is better | List of ASes the route has traversed; primary loop-prevention mechanism and path-length measure |
| Origin | Well-known mandatory | IGP < EGP < Incomplete | How the route entered BGP: IGP (i), EGP (e), or redistributed (?) |
| MED | Optional non-transitive | Lower is better | Multi-Exit Discriminator; hints to external AS which entry point to use; exchanged between directly peered ASes only |
| eBGP over iBGP | Route type | eBGP preferred | Routes learned from external peers preferred over internal peers |
Exam tip: The BGP best-path selection order is evaluated top-to-bottom; the first attribute that differs between two paths determines the winner. The common mnemonic is N WLLA OMNI (Neighbour Weight, LOCAL_PREF, Locally originated, AS_PATH, Origin, MED, eBGP vs iBGP, IGP metric, Neighbour ID).
8. Protocol Metric Comparison
| Protocol | Metric Type | Formula / Basis | Max / Range | Bandwidth-Aware? | Tuning Command |
|---|---|---|---|---|---|
| RIP | Hop count | Count of router hops | 1–15 (16 = unreachable) | No | offset-list to add to metric |
| OSPF | Cost | Ref BW ÷ Interface BW (sum along path) | 1–65,535 per interface | Yes | ip ospf cost or auto-cost reference-bandwidth |
| EIGRP | Composite | [(107 / BW) + (delay/10)] × 256 | 256 – ~4.29 billion | Yes | bandwidth or delay on interface |
| IS-IS | Cost | Sum of interface costs (default 10 per link) | 1–16,777,214 (wide metric) | Configurable | isis metric on interface |
| BGP | Path attributes | Multi-attribute policy decision (see Section 7) | Policy-defined | Indirectly via MED | Route maps, set weight, set local-preference, set metric |
9. Equal-Cost Multi-Path (ECMP) Routing
When a routing protocol finds two or more paths to the same destination with identical metrics, it installs all of them in the routing table simultaneously. The router then distributes traffic across these paths — a feature called ECMP (Equal-Cost Multi-Path).
| Protocol | Default Max ECMP Paths | Maximum Configurable | Load-Balance Method |
|---|---|---|---|
| RIP | 4 | Up to 16 (IOS version dependent) | Per-destination (CEF) |
| OSPF | 4 | Up to 16 (maximum-paths) |
Per-destination or per-packet |
| EIGRP | 4 | Up to 16 (maximum-paths); also supports unequal-cost LB via variance |
Proportional to metric (unequal) or equal (ECMP) |
| BGP | 1 (single best path) | Up to 8 with maximum-paths (eBGP) or maximum-paths ibgp |
Per-destination |
! OSPF — increase ECMP paths
router ospf 1
maximum-paths 8
! EIGRP — equal-cost load balancing (4 paths)
router eigrp 1
maximum-paths 4
! EIGRP — unequal-cost load balancing with variance
! Routes with metric ≤ (best-metric × variance) are included
router eigrp 1
variance 2 ! Allow paths up to 2x the best metric
! Verify ECMP in routing table
Router# show ip route 10.1.0.0
10. Metric Manipulation and Tuning
Administrators manipulate metrics to force traffic down preferred paths, implement primary/backup topologies, or satisfy business policies that the automatic metric calculation would not produce.
10a. OSPF Cost Tuning
! Set cost explicitly on an interface (overrides calculated value)
interface GigabitEthernet0/1
ip ospf cost 5
! Raise reference bandwidth so GigE ≠ 10GigE in cost
router ospf 1
auto-cost reference-bandwidth 10000 ! 10 Gbps = cost 1; 1 Gbps = cost 10
10b. EIGRP Bandwidth and Delay Tuning
! Lower bandwidth statement raises EIGRP metric → makes path less preferred
interface Serial0/0
bandwidth 512 ! in kbps; does NOT change actual clock rate
! Raise delay → makes path less preferred
interface GigabitEthernet0/1
delay 200 ! in tens of microseconds
10c. RIP Offset-List
! Add 3 hops to all RIP routes learned on Gi0/1 → makes path less preferred
router rip
offset-list 0 in 3 GigabitEthernet0/1
10d. Using Route Maps to Set Metrics
! Set metric to 20 for specific prefixes during redistribution
route-map SET_METRIC permit 10
match ip address ACL_PREFIXES
set metric 20
router rip
redistribute ospf 1 metric 5 route-map SET_METRIC
11. Metric During Route Redistribution
When routes are redistributed between different protocols, the source protocol’s metric has no meaning in the destination protocol. A seed metric must be defined or IOS will apply a default that may cause the redistributed routes to be unreachable.
| Destination Protocol | Default Seed Metric (if not specified) | Risk | Best Practice |
|---|---|---|---|
| RIP | Infinity (unreachable — metric = 16) | Routes will not be propagated | Always specify metric <1-15> in redistribute command |
| OSPF | 20 (for external Type 2 routes) | All external routes appear equal; no path differentiation | Use metric keyword or route map set metric |
| EIGRP | Infinity (unreachable) if no seed metric given | Routes will not be propagated | Always provide all five metric components: redistribute <src> metric BW delay reliability load MTU |
! Redistribute OSPF into EIGRP with explicit seed metric
router eigrp 1
redistribute ospf 1 metric 10000 100 255 1 1500
! BW DLY REL LD MTU
! Redistribute EIGRP into OSPF with seed cost
router ospf 1
redistribute eigrp 1 subnets metric 30 metric-type 1
! Redistribute OSPF into RIP with seed hop count
router rip
redistribute ospf 1 metric 3
See also: Step-by-Step: Route Redistribution | Default Routes | Floating Static Routes
12. Metrics and Routing Convergence
Metric stability directly affects how quickly and smoothly a network converges after a topology change:
- Stable metrics (e.g., OSPF cost based on interface bandwidth) produce consistent routing tables and fast convergence because the best path does not change unless the topology actually changes.
- Fluctuating metrics (e.g., EIGRP with K2/K4 load or reliability enabled) cause continuous route changes even under steady traffic loads, leading to route flapping and instability. This is why K2 and K4 are disabled by default.
- RIP’s slow convergence is partly a metric problem: because bad news propagates one hop at a time (counting to infinity), a 15-hop route can take minutes to be declared unreachable after a failure. RIP uses split horizon, route poisoning, and holddown timers to mitigate this.
- OSPF and EIGRP use topology databases (LSDB and topology table) to recalculate metrics after failures, converging in seconds rather than minutes.
13. Verification Commands
| Command | Purpose | Key Output |
|---|---|---|
show ip route |
Full routing table | Shows metric in brackets: [AD/metric] e.g., [110/20] for OSPF cost 20 |
show ip route 10.1.0.0 |
Detail for a specific prefix | Shows all ECMP paths and their individual metrics |
show ip protocols |
Routing protocol configuration | Shows maximum-paths, timers, K-values (EIGRP), reference bandwidth (OSPF) |
show ip ospf interface [int] |
OSPF cost per interface | Cost value, hello/dead intervals, neighbour count |
show ip eigrp topology |
Full EIGRP topology table | Composite metric, feasible distance (FD), advertised distance (AD) per route |
show ip eigrp topology 10.1.0.0/24 |
EIGRP detail for one prefix | All successors and feasible successors; useful for verifying variance and unequal-cost LB |
show ip bgp 10.1.0.0/24 |
BGP path detail | All paths with attributes; best path marked with > |
show ip bgp summary |
BGP peer status | State, prefixes received; useful to verify BGP is exchanging routes |
! Reading the routing table metric field
! Format: [AD/metric]
Router# show ip route
O 10.1.0.0/24 [110/20] via 192.168.1.2, 00:05:12, GigabitEthernet0/1
! ^^^ ^^
! AD metric (OSPF cost)
D 10.2.0.0/24 [90/30720] via 192.168.2.2, 00:04:55, GigabitEthernet0/2
! ^^ ^^^^^
! AD metric (EIGRP composite)
R 10.3.0.0/24 [120/3] via 192.168.3.2, 00:01:02, Serial0/0
! ^^^ ^
! AD metric (RIP hop count)
14. Best Practices for Metric Design
- OSPF: Always set
auto-cost reference-bandwidthto match the fastest links in your network. The default 100 Mbps reference makes GigE and 10 GigE indistinguishable (both cost 1). - EIGRP: Never enable K2 (load) or K4 (reliability) in production — they fluctuate dynamically and cause route instability. Stick to K1 (bandwidth) and K3 (delay).
- Redistribution: Always define an explicit seed metric when redistributing into RIP or EIGRP — both default to infinity (unreachable) if no metric is provided.
- ECMP: Verify that ECMP paths are truly equal in capacity before enabling load balancing; unequal physical links with equal metrics overload the lower-capacity path.
- Documentation: Record any manual metric overrides (interface cost, bandwidth,
delay statements) in network diagrams and change logs — they are not obvious
from a plain
show ip route. - Avoid metric-based tricks for failover in OSPF when a simple
ip ospf coston the standby link suffices; keep configurations readable and auditable. - BGP: Prefer LOCAL_PREF for outbound traffic control within an AS and MED for signalling preferred ingress points to external peers; avoid relying on AS_PATH prepending as a primary design tool.
15. Key Points & CCNA Exam Tips
- Metric = cost of a route within one protocol; AD = trustworthiness of a protocol between protocols. AD is evaluated first.
- Lower metric = more preferred route (same rule as AD)
- RIP metric = hop count; max 15; 16 = unreachable; no bandwidth awareness
- OSPF metric = cost = Reference BW ÷ Interface BW; lower bandwidth → higher cost
- Default OSPF reference bandwidth = 100 Mbps; raise with
auto-cost reference-bandwidthon all routers in the domain - EIGRP composite metric uses bandwidth and delay by default (K1=1, K3=1); formula: [(107/BW) + (delay/10)] × 256
- BGP uses path attributes (Weight → LOCAL_PREF → AS_PATH → Origin → MED …); higher Weight/LOCAL_PREF preferred; shorter AS_PATH preferred
- Metrics are not comparable across protocols — never compare an OSPF cost to a RIP hop count
- ECMP: when multiple paths share the same metric, all are installed and traffic is load-balanced
- EIGRP supports unequal-cost load balancing via the
variancecommand — unique among IGPs - Redistribution requires a seed metric; RIP and EIGRP default to unreachable if none is specified
- Read routing table metrics as [AD/metric]:
[110/20]= OSPF (AD 110), cost 20