Administrative distance, route maps, loop prevention, EIGRP (named-mode, stub, summarization, authentication), OSPFv2 & OSPFv3 (LSA types, area types, virtual links, authentication), eBGP/iBGP (path selection, attributes, route reflectors, communities, peer groups), redistribution between protocols, and Policy-Based Routing.
1.1 Administrative distance (AD)
When two routing sources advertise the same destination prefix with the same prefix length, IOS picks the one with the lowest AD. AD is purely local to the router — it never traverses the wire. Mastering AD is essential for redistribution scenarios because feedback loops are usually solved by manipulating AD.
Default AD values to memorize
| Source | AD | Notes |
|---|---|---|
| Connected interface | 0 | Always wins |
| Static route | 1 | Floating static = static with higher AD |
| eBGP | 20 | From a different AS |
| EIGRP (internal) | 90 | Native EIGRP routes |
| IGRP | 100 | Legacy |
| OSPF | 110 | All OSPF route types share the same AD |
| IS-IS | 115 | |
| RIP | 120 | |
| EIGRP (external) | 170 | Routes redistributed into EIGRP |
| iBGP | 200 | From the same AS |
| Unreachable | 255 | Route is dropped |
Visualizing AD selection
ip route 10.0.0.0 255.0.0.0 192.168.1.1 200 creates a static route with AD 200, used only if all dynamic protocols (OSPF/EIGRP) lose the prefix. Classic backup/failover trick.1.2 Route maps — the universal policy tool
A route-map is an ordered, sequence-numbered policy with match conditions and set actions. ENARSI uses route-maps everywhere — PBR, redistribution, BGP attributes, EIGRP/OSPF filtering. Master one tool, control all protocols.
Route-map structure
R1(config-route-map)# match ip address prefix-list LANS
R1(config-route-map)# match interface GigabitEthernet0/1
R1(config-route-map)# set metric 5000
R1(config-route-map)# set tag 100
R1(config-route-map)# exit
R1(config)# route-map MY_POLICY permit 20 ! catch-all (no match = match everything)
Reading rules
- Sequence numbers are evaluated top-down, first match wins.
- permit + match → apply
setand exit. - deny + match → reject (filter, do not redistribute).
- No
matchstatement = match everything. - Multiple
matchstatements of the same type = logical OR. - Multiple
matchstatements of different types = logical AND. - Implicit deny at the end — anything not matched is filtered.
Where route-maps attach
| Use case | Command |
|---|---|
| Policy-Based Routing | ip policy route-map NAME on an interface |
| Redistribution filter | redistribute ospf 1 route-map FILTER |
| BGP neighbor inbound/outbound | neighbor x.x.x.x route-map IN in |
| BGP network statement | network 10.0.0.0 mask 255.0.0.0 route-map ORIG |
| EIGRP/OSPF distribute-list | distribute-list route-map FILTER in |
match ip address (ACL or prefix-list), match ip route-source, match interface, match metric, match tag, match route-type, match community (BGP), match as-path (BGP).Common set objects:
set ip next-hop, set metric, set metric-type, set tag, set local-preference, set as-path prepend, set community, set weight.1.3 Loop prevention mechanisms
Each protocol has its own loop-avoidance philosophy. ENARSI tests them across all four IGPs/EGP.
| Protocol | Loop prevention mechanism |
|---|---|
| RIP | Split horizon, route poisoning (16=infinity), hold-down timers, poison reverse, max hop count 15 |
| EIGRP | DUAL feasibility condition (FC: ADnbr < FDlocal), split horizon, no inherent area concept |
| OSPF | Link-state SPF computes loop-free SPT per area; inter-area must transit Area 0; LSA flooding boundaries |
| BGP | eBGP: AS_PATH check (drop if own ASN appears). iBGP: split horizon (don’t re-advertise iBGP-learned routes to other iBGP peers → full mesh or RR) |
| Redistribution | Route tagging + match tag + deny in route-map; manipulating AD; filtering with distribute/prefix-list |
Tag-based loop prevention (redistribution)
R1(config)# route-map OSPF_TO_EIGRP permit 10
R1(config-route-map)# set tag 100
R1(config)# router eigrp 100
R1(config-router)# redistribute ospf 1 metric 10000 100 255 1 1500 route-map OSPF_TO_EIGRP
! On router doing EIGRP -> OSPF, drop anything tagged 100 (loop)
R2(config)# route-map EIGRP_TO_OSPF deny 10
R2(config-route-map)# match tag 100
R2(config-route-map)# route-map EIGRP_TO_OSPF permit 20
R2(config)# router ospf 1
R2(config-router)# redistribute eigrp 100 subnets route-map EIGRP_TO_OSPF
1.4 EIGRP — advanced features
DUAL recap — Successor & Feasible Successor
- FD (Feasible Distance) — lowest metric to a destination from the local router.
- RD/AD (Reported / Advertised Distance) — metric the neighbor reports to the destination.
- Successor — primary route (lowest FD), installed in RIB.
- Feasible Successor (FS) — backup that satisfies the Feasibility Condition: RDnbr < FDlocal. Loop-free; instant failover.
EIGRP stub routing
A stub router announces itself as a stub; the hub will never send queries to a stub. Massive scaling benefit, prevents SIA (Stuck-In-Active).
SPOKE(config-router-af)# eigrp stub connected summary static redistributed receive-only leak-map LM
Stub options: connected, summary, static, redistributed, receive-only, leak-map (selectively leak prefixes that would otherwise be filtered).
EIGRP authentication — classic vs named-mode
R1(config)# key chain EIGRP_KC
R1(config-keychain)# key 1
R1(config-keychain-key)# key-string Cisco123!
R1(config)# interface Gi0/1
R1(config-if)# ip authentication mode eigrp 100 md5
R1(config-if)# ip authentication key-chain eigrp 100 EIGRP_KC
! Named-mode — HMAC-SHA-256 (modern, ENARSI v1.1)
R1(config)# router eigrp NAMED
R1(config-router)# address-family ipv4 unicast autonomous-system 100
R1(config-router-af)# af-interface Gi0/1
R1(config-router-af-int)# authentication mode hmac-sha-256 Cisco123!
EIGRP summarization, passive-interface, filtering
R1(config-if)# ip summary-address eigrp 100 10.0.0.0 255.0.0.0
! Passive-interface (no hellos, no neighbors on this iface)
R1(config-router)# passive-interface default
R1(config-router)# no passive-interface Gi0/1
! Filter outbound on Gi0/1 with prefix-list
R1(config)# ip prefix-list NO_DEFAULT seq 5 deny 0.0.0.0/0
R1(config)# ip prefix-list NO_DEFAULT seq 10 permit 0.0.0.0/0 le 32
R1(config)# router eigrp 100
R1(config-router)# distribute-list prefix NO_DEFAULT out Gi0/1
passive-interface on EIGRP/OSPF stops Hello packets — no neighbor will form. On RIP it just stops updates, but the interface still receives them. Different behavior per protocol.1.5 OSPFv2 & OSPFv3 — LSAs, areas, virtual links
The 7 OSPF LSA types you must know cold
| Type | Name | Originator | Scope |
|---|---|---|---|
| 1 | Router LSA | Every router | Within its area only |
| 2 | Network LSA | DR on multi-access segments | Within the area |
| 3 | Summary (Inter-Area Prefix) LSA | ABR | Across area boundaries |
| 4 | ASBR-Summary LSA | ABR | Tells other areas how to reach the ASBR |
| 5 | External LSA | ASBR | Flooded throughout the OSPF domain (except stub/NSSA) |
| 7 | NSSA External LSA | ASBR inside an NSSA | Within the NSSA; ABR translates to Type 5 leaving the NSSA |
| 9-11 | Opaque LSAs | Various (TE, Segment Routing) | Link / area / AS scope |
OSPF area types — what’s allowed
| Area type | Type 1/2 | Type 3 (inter-area) | Type 4/5 (external) | Type 7 (NSSA) | ABR injects default? |
|---|---|---|---|---|---|
| Standard / Backbone | ✓ | ✓ | ✓ | — | No |
| Stub | ✓ | ✓ | ✗ | ✗ | Yes (Type 3) |
| Totally Stubby | ✓ | ✗ | ✗ | ✗ | Yes (Type 3) |
| NSSA | ✓ | ✓ | ✗ | ✓ | Optional |
| Totally NSSA | ✓ | ✗ | ✗ | ✓ | Yes (Type 3) |
Rx(config-router)# area 1 stub
! Totally Stubby: stub no-summary on the ABR only; stub on others
ABR(config-router)# area 1 stub no-summary
! NSSA: every router in area
Rx(config-router)# area 2 nssa
! Totally NSSA: nssa no-summary on ABR; nssa on others
ABR(config-router)# area 2 nssa no-summary
Virtual links — rescuing a discontiguous backbone
All non-backbone areas must touch Area 0. If a remote area is separated from Area 0, a virtual link tunnels the adjacency through a transit area (must be a standard area — never stub).
ABR1(config-router)# area 1 virtual-link 3.3.3.3
ABR3(config-router)# area 1 virtual-link 2.2.2.2
ABR1# show ip ospf virtual-links
OSPFv2 vs OSPFv3 differences
| Aspect | OSPFv2 | OSPFv3 |
|---|---|---|
| Address family | IPv4 only | IPv6 native; IPv4 via Address Family extension (RFC 5838) |
| Adjacency | Subnet-based | Per-link (link-local addresses) |
| Router ID | 32-bit, often highest loopback | 32-bit, must be configured if no IPv4 address |
| Authentication | Plain/MD5 in OSPF header | Originally IPsec AH/ESP; now built-in keychains supported |
| New LSAs | — | Type 8 (Link-LSA), Type 9 (Intra-Area Prefix LSA) |
| Multicast | 224.0.0.5 / 224.0.0.6 | FF02::5 / FF02::6 |
OSPF authentication (named keychain — modern)
R1(config-keychain)# key 1
R1(config-keychain-key)# key-string Cisco123!
R1(config-keychain-key)# cryptographic-algorithm hmac-sha-256
R1(config)# interface Gi0/1
R1(config-if)# ip ospf authentication key-chain OSPF_KC
1.6 BGP — eBGP, iBGP, path selection, RR, communities
eBGP vs iBGP — the core distinction
| Aspect | eBGP | iBGP |
|---|---|---|
| Peers in | Different AS numbers | Same AS number |
| TTL by default | 1 (directly connected) | 255 (multi-hop OK) |
| AD | 20 | 200 |
| Next-hop on advertise | Changes to self | Preserved (use next-hop-self) |
| AS_PATH on advertise | Prepends own ASN | Unchanged |
| Loop prevention | AS_PATH check | Split horizon (no re-advertise iBGP→iBGP) |
| Topology required | Direct | Full mesh, OR Route Reflector, OR Confederation |
BGP path-selection algorithm — in order
For prefixes with multiple paths, BGP walks down this list, stopping at the first tie-breaker that picks a winner.
- Weight — highest (Cisco-only, local to router)
- LOCAL_PREF — highest (within an AS, default 100)
- Locally originated —
network/aggregate-address/redistributebeats learned - AS_PATH — shortest length
- Origin — IGP (i) > EGP (e) > Incomplete (?)
- MED — lowest (only compared within same neighboring AS)
- eBGP over iBGP — prefer external
- Lowest IGP metric to next-hop
- Older eBGP path (stability)
- Lowest router ID
- Shortest cluster list length (RR scenario)
- Lowest neighbor IP
Attribute classification
| Class | Attributes | Behavior |
|---|---|---|
| Well-known mandatory | AS_PATH, NEXT_HOP, ORIGIN | Must be in every UPDATE; recognized by all |
| Well-known discretionary | LOCAL_PREF, ATOMIC_AGGREGATE | Recognized by all; optional to send |
| Optional transitive | AGGREGATOR, COMMUNITY | Forwarded even if not understood |
| Optional non-transitive | MED, ORIGINATOR_ID, CLUSTER_LIST | Dropped if not understood |
iBGP scaling — Route Reflector (RR)
iBGP requires a full mesh (n(n-1)/2 sessions). Two solutions:
- Route Reflector — one router (RR) reflects routes between iBGP clients. Loop prevention via
ORIGINATOR_IDandCLUSTER_LIST. - Confederation — carve a single AS into sub-ASes, treat them like eBGP between them.
RR(config-router)# neighbor 10.1.1.1 remote-as 65000
RR(config-router)# neighbor 10.1.1.1 route-reflector-client
RR(config-router)# neighbor 10.1.1.2 remote-as 65000
RR(config-router)# neighbor 10.1.1.2 route-reflector-client
BGP communities — tags carried with routes
Communities are 32-bit values written as ASN:value. Commonly used to flag routes for downstream policy.
- NO_EXPORT — do not advertise outside local AS
- NO_ADVERTISE — do not advertise to any peer
- LOCAL_AS — do not advertise outside local sub-AS (in confederations)
- INTERNET — advertise everywhere (default)
R1(config-route-map)# match ip address prefix-list INFRA
R1(config-route-map)# set community 65000:100 no-export additive
R1(config)# router bgp 65000
R1(config-router)# neighbor 192.0.2.1 send-community
R1(config-router)# network 10.0.0.0 mask 255.0.0.0 route-map TAG_INFRA
Peer groups & peer templates
Apply a single configuration to many neighbors and reduce CPU cost (single UPDATE generated, replicated).
R1(config-router)# neighbor SPOKES remote-as 65000
R1(config-router)# neighbor SPOKES update-source Loopback0
R1(config-router)# neighbor SPOKES route-reflector-client
R1(config-router)# neighbor 10.1.1.1 peer-group SPOKES
R1(config-router)# neighbor 10.1.1.2 peer-group SPOKES
1.7 Route redistribution & filtering
Redistribution moves routes between protocols. Three problems must be managed: seed metrics, routing loops, and suboptimal routing.
Seed metrics — what to set when
| Into ↓ | Seed metric required? | How to specify |
|---|---|---|
| OSPF | Default = 20 (BGP=1). Use subnets keyword! |
redistribute eigrp 100 metric 100 subnets |
| EIGRP | Yes, required: BW, Delay, Reliability, Load, MTU | redistribute ospf 1 metric 10000 100 255 1 1500 |
| RIP | Yes, hop count | redistribute ospf 1 metric 5 |
| BGP | Optional (uses IGP metric as MED) | redistribute ospf 1 |
subnets keyword, only classful networks are redistributed. Subnets like 10.1.1.0/24 are silently dropped. Always use subnets.External route metric types
- OSPF E1 — cost = redistributed metric + cumulative path cost (changes per hop). Best when you want path selection to consider transit cost.
- OSPF E2 (default) — cost = redistributed metric only (does not change). Use when external metric should dominate.
- EIGRP external — AD 170 instead of 90.
- BGP origin code —
ifor network,?for redistribute.
Filtering tools at redistribution
| Tool | Granularity | Typical use |
|---|---|---|
| distribute-list ACL | Per prefix (no length match) | Quick filtering with std/ext ACL |
| distribute-list prefix | Per prefix & length | Precise prefix-length filtering |
| route-map (with deny seq) | Match anything, set anything | Tag-and-filter loop prevention |
| Tag (set tag / match tag) | Stamp routes for downstream filtering | Two-way redistribution loops |
| Modify AD per protocol | Whole protocol | Force one source to lose to another |
Mutual redistribution — the loop trap
1.8 Policy-Based Routing (PBR)
PBR overrides destination-based routing using a route-map applied to an interface. Match on source IP, application, packet length, ToS — then set next-hop, output interface, IP precedence, etc.
Configuration steps
- Define an ACL (or prefix-list) matching interesting traffic.
- Create a route-map with
match ip address&set ip next-hop. - Apply with
ip policy route-map NAMEon the ingress interface. - For traffic generated by the router itself:
ip local policy route-map NAMEin global config.
R1(config-ext-nacl)# permit udp any any range 16384 32767
R1(config)# route-map PBR_VOICE permit 10
R1(config-route-map)# match ip address VOICE
R1(config-route-map)# set ip next-hop verify-availability 10.0.0.1 10 track 1
R1(config-route-map)# set ip precedence 5
R1(config)# route-map PBR_VOICE permit 20 ! catch-all = normal routing
R1(config)# interface Gi0/0
R1(config-if)# ip policy route-map PBR_VOICE
show ip policy shows interfaces. show route-map shows match counters. debug ip policy shows live decisions (use carefully on production).PBR with object tracking (resilient PBR)
Combine PBR with track objects so the policy backs out automatically when the next-hop or SLA fails.
R1(config-ip-sla)# icmp-echo 10.0.0.1
R1(config-ip-sla)# frequency 5
R1(config)# ip sla schedule 1 life forever start-time now
R1(config)# track 1 ip sla 1 reachability
R1(config)# route-map PBR_VOICE permit 10
R1(config-route-map)# set ip next-hop verify-availability 10.0.0.1 10 track 1
Hands-on labs (8)
R1(config)# router eigrp HQ
R1(config-router)# address-family ipv4 unicast autonomous-system 100
R1(config-router-af)# network 10.0.0.0 0.255.255.255
R1(config-router-af)# af-interface Gi0/1
R1(config-router-af-int)# authentication mode hmac-sha-256 EnArSi2026
R1(config-router-af-int)# summary-address 10.10.0.0 255.255.0.0
R1(config-router-af-int)# exit-af-interface
! SPOKE (R2) — stub
R2(config)# router eigrp BRANCH
R2(config-router)# address-family ipv4 unicast autonomous-system 100
R2(config-router-af)# network 10.20.0.0 0.0.255.255
R2(config-router-af)# eigrp stub connected summary
R2(config-router-af)# af-interface Gi0/1
R2(config-router-af-int)# authentication mode hmac-sha-256 EnArSi2026
! Verify
R1# show eigrp address-family ipv4 neighbors detail
R1# show eigrp address-family ipv4 topology
R1# show ip protocols
! ^ NSSA
! ABR1 (Area 0 <-> Area 1) RID 1.1.1.1
ABR1(config)# router ospf 1
ABR1(config-router)# router-id 1.1.1.1
ABR1(config-router)# network 10.0.0.0 0.0.0.3 area 0
ABR1(config-router)# network 10.0.1.0 0.0.0.3 area 1
ABR1(config-router)# area 1 virtual-link 3.3.3.3
! ABR2 (Area 1 <-> Area 2 NSSA) RID 3.3.3.3
ABR2(config)# router ospf 1
ABR2(config-router)# router-id 3.3.3.3
ABR2(config-router)# network 10.0.1.0 0.0.0.3 area 1
ABR2(config-router)# network 10.0.2.0 0.0.0.3 area 2
ABR2(config-router)# area 2 nssa default-information-originate
ABR2(config-router)# area 1 virtual-link 1.1.1.1
! Internal router in NSSA Area 2
R5(config-router)# area 2 nssa
! Verify
ABR1# show ip ospf virtual-links
ABR2# show ip ospf database nssa-external
R5# show ip route ospf
R1(config)# key chain OSPFv3_KC
R1(config-keychain)# key 1
R1(config-keychain-key)# key-string Cisco123!
R1(config-keychain-key)# cryptographic-algorithm hmac-sha-256
R1(config)# router ospfv3 1
R1(config-router)# router-id 1.1.1.1
R1(config-router)# address-family ipv6 unicast
R1(config-router-af)# exit-address-family
R1(config)# interface Gi0/1
R1(config-if)# ipv6 address 2001:db8::1/64
R1(config-if)# ospfv3 1 ipv6 area 0
R1(config-if)# ospfv3 authentication key-chain OSPFv3_KC
R1# show ospfv3 neighbor
R1# show ipv6 route ospf
R1(config)# ip prefix-list TO_R2 seq 10 permit 10.1.0.0/16
R1(config)# ip prefix-list TO_R2 seq 20 permit 10.2.0.0/16
R1(config)# route-map OUT_TO_R2 permit 10
R1(config-route-map)# match ip address prefix-list TO_R2
R1(config-route-map)# set as-path prepend 65001 65001
R1(config)# router bgp 65001
R1(config-router)# bgp router-id 1.1.1.1
R1(config-router)# neighbor 192.0.2.2 remote-as 65002
R1(config-router)# neighbor 192.0.2.2 password Cisco123!
R1(config-router)# neighbor 192.0.2.2 route-map OUT_TO_R2 out
R1(config-router)# network 10.1.0.0 mask 255.255.0.0
R1(config-router)# network 10.2.0.0 mask 255.255.0.0
R1# show bgp ipv4 unicast summary
R1# show bgp ipv4 unicast neighbors 192.0.2.2 advertised-routes
RR(config)# ip community-list standard NO_EXP permit no-export
RR(config)# route-map FROM_CLIENT permit 10
RR(config-route-map)# match community NO_EXP
RR(config-route-map)# set local-preference 200
RR(config)# router bgp 65000
RR(config-router)# neighbor RR_CLIENTS peer-group
RR(config-router)# neighbor RR_CLIENTS remote-as 65000
RR(config-router)# neighbor RR_CLIENTS update-source Loopback0
RR(config-router)# neighbor RR_CLIENTS route-reflector-client
RR(config-router)# neighbor RR_CLIENTS send-community
RR(config-router)# neighbor RR_CLIENTS route-map FROM_CLIENT in
RR(config-router)# neighbor 10.0.0.2 peer-group RR_CLIENTS
RR(config-router)# neighbor 10.0.0.3 peer-group RR_CLIENTS
RR# show bgp ipv4 unicast 10.5.0.0
RR# show ip bgp neighbors 10.0.0.2 advertised-routes
! Outbound (OSPF -> EIGRP): tag with 1000
R1(config)# route-map OSPF_TO_EIGRP deny 10
R1(config-route-map)# match tag 2000 ! drop routes that came from EIGRP-side
R1(config)# route-map OSPF_TO_EIGRP permit 20
R1(config-route-map)# set tag 1000
! Outbound (EIGRP -> OSPF): tag with 2000
R1(config)# route-map EIGRP_TO_OSPF deny 10
R1(config-route-map)# match tag 1000 ! drop routes that came from OSPF-side
R1(config)# route-map EIGRP_TO_OSPF permit 20
R1(config-route-map)# set tag 2000
R1(config)# router ospf 1
R1(config-router)# redistribute eigrp 100 subnets route-map EIGRP_TO_OSPF
R1(config)# router eigrp 100
R1(config-router)# redistribute ospf 1 metric 10000 100 255 1 1500 route-map OSPF_TO_EIGRP
! Repeat the EXACT same config on R2 — tags carry across redistribution and stop the loop
R1(config)# ip access-list extended HR_TRAFFIC
R1(config-ext-nacl)# permit ip 10.10.10.0 0.0.0.255 any
R1(config)# ip sla 10
R1(config-ip-sla)# icmp-echo 198.51.100.1 source-interface Gi0/1
R1(config-ip-sla)# frequency 5
R1(config)# ip sla schedule 10 life forever start-time now
R1(config)# track 10 ip sla 10 reachability
R1(config)# route-map PBR_HR permit 10
R1(config-route-map)# match ip address HR_TRAFFIC
R1(config-route-map)# set ip next-hop verify-availability 198.51.100.1 1 track 10
R1(config)# interface Gi0/0
R1(config-if)# ip policy route-map PBR_HR
R1# show ip policy
R1# show route-map PBR_HR
R1# show track 10
R1(config)# route-map FROM_ISP1 permit 10
R1(config-route-map)# set local-preference 200 ! higher = preferred
R1(config)# route-map FROM_ISP2 permit 10
R1(config-route-map)# set local-preference 100 ! default
R1(config)# route-map TO_ISP2 permit 10
R1(config-route-map)# set as-path prepend 65001 65001 65001 ! make our routes look longer
R1(config)# router bgp 65001
R1(config-router)# neighbor 192.0.2.1 remote-as 64500
R1(config-router)# neighbor 192.0.2.1 route-map FROM_ISP1 in
R1(config-router)# neighbor 198.51.100.1 remote-as 64501
R1(config-router)# neighbor 198.51.100.1 route-map FROM_ISP2 in
R1(config-router)# neighbor 198.51.100.1 route-map TO_ISP2 out
R1# show bgp ipv4 unicast
R1# show bgp ipv4 unicast 0.0.0.0/0
Check Your Understanding
Twenty-five questions on this section. Each answer is explained as you go.
