Configuring OSPFv2

This section contains payload examples to demonstrate how to use the NX-API REST API to configure OSPFv2 on the Cisco Nexus 3000 and 9000 Series switches.

Guidelines and Restrictions

  1. OSPFv2 operational support is not available through NX-API in releases earlier than Cisco NX-OS 7.0(3)I5(1).
  2. When configuring interface settings in a POST operation, you must always specify the desired area. If no area attribute is specified, the operation is applied to area 1.
  3. If an interface is configured with area="0.0.0.0", the REST GET for the interface MO shows area="backbone".
  4. Operational information objects (status and statistics) are maintained only for a single OSPF instance. When multiple OSPF instances exist, operational information is not supported.
  5. When configuring or querying an OSPFv2 interface, do not use the ospfInternalIf managed object. Use ospfIf instead.

For other CLI options, see the Cisco Nexus 9000 Series NX-OS Command Reference: http://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-command-reference-list.html

Enabling OSPFv2

Enabling OSPFv2
POST http://<mgmt0_IP>/api/mo/sys.json
{
  "topSystem": {
    "children": [
      {
        "fmEntity": {
          "children": [
            {
              "fmOspf": {
                "attributes": {
                  "adminSt": "enabled"
                }
              }
            }
          ]
        }
      }
    ]
  }
}
{
    imdata:[]
}
<System>
  <fm-items>
      <adminSt>enabled</adminSt>
  </fm-items>
</System>

Note: This example was added in Release 7.0(3)I7(3).


CLI Commands

The CLI commands are equivalent to the payload examples displayed in the pane on the right. Click the DME tab in the top-left corner of the right pane to view the JSON payload. Click the YANG tab to view the XML payload.

feature ospf

For other CLI options, see the Cisco Nexus 9000 Series NX-OS Command Reference: http://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-command-reference-list.html

See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/

For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html

Disabling OSPFv2

Disabling OSPFv2
POST http://<mgmt0_IP>/api/mo/sys.json
{
  "topSystem": {
    "children": [
      {
        "fmEntity": {
          "children": [
            {
              "fmOspf": {
                "attributes": {
                  "adminSt": "disabled"
                }
              }
            }
          ]
        }
      }
    ]
  }
}
{
    imdata:[]
}
<System>
  <fm-items>
      <adminSt>disabled</adminSt>
  </fm-items>
</System>

Note: This example was added in Release 7.0(3)I7(3).


CLI Commands

The CLI commands are equivalent to the payload examples displayed in the pane on the right. Click the DME tab in the top-left corner of the right pane to view the JSON payload. Click the YANG tab to view the XML payload.

no feature ospf

For other CLI options, see the Cisco Nexus 9000 Series NX-OS Command Reference: http://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-command-reference-list.html

See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/

For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html

Configuring Optional Parameters on an OSPFv2 Instance

Configuring Optional Parameters on an OSPFv2 Instance
POST http://<IP_Address>/api/node/mo/sys/ospf/inst.json
 {
  "ospfInst": {
    "attributes": {
      "name": "my_ospf"
    },
    "children": [
      {
        "ospfDom": {
          "attributes": {
            "adjChangeLogLevel": "brief",
            "ctrl": "default-passive,name-lookup",
            "dist": "25",
            "maxEcmp": "4",
            "name": "default",
            "rtrId": "192.0.20.1"
}}}]}}
{
    imdata:[]
}
POST:  http://<IP_Address>/restconf/data/Cisco-NX-OS-device:
<System>
  <ospf-items>
    <inst-items>
      <Inst-list>
        <name>my_ospf</name>
        <dom-items>
          <Dom-list>
            <name>default</name>
            <adjChangeLogLevel>brief</adjChangeLogLevel>
            <ctrl>default-passive,name-lookup</ctrl>
            <dist>25</dist>
            <maxEcmp>4</maxEcmp>
            <rtrId>192.0.20.1</rtrId>
          </Dom-list>
        </dom-items>
      </Inst-list>
    </inst-items>
  </ospf-items>
</System>

You can configure optional parameters for OSPF.


CLI Commands

The CLI commands and options listed below are the equivalent to the payload example displayed in the pane on the right.

router ospf my_ospf
 router-id 192.0.20.1
 distance 25
 log-adjacency-changes
 maximum-paths 4
 passive-interface default
 name-lookup

For other CLI options, see the Cisco Nexus 9000 Series NX-OS Command Reference: http://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-command-reference-list.html

See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/

For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html

Configuring Networks in OSPFv2

