Cisco IOS XR OSPF Configuration Examples (ASR 9000) - 夜莺博客

Cisco IOS XR OSPF Configuration Examples (ASR 9000)

OSPF configuration on Cisco IOS XR looks familiar to IOS engineers but works differently underneath: configuration is hierarchical, areas must be created explicitly, interfaces are bound to an area from inside area configuration mode, and nothing takes effect until you commit. Using the official ASR 9000 IOS XR routing guide examples, this article shows the minimal OSPFv2 setup, authentication, multi-area design and the commit workflow.

Why IOS XR OSPF Looks Different From IOS

IOS XR keeps the OSPF protocol semantics that IOS engineers already know — the same LSAs, the same SPF, the same DR/BDR election rules — but it replaces the flat, line-oriented configuration model with a hierarchical two-level commit model. Four consequences fall out of that design and explain almost every surprising error message you will see:

  • Configuration is hierarchical, not flat. Protocol configuration owns an explicit area submode, and interfaces are declared inside the area. IOS XR never infers an area from an interface address, so there is no network 10.0.0.0 0.0.0.255 area 0 statement anywhere.
  • Nothing takes effect until commit. Editing is done against a candidate configuration held by the configuration manager. If you exit without committing, your work is discarded — a behaviour that catches out engineers used to IOS applying changes as they type.
  • Interfaces are bound to protocols in protocol mode. The interface does not carry an ip ospf command. Instead, the protocol references the interface. IOS XR uses the same pattern for ISIS, MPLS LDP and RSVP, so it is worth internalising once.
  • Validation happens before apply. The parser rejects logically inconsistent configuration at commit time, which means fewer half-applied states and much less need for no commands to unwind a mistake.

Prerequisites and the Commit Model in Detail

Before configuring OSPF, confirm the interfaces exist, have addresses and are administratively up. On ASR 9000 you usually land on the RSP:

RP/0/RSP0/CPU0:router# show ipv4 interface brief
RP/0/RSP0/CPU0:router# show running-config interface GigabitEthernet 0/3/0/0

All configuration is performed in config mode. The commands worth knowing:

RP/0/RSP0/CPU0:router# configure
RP/0/RSP0/CPU0:router(config)# show configuration
RP/0/RSP0/CPU0:router(config)# commit confirmed 5
RP/0/RSP0/CPU0:router(config)# commit
RP/0/RSP0/CPU0:router(config)# abort
RP/0/RSP0/CPU0:router# show configuration commit list
RP/0/RSP0/CPU0:router# rollback configuration to 1000000012

Two of these deserve special attention. commit confirmed 5 applies the change but automatically rolls it back after five minutes unless you issue a second commit. On a remote router that is your safety net against an OSPF change that locks you out. And rollback configuration restores a previous commit by ID, which turns what would otherwise be a multi-hour outage into a single command. The companion technique is to review a pending change with show configuration before you apply it.

Minimal OSPFv2 Configuration

RP/0/RSP0/CPU0:router# configure
RP/0/RSP0/CPU0:router(config)# interface GigabitEthernet 0/3/0/0
RP/0/RSP0/CPU0:router(config-if)# ipv4 address 10.1.2.1 255.255.255.0
RP/0/RSP0/CPU0:router(config-if)# no shutdown
RP/0/RSP0/CPU0:router(config-if)# exit
RP/0/RSP0/CPU0:router(config)# router ospf 1
RP/0/RSP0/CPU0:router(config-ospf)# router-id 10.2.3.4
RP/0/RSP0/CPU0:router(config-ospf)# area 0
RP/0/RSP0/CPU0:router(config-ospf-ar)# interface GigabitEthernet 0/3/0/0
RP/0/RSP0/CPU0:router(config-ospf-ar-if)# exit
RP/0/RSP0/CPU0:router(config-ospf)# commit

Note two IOS XR quirks: area 0 must be configured explicitly (it is never implicit), and the interface is bound to the area by entering interface under the area - there is no network statement and no ip ospf keyword on the interface.

Interface Tuning Under the Area

OSPF interface parameters are configured hierarchically - area-level values are inherited by interfaces that do not override them:

RP/0/RSP0/CPU0:router(config)# router ospf 1
RP/0/RSP0/CPU0:router(config-ospf)# area 0
RP/0/RSP0/CPU0:router(config-ospf-ar)# interface GigabitEthernet 0/3/0/0
RP/0/RSP0/CPU0:router(config-ospf-ar-if)# cost 77
RP/0/RSP0/CPU0:router(config-ospf-ar-if)# hello-interval 10
RP/0/RSP0/CPU0:router(config-ospf-ar-if)# authentication message-digest
RP/0/RSP0/CPU0:router(config-ospf-ar-if)# message-digest-key 1 md5 0 test
RP/0/RSP0/CPU0:router(config-ospf-ar-if)# commit

Multi-Area Example

