Configuring Static Routes

Static routes are route table entries that you manually configure. These static routes do not change unless you reconfigure them. Static routes are simple to design and work well in environments where network traffic is relatively predictable and where network design is relatively simple.

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

Configuring an IPv4 Static Route

Configuring an IPv4 Static Route
POST http://<mgmt0_IP>/api/mo/sys/ipv4/inst.json
{
  "ipv4Inst": {
    "children": [
      {
        "ipv4Dom": {
          "attributes": {
            "name": "default"
          },
          "children": [
            {
              "ipv4Route": {
                "attributes": {
                  "prefix": "192.0.0.0/8"
                },
                "children": [
                  {
                    "ipv4Nexthop": {
                      "attributes": {
                        "nhAddr": "192.0.2.4/32",
                        "nhIf": "eth1/8",
                        "nhVrf": "default",
                        "pref": "1",
                        "rtname": "StatRt5",
                        "tag": "1234"
}}}]}}]}}]}}
{
    imdata:[]
}
<System>
  <ipv4-items>
    <inst-items>
      <dom-items>
        <Dom-list>
          <name>default</name>
          <rt-items>
            <Route-list>
              <prefix>192.0.0.0/8</prefix>
              <nh-items>
                <Nexthop-list>
                  <nhIf>eth1/8</nhIf>
                  <nhAddr>192.0.2.4/32</nhAddr>
                  <nhVrf>default</nhVrf>
                  <pref>1</pref>
                  <rtname>StatRt5</rtname>
                  <tag>1234</tag>
                </Nexthop-list>
              </nh-items>
            </Route-list>
          </rt-items>
        </Dom-list>
      </dom-items>
    </inst-items>
  </ipv4-items>
</System>

Configures an IPv4 unicast static route.


CLI Command

The CLI command below is the equivalent to the payload example 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 or the YANG tab to view the XML payload.

ip route 192.0.2.0/8 ethernet 1/8 192.0.2.4 name StatRt5 tag 1234 1

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 an IPv6 Static Route

Configuring an IPv6 Static Route
POST http://<mgmt0_IP>/api/mo/sys/ipv6/inst.json
{
"ipv6Inst": {
 "children": [
{
"ipv6Dom": {
  "attributes": {
    "name": "default"
},
"children": [
{
  "ipv6Route": {
    "attributes": {
      "prefix": "2001:db8::/48"
    },
    "children": [
      {
        "ipv6Nexthop": {
          "attributes": {
            "nhAddr": "6::6/128",
            "nhIf": "eth2/1",
            "nhVrf": "default",
            "pref": "1",
            "rtname": "StatRtV6-5",
            "tag": "1234"
}}}]}}]}}]}}
{
    imdata:[]
}
<System>
  <ipv6-items>
    <inst-items>
      <dom-items>
        <Dom-list>
          <name>default</name>
          <rt-items>
            <Route-list>
              <prefix>2001:db8::/48</prefix>
              <nh-items>
                <Nexthop-list>
                  <nhIf>eth2/1</nhIf>
                  <nhAddr>6::6/128</nhAddr>
                  <nhVrf>default</nhVrf>
                  <pref>1</pref>
                  <rtname>StatRtV6-5</rtname>
                  <tag>1234</tag>
                </Nexthop-list>
              </nh-items>
            </Route-list>
          </rt-items>
        </Dom-list>
      </dom-items>
    </inst-items>
  </ipv6-items>
</System>

Configures an IPv6 unicast static route.


CLI Command

The CLI command below is the equivalent to the payload example 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 or the YANG tab to view the XML payload.

ipv6 route 2001:db8::/48 6::6 eth2/1 name StatRtV6-5 tag 1234 1

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 an IPv4 Static Route with BFD

Configuring an IPv4 Static Route with BFD
POST http://<mgmt0_IP>/api/mo/sys/ipv4/inst.json
{
"ipv4Inst": {
 "children": [
{
"ipv4Dom": {
  "attributes": {
    "name": "default"
},
"children": [
{
  "ipv4RtStaticBfd": {
    "attributes": {
      "intf": "eth1/9",
      "nexthop": "192.0.20.123"
}}}]}}]}}
{
    imdata:[]
}
<System>
  <ipv4-items>
    <inst-items>
      <dom-items>
        <Dom-list>
          <name>default</name>
          <rtstaticbfd-items>
            <RtStaticBfd-list>
              <intf>eth1/9</intf>
              <nexthop>192.0.20.123</nexthop>
            </RtStaticBfd-list>
          </rtstaticbfd-items>
        </Dom-list>
      </dom-items>
    </inst-items>
  </ipv4-items>
</System>

Enables BFD for all static routes on an interface. Use the? keyword to display the supported interfaces.

Prerequisite: BFD is enabled


CLI Command

The CLI command below is the equivalent to the payload example 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 or the YANG tab to view the XML payload.