Configuring Networks in OSPFv2
POST http://<IP_Address>/api/node/mo/sys.json
{
  "topSystem": {
    "children": [
      {
        "ipv4Entity": {
          "children": [
            {
              "ipv4Inst": {
                "children": [
                  {
                    "ipv4Dom": {
                      "attributes": {
                        "name": "default"
                      },
                      "children": [
                        {
                          "ipv4If": {
                            "attributes": {
                              "id": "eth1/2"
                            },
                            "children": [
                              {
                                "ipv4Addr": {
                                  "attributes": {
                                    "addr": "192.0.20.1/16"
}}}]}}]}}]}}]}},{
"ospfEntity": {
  "children": [
    {
      "ospfInst": {
        "attributes": {
          "name": "201"
        },
        "children": [
          {
            "ospfDom": {
              "attributes": {
                "name": "default"
              },
              "children": [
                {
                  "ospfIf": {
                    "attributes": {
                      "adminSt": "enabled",
                      "advertiseSecondaries": "no",
                      "area": "0.0.0.15",
                      "cost": "25",
                      "ctrl": "mtu-ignore",
                      "deadIntvl": "50",
                      "helloIntvl": "25",
                      "id": "eth1/2",
                      "passiveCtrl": "enabled",
                      "prio": "25"
}}}]}}]}}]}}]}}
{
    imdata:[]
}
POST:  http://<IP_Address>/restconf/data/Cisco-NX-OS-device:
<System>
  <ipv4-items>
    <inst-items>
      <dom-items>
        <Dom-list>
          <name>default</name>
          <if-items>
            <If-list>
              <id>eth1/2</id>
              <addr-items>
                <Addr-list>
                  <addr>192.0.20.1/16</addr>
                </Addr-list>
              </addr-items>
            </If-list>
          </if-items>
        </Dom-list>
      </dom-items>
    </inst-items>
  </ipv4-items>
  <ospf-items>
    <inst-items>
      <Inst-list>
        <name>201</name>
        <dom-items>
          <Dom-list>
            <name>default</name>
            <if-items>
              <If-list>
                <id>eth1/2</id>
                <adminSt>enabled</adminSt>
                <advertiseSecondaries>false</advertiseSecondaries>
                <area>0.0.0.15</area>
                <cost>25</cost>
                <ctrl>mtu-ignore</ctrl>
                <deadIntvl>50</deadIntvl>
                <helloIntvl>25</helloIntvl>
                <passiveCtrl>enabled</passiveCtrl>
                <prio>25</prio>
              </If-list>
            </if-items>
          </Dom-list>
        </dom-items>
      </Inst-list>
    </inst-items>
  </ospf-items>
</System>

You can configure a network to OSPFv2 by associating it through the interface that the router uses to connect to that network. You can add all networks to the default backbone area (Area 0), or you can create new areas using any decimal number or an IP address.

Prerequisite: The interface eth1/9 is already configured.


CLI Commands

The CLI commands and options listed below are the equivalent to the payload example displayed in the pane on the right.

interface eth1/9
 ip address 192.0.20.1/16
 ip router ospf 201 area 0.0.0.15 secondaries none
 ip ospf cost 25
 ip ospf dead-interval 50
 ip ospf hello-interval 25
 ip ospf mtu-ignore
 ip ospf passive-interface
 ip ospf priority 25
 no ip ospf shutdown

For other CLI options, see the Cisco Nexus 9000 Series NX-OS Command Reference: http://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-command-reference-list.html

See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/

For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html

Configuring a Virtual Link
POST http://<IP_Address>/api/node/mo/sys/ospf/inst.json
{
  "ospfInst": {
    "attributes": {
      "name": "my_ospf"
    },
    "children": [
      {
        "ospfDom": {
          "attributes": {
            "name": "default"
          },
          "children": [
            {
              "ospfArea": {
                "attributes": {
                  "id": "0.0.0.10"
                },
                "children": [
                  {
                    "ospfVLink": {
                      "attributes": {
                        "deadIntvl": "50",
                        "helloIntvl": "25",
                        "nbrRtrId": "10.1.2.3",
                        "rexmitIntvl": "60",
                        "xmitDelay": "2"
                      },
                      "children": [
                        {
                          "ospfAuthNewP": {
                            "attributes": {
                              "keyId": "3",
                              "md5key": "3 6260a55332988492d5666ab77a685d71",
                              "md5keySecureMode": "yes",
                              "type": "md5"
}}}]}}]}}}}}}
{
    imdata:[]
}
POST:  http://<IP_Address>/restconf/data/Cisco-NX-OS-device:
<System>
  <ospf-items>
    <inst-items>
      <Inst-list>
        <name>my_ospf</name>
        <dom-items>
          <Dom-list>
            <name>default</name>
            <area-items>
              <Area-list>
                <id>0.0.0.10</id>
                <vlink-items>
                  <VLink-list>
                    <nbrRtrId>10.1.2.3</nbrRtrId>
                    <deadIntvl>50</deadIntvl>
                    <helloIntvl>25</helloIntvl>
                    <rexmitIntvl>60</rexmitIntvl>
                    <xmitDelay>2</xmitDelay>
                    <authnew-items>
                      <keyId>3</keyId>
                      <md5key>3 6260a55332988492d5666ab77a685d71</md5key>
                      <md5keySecureMode>true</md5keySecureMode>
                      <type>md5</type>
                    </authnew-items>
                  </VLink-list>
                </vlink-items>
              </Area-list>
            </area-items>
          </Dom-list>
        </dom-items>
      </Inst-list>
    </inst-items>
  </ospf-items>
</System>

A virtual link connects an isolated area to the backbone area through an intermediate area.


CLI Commands

The CLI commands and options listed below are the equivalent to the payload example displayed in the pane on the right.

router ospf my_ospf
 area 0.0.0.10 virtual-link 10.1.2.3
 dead-interval 50
 hello-interval 25
 retransmit-interval 60
 transmit-delay 2
 authentication message-digest
 message-digest-key 3 md5 asdflkj1234

For other CLI options, see the Cisco Nexus 9000 Series NX-OS Command Reference: http://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-command-reference-list.html

See the NX-API DME Model Reference for detailed information about classes and attributes described in the payload: https://developer.cisco.com/site/nx-os/docs/nexus-model-reference/

For information about using the payloads, see the Cisco Nexus 9000 Series NX-OS Programmability Guide https://www.cisco.com/c/en/us/support/switches/nexus-9000-series-switches/products-programming-reference-guides-list.html