Cisco Nexus NX-OS OSPF Configuration with Examples - 夜莺博客

Cisco Nexus NX-OS OSPF Configuration with Examples

NX-OS OSPF configuration differs from classic IOS in several important ways: you must enable the protocol with feature ospf, interfaces join the process with ip router ospf instead of a network statement, and areas are always displayed in dotted-decimal notation. This guide walks through OSPFv2 setup on Nexus 3000/7000/9000 switches - enabling the feature, creating the process, assigning interfaces to areas, tuning timers and authentication, and verifying neighbors - based on the official Cisco NX-OS unicast routing configuration guide.

Step 1: Enable the OSPF Feature

switch(config)# feature ospf

Without this line NX-OS rejects the router ospf command - it is the most common first-time mistake.

Step 2: Create the OSPF Process and Router-ID

switch(config)# router ospf 201
switch(config-router)# router-id 192.0.2.1
switch(config-router)# exit

NX-OS supports multiple OSPF instances per VDC/VRF. Set the router-id explicitly to avoid instability when interfaces flap and change the auto-selected ID.

Step 3: Assign Layer-3 Interfaces to Areas

Routed interfaces join the process per interface - no network statements:

switch(config)# interface ethernet 1/2
switch(config-if)# no switchport
switch(config-if)# ip address 192.0.2.1/30
switch(config-if)# ip router ospf 201 area 0.0.0.0
switch(config-if)# no shutdown

For an area other than backbone use e.g. ip router ospf 201 area 0.0.0.10 (dotted decimal) or area 10.

Optional: Timers, Authentication and Stub Areas

switch(config)# interface ethernet 1/2
switch(config-if)# ip ospf cost 100
switch(config-if)# ip ospf hello-interval 5
switch(config-if)# ip ospf dead-interval 20
switch(config-if)# ip ospf authentication message-digest
switch(config-if)# ip ospf message-digest-key 1 md5 7 <encrypted-key>
switch(config-router)# area 0.0.0.10 stub
switch(config-router)# area 0.0.0.10 default-cost 20

Stub and totally-stubby areas (area 20 stub no-summary) reduce LSA flooding in large fabrics, and NSSA handles external routes through the ASBR.

Verification Commands

switch# show ip ospf
switch# show ip ospf neighbor
switch# show ip ospf interface ethernet 1/2
switch# show ip ospf route
switch# show ip ospf database summary

Related Guides on This Site

OSPF is usually the underlay for vPC and VXLAN designs: see NX-OS vPC configuration, the IOS XR OSPF examples for a comparison, and OSPF LSA types explained to understand what the database should contain.

原文链接:https://www.cisco.com/c/en/us/td/docs/switches/datacenter/nexus7000/sw/unicast/config/cisco_nexus7000_unicast_routing_config_guide_8x/configuring_ospfv2.html