RP/0/RSP0/CPU0:router(config)# router ospf 1
RP/0/RSP0/CPU0:router(config-ospf)# router-id 10.2.3.4
RP/0/RSP0/CPU0:router(config-ospf)# area 0
RP/0/RSP0/CPU0:router(config-ospf-ar)# interface GigabitEthernet 0/3/0/0
RP/0/RSP0/CPU0:router(config-ospf-ar)# exit
RP/0/RSP0/CPU0:router(config-ospf)# area 1
RP/0/RSP0/CPU0:router(config-ospf-ar)# interface GigabitEthernet 0/3/0/1
RP/0/RSP0/CPU0:router(config-ospf-ar)# exit
RP/0/RSP0/CPU0:router(config-ospf)# commit

In IOS XR a single OSPF process can span multiple areas, and route summarization happens on the ABR with area <id> range. The process name can be a string up to 40 characters - engineers often name it after the role (for example router ospf core).

Area Types: Stub, Totally Stubby and NSSA

IOS XR expresses area types as keywords on the area statement rather than as a collection of interface commands. The topology below makes area 1 a totally stubby area, so it receives no Type 3, 4 or 5 LSAs and relies entirely on a default route injected by the ABR from area 0:

RP/0/RSP0/CPU0:router(config)# router ospf 1
RP/0/RSP0/CPU0:router(config-ospf)# router-id 10.2.3.4
RP/0/RSP0/CPU0:router(config-ospf)# area 0
RP/0/RSP0/CPU0:router(config-ospf-ar)# interface GigabitEthernet 0/3/0/0
RP/0/RSP0/CPU0:router(config-ospf-ar)# exit
RP/0/RSP0/CPU0:router(config-ospf)# area 1
RP/0/RSP0/CPU0:router(config-ospf-ar)# stub no-summary
RP/0/RSP0/CPU0:router(config-ospf-ar)# interface GigabitEthernet 0/3/0/1
RP/0/RSP0/CPU0:router(config-ospf-ar)# commit

For an NSSA that also needs to carry external routes, replace stub with nssa and add default-information-originate where the ABR should inject a default. Redistribution of connected or static routes into the domain is done under the OSPF process with redistribute, and external metrics are controlled per statement:

RP/0/RSP0/CPU0:router(config-ospf)# redistribute connected
RP/0/RSP0/CPU0:router(config-ospf)# redistribute static metric 100 metric-type 2
RP/0/RSP0/CPU0:router(config-ospf)# redistribute bgp 65000 metric 20 metric-type 1
RP/0/RSP0/CPU0:router(config-ospf)# commit

Type 1 externals are preferred over Type 2 externals and have their internal cost added to the metric; Type 2 externals use the advertised metric alone. Choosing the wrong type is a classic way to create suboptimal exit selection between two border routers.

Route Summarisation on the ABR and ASBR

IOS XR performs inter-area summarisation with area range, configured on the ABR inside the area whose routes are being summarised. External summarisation uses summary-address on the ASBR.

RP/0/RSP0/CPU0:router(config)# router ospf 1
RP/0/RSP0/CPU0:router(config-ospf)# area 1
RP/0/RSP0/CPU0:router(config-ospf-ar)# range 10.10.0.0 255.255.0.0
RP/0/RSP0/CPU0:router(config-ospf-ar)# commit
RP/0/RSP0/CPU0:router(config-ospf)# summary-address 172.16.0.0 255.255.252.0
RP/0/RSP0/CPU0:router(config-ospf)# commit

Add not-advertise to a range or summary to suppress the component routes entirely without advertising the aggregate, which is a clean way to filter at the boundary of a domain.

Timers, Authentication and Fast Convergence

Interface timers, authentication and network type are all set inside the area's interface submode. The example below uses hello/dead timers of 3 and 12 seconds, MD5 authentication, point-to-point network type and BFD for sub-second failure detection:

RP/0/RSP0/CPU0:router(config)# router ospf 1
RP/0/RSP0/CPU0:router(config-ospf)# area 0
RP/0/RSP0/CPU0:router(config-ospf-ar)# interface GigabitEthernet 0/3/0/0
RP/0/RSP0/CPU0:router(config-ospf-ar-if)# network point-to-point
RP/0/RSP0/CPU0:router(config-ospf-ar-if)# hello-interval 3
RP/0/RSP0/CPU0:router(config-ospf-ar-if)# dead-interval 12
RP/0/RSP0/CPU0:router(config-ospf-ar-if)# authentication message-digest
RP/0/RSP0/CPU0:router(config-ospf-ar-if)# message-digest-key 1 md5 clear test123
RP/0/RSP0/CPU0:router(config-ospf-ar-if)# bfd fast-detect
RP/0/RSP0/CPU0:router(config-ospf-ar-if)# commit

IOS XR uses clear or encrypted to indicate whether the supplied key is plaintext or already hashed, so message-digest-key 1 md5 0 test and md5 clear test are equivalent forms; the numeric form is what appears in show output. In security-sensitive environments, key chain authentication with authentication keychain allows time-based key rotation without an outage.