ip route static bfd eth1/9 192.0.20.123

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

Deleting an IPv4 Static Route

Deleting an IPv4 Static Route
POST http://<mgmt0_IP>/api/mo/sys/ipv4/inst.json
{
"ipv4Inst": {
"children": [
{
"ipv4Dom": {
  "attributes": {
    "name": "default"
},
"children": [
{
  "ipv4Route": {
    "attributes": {
      "prefix": "192.0.0.0/8"
},
    "children": [
      {
        "ipv4Nexthop": {
          "attributes": {
            "nhAddr": "192.0.2.4",
            "nhIf": "eth1/8",
            "nhVrf": "default",
            "status": "deleted"
}}}]}}]}}]}}
{
    imdata:[]
}
<System>
  <ipv4-items>
    <inst-items>
      <dom-items>
        <Dom-list>
          <name>default</name>
          <rt-items>
            <Route-list>
              <prefix>192.0.0.0/8</prefix>
              <nh-items>
                <Nexthop-list xc:operation="delete">
                  <nhIf>eth1/8</nhIf>
                  <nhAddr>192.0.2.4</nhAddr>
                  <nhVrf>default</nhVrf>
                </Nexthop-list>
              </nh-items>
            </Route-list>
          </rt-items>
        </Dom-list>
      </dom-items>
    </inst-items>
  </ipv4-items>
</System>

Deletes an IPv4 static route.


CLI Command

The CLI command below is the equivalent to the payload example 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 or the YANG tab to view the XML payload.

no ip route 192.0.2.0/8 ethernet 1/8 192.0.2.4

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

Specifying a Next-Hop Address

Specifying an IPv4 Next-Hop Address
POST http://<mgmt0_IP>/api/mo/sys/ipv4/inst.json
{
"ipv4Inst": {
 "children": [
{
"ipv4Dom": {
  "attributes": {
    "name": "default"
},
"children": [
{
  "ipv4Route": {
    "attributes": {
      "prefix": "0.0.0.0/1"
},
"children": [
{
"ipv4Nexthop": {
  "attributes": {
    "nhAddr": "2.2.2.2/32",
    "nhIf": "unspecified",
    "nhVrf": "default"
}}}]}}]}}]}}
{
    imdata:[]
}
<System>
  <ipv4-items>
    <inst-items>
      <dom-items>
        <Dom-list>
          <name>default</name>
          <rt-items>
            <Route-list>
              <prefix>0.0.0.0/1</prefix>
              <nh-items>
                <Nexthop-list>
                  <nhIf>unspecified</nhIf>
                  <nhAddr>2.2.2.2/32</nhAddr>
                  <nhVrf>default</nhVrf>
                </Nexthop-list>
              </nh-items>
            </Route-list>
          </rt-items>
        </Dom-list>
      </dom-items>
    </inst-items>
  </ipv4-items>
</System>

Configures an IPv4 next hop.


CLI Command

The CLI command below is the equivalent to the payload example 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 or the YANG tab to view the XML payload.

ip route 1.1.1.1/1 2.2.2.2

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

Specifying an IPv6 Next-Hop Address

Specifying an IPv6 Next-Hop Address
POST http://<mgmt0_IP>/api/mo/sys/ipv6/inst.json
{
"ipv6Inst": {
 "children": [
{
"ipv6Dom": {
  "attributes": {
    "name": "default"
},
"children": [
{
  "ipv6Route": {
    "attributes": {
      "prefix": "2:3::4:5/3"
},
"children": [
  {
    "ipv6Nexthop": {
      "attributes": {
        "nhAddr": "1:2::3:4/128",
        "nhIf": "eth1/1",
        "nhVrf": "default"
}}}]}}]}}]}}
{
    imdata:[]
}
<System>
  <ipv6-items>
    <inst-items>
      <dom-items>
        <Dom-list>
          <name>default</name>
          <rt-items>
            <Route-list>
              <prefix>2:3::4:5/3</prefix>
              <nh-items>
                <Nexthop-list>
                  <nhIf>eth1/1</nhIf>
                  <nhAddr>1:2::3:4/128</nhAddr>
                  <nhVrf>default</nhVrf>
                </Nexthop-list>
              </nh-items>
            </Route-list>
          </rt-items>
        </Dom-list>
      </dom-items>
    </inst-items>
  </ipv6-items>
</System>

Configures an IPv6 unicast static route.


CLI Command

The CLI command below is the equivalent to the payload example 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 or the YANG tab to view the XML payload.

ipv6 route 2:3::4:5/3 ethernet 1/1 1:2::3:4

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 IP Static Routes on an Interface

Configuring IP Static Routes on an Interface
POST http://<mgmt0_IP>/api/mo/sys/ipv4/inst.json
{
"ipv4Inst": {
"children": [
{
"ipv4Dom": {
  "attributes": {
    "name": "default"
},
"children": [
{
  "ipv4RtStaticBfd": {
    "attributes": {
      "intf": "eth1/1",
      "nexthop": "2.2.2.2"
}}}]}}]}}
{
    imdata:[]
}
<System>
  <ipv4-items>
    <inst-items>
      <dom-items>
        <Dom-list>
          <name>default</name>
          <rtstaticbfd-items>
            <RtStaticBfd-list>
              <intf>eth1/1</intf>
              <nexthop>2.2.2.2</nexthop>
            </RtStaticBfd-list>
          </rtstaticbfd-items>
        </Dom-list>
      </dom-items>
    </inst-items>
  </ipv4-items>
</System>

Enables BFD detection on a static route.


CLI Command

The CLI command below is the equivalent to the payload example 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 or the YANG tab to view the XML payload.

interface ethernet1/1
 ip route static bfd ethernet1/1 2.2.2.2

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 IPv6 Static Routes on an Interface

Configuring IPv6 Static Routes
POST http://<mgmt0_IP>/api/mo/sys/ipv6/inst.json
{
"ipv6Inst": {
"children": [
{
"ipv6Dom": {
  "attributes": {
    "name": "default"
},
"children": [
{
  "ipv6RtStaticBfd": {
    "attributes": {
      "intf": "eth1/1",
      "nexthop": "2:4::6:8/128"
}}}]}}]}}
{
    imdata:[]
}
<System>
  <ipv6-items>
    <inst-items>
      <dom-items>
        <Dom-list>
          <name>default</name>
          <rtstaticbfd-items>
            <RtStaticBfd-list>
              <intf>eth1/1</intf>
              <nexthop>1:2::3:42/128</nexthop>
            </RtStaticBfd-list>
          </rtstaticbfd-items>
        </Dom-list>
      </dom-items>
    </inst-items>
  </ipv6-items>
</System>

Enables BFD detection on a static route.


CLI Command

The CLI command below is the equivalent to the payload example 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 or the YANG tab to view the XML payload.

interface ethernet1/1
 ipv6 route static bfd ethernet1/1 2:4::6:8

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

Querying an IPv4 Static Route

Querying an IPv4 Static Route
GET http://<IP_Address>/api/node/mo/sys/ipv4/inst/dom-default/rt-[192.0.0.0/8].json
{
  "totalCount": "1",
  "imdata": [
{
  "ipv4Route": {
    "attributes": {
      "childAction": "",
      "ctrl": "",
      "descr": "",
      "dn": "sys/ipv4/inst/dom-default/rt-[192.0.0.0/8]",
      "modTs": "2016-12-16T00:41:12.115+00:00",
      "monPolDn": "uni/fabric/monfab-default",
      "name": "",
      "pcTag": "any",
      "persistentOnReload": "true",
      "pref": "1",
      "prefix": "192.0.0.0/8",
      "status": "",
      "tag": "0"
},
"children": [
  {
    "ipv4Nexthop": {
      "attributes": {
        "childAction": "",
        "descr": "",
        "flags": "",
        "ipv4CfgFailedBmp": "",
        "ipv4CfgFailedTs": "00:00:00:00.000",
        "ipv4CfgState": "0",
        "modTs": "2016-12-16T00:41:12.115+00:00",
        "monPolDn": "uni/fabric/monfab-default",
        "name": "",
        "nhAddr": "192.0.2.4/32",
        "nhIf": "eth1/9",
        "nhVrf": "default",
        "object": "0",
        "operSt": "up",
        "operStQual": "unspecified",
        "persistentOnReload": "true",
        "pref": "1",
        "rn": "nh-[eth1/9]-addr-[192.0.2.4/32]-vrf-[default]",
        "rtname": "StatRt5",
        "rwEncap": "unknown",
        "status": "",
        "tag": "1234"
}}}]}}]}

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

Querying a Static Route

Querying a Static Route
GET https://<IP_Address>/api/mo/sys/ipv4/inst/dom-default/routestat.json?rsp-subtree=full&rsp-foreign-subtree=ephemeral&batch-id=1&batch-size=10


CLI Command

show ip static-route [vrf {<vrf-name> | <vrf-known-name> | all}]

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

Querying IPv6 Static Routes

Querying IPv6 Static Routes
GET https://<IP_Address>/mo/sys/ipv6/inst/dom-default/routestats.json?rsp-subtree=full&rsp-foreign-subtree=ephemeral&batch-id=1&batch-size=20
Querying IPv6 Static Routes
GET https://<IP_Address>/api/mo/sys/ipv6/inst/dom-default/routestats/pfx-[102:102:102::102/128]-nh-[12:1:1::2/128].json?rsp-subtree=full&rsp-foreign-subtree=ephemeral&batch-id=1&batch-size=20


CLI Command

show ipv6 static-route [<prefix>] [multicast] [track-table]

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