OSPFv3 for IPv6

IPv6 uses a separate address family and a separate process. On IOS XR the OSPFv3 process is configured with router ospfv3 and interfaces are enabled under the area exactly as with OSPFv2:

RP/0/RSP0/CPU0:router(config)# router ospfv3 1
RP/0/RSP0/CPU0:router(config-ospfv3)# router-id 10.2.3.4
RP/0/RSP0/CPU0:router(config-ospfv3)# area 0
RP/0/RSP0/CPU0:router(config-ospfv3-ar)# interface GigabitEthernet 0/3/0/0
RP/0/RSP0/CPU0:router(config-ospfv3-ar-if)# commit

If you are migrating from IPv4, the practical order is: enable IPv6 unicast routing, address the links, bring OSPFv3 up in parallel with OSPFv2, verify adjacency and prefix exchange, then remove OSPFv2 from the links one at a time. Running both in parallel during the change window is far safer than an in-place cut-over.

Multi-VRF and Per-VRF OSPF

For MPLS L3VPN PE routers, each VRF runs its own OSPF instance bound to the VRF with the vrf keyword under the router statement:

RP/0/RSP0/CPU0:router(config)# vrf CUSTOMER-A
RP/0/RSP0/CPU0:router(config-vrf)# address-family ipv4 unicast
RP/0/RSP0/CPU0:router(config-vrf-af)# commit
RP/0/RSP0/CPU0:router(config)# router ospf 100
RP/0/RSP0/CPU0:router(config-ospf)# vrf CUSTOMER-A
RP/0/RSP0/CPU0:router(config-ospf)# router-id 10.99.0.1
RP/0/RSP0/CPU0:router(config-ospf)# area 0
RP/0/RSP0/CPU0:router(config-ospf-ar)# interface GigabitEthernet 0/3/0/2
RP/0/RSP0/CPU0:router(config-ospf-ar-if)# commit

Redistribution between the per-VRF OSPF and the provider's BGP is then done inside that VRF, which keeps customer routing information perfectly separate from the global table.

Verification and Troubleshooting Commands

Verification on IOS XR is largely familiar, with a few XR-specific additions:

RP/0/RSP0/CPU0:router# show ospf neighbor
RP/0/RSP0/CPU0:router# show ospf neighbor detail
RP/0/RSP0/CPU0:router# show ospf interface GigabitEthernet 0/3/0/0
RP/0/RSP0/CPU0:router# show ospf database
RP/0/RSP0/CPU0:router# show ospf routes
RP/0/RSP0/CPU0:router# show ospf statistics
RP/0/RSP0/CPU0:router# show route ospf
RP/0/RSP0/CPU0:router# show log | include OSPF

Common failure modes and what they point to:

  • Neighbors stuck in INIT or EXSTART. One-way communication, an MTU mismatch (IOS XR does not fragment OSPF packets) or a duplicate router ID. Check show ospf interface for the MTU and show logging for the router-ID conflict message.
  • Neighbors in EXCHANGE forever. Almost always an MTU mismatch or a database exchange broken by an interface that flaps under load.
  • Adjacency forms but no routes. The interface may be passive, or the area IDs may disagree — a mismatch produces a log message but no adjacency.
  • Stub area mismatch. The stub flag must match on every router in the area; the router with the mismatch refuses the adjacency and logs the reason.
  • Authentication failure. Key ID or key value mismatch. Authentication counters are visible in show ospf statistics.

Common Configuration Mistakes

Four mistakes account for most XR OSPF trouble tickets. First, forgetting commit — the configuration looks correct in show configuration but is not running. Second, expecting an implicit area 0: XR requires the explicit area 0 submode, and an interface that is never bound to an area simply does not participate. Third, using IOS network statement syntax out of habit; the parser rejects it, and engineers sometimes conclude that XR "does not support OSPF" rather than that they used the wrong syntax. Fourth, putting interface parameters at the wrong level: values set at the area level are inherited, so a cost entered under the area applies to every interface unless overridden, which can silently distort path selection across a whole area.

The Commit Workflow

IOS XR does not apply changes line by line: uncommitted changes sit in a candidate configuration. commit applies them, end prompts you to commit before exiting, and show configuration displays the pending diff. Verification uses classic commands:

RP/0/RSP0/CPU0:router# show ospf neighbor
RP/0/RSP0/CPU0:router# show ospf database
RP/0/RSP0/CPU0:router# show route ospf

Related Reading on This Site

Start with IOS XR CLI basics and command modes and see ASR9000 fabric troubleshooting for the hardware side. For the theory behind what you are configuring, read OSPF LSA types explained and the stub and NSSA area design guide; if you also run Cisco data-centre gear, compare the syntax with OSPF on Nexus NX-OS.

原文链接:https://www.cisco.com/c/en/us/td/docs/routers/asr9000/software/710x/routing/configuration/guide/b-routing-cg-asr9000-710x/implementing-ospf.html