cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
874
Views
0
Helpful
2
Replies

I develop application that needs data from router. How to get the current routing table from CISCO 4331 ISR

RuthiMosacho
Level 1
Level 1

I try restconf but get 404 error

2 Replies 2

CameronC
Level 1
Level 1

Multiple ways to achieve this. You can do a simple send_command in python using the netmiko library and ssh, then process the response in python data structures.

omz
VIP Alumni
VIP Alumni

You could use - https://ios-xe-mgmt.cisco.com:9443/restconf/data/ietf-routing:routing-state/routing-instance

 

curl -v -k -u admin:admin -H "Accept: application/yang-data+json" https://ios-xe-mgmt.cisco.com:9443/restconf/data/ietf-routing:routing-state/routing-instance

Output

{
  "ietf-routing:routing-instance": [
    {
      "name": "default",
      "type": "ietf-routing:default-routing-instance",
      "router-id": "0.0.0.0",
      "routing-protocols": {
        "routing-protocol": [
          {
            "type": "ietf-routing:direct",
            "name": "0"
          },
          {
            "type": "ietf-routing:static",
            "name": "0"
          }
        ]
      },
      "ribs": {
        "rib": [
          {
            "name": "ipv4-default",
            "address-family": "ietf-routing:ipv4",
            "default-rib": false,
            "routes": {
              "route": [
                {
                  "destination-prefix": "0.0.0.0/0",
                  "route-preference": 1,
                  "metric": 1,
                  "next-hop": {
                    "outgoing-interface": "GigabitEthernet1",
                    "next-hop-address": "10.10.20.254"
                  },
                  "source-protocol": "ietf-routing:static",
                  "active": [null]
                },
                {
                  "destination-prefix": "1.1.1.200/32",
                  "route-preference": 0,
                  "metric": 0,
                  "next-hop": {
                    "outgoing-interface": "Loopback200",
                    "next-hop-address": "0.0.0.0"
                  },
                  "source-protocol": "ietf-routing:direct",
                  "active": [null]
                },
                {
                  "destination-prefix": "1.2.3.4/32",
                  "route-preference": 0,
                  "metric": 0,
                  "next-hop": {
                    "outgoing-interface": "Loopback1234",
                    "next-hop-address": "0.0.0.0"
                  },
                  "source-protocol": "ietf-routing:direct",
                  "active": [null]
                },
                {
                  "destination-prefix": "1.2.3.55/32",
                  "route-preference": 0,
                  "metric": 0,
                  "next-hop": {
                    "outgoing-interface": "Loopback55",
                    "next-hop-address": "0.0.0.0"
                  },
                  "source-protocol": "ietf-routing:direct",
                  "active": [null]
                },
                {
                  "destination-prefix": "10.1.1.1/32",
                  "route-preference": 0,
                  "metric": 0,
                  "next-hop": {
                    "outgoing-interface": "Loopback1001",
                    "next-hop-address": "0.0.0.0"
                  },
                  "source-protocol": "ietf-routing:direct",
                  "active": [null]
                },
                {
                  "destination-prefix": "10.10.20.0/24",
                  "route-preference": 0,
                  "metric": 0,
                  "next-hop": {
                    "outgoing-interface": "GigabitEthernet1",
                    "next-hop-address": "0.0.0.0"
                  },
                  "source-protocol": "ietf-routing:direct",
                  "active": [null]
                },
                {
                  "destination-prefix": "10.10.20.48/32",
                  "route-preference": 0,
                  "metric": 0,
                  "next-hop": {
                    "outgoing-interface": "GigabitEthernet1",
                    "next-hop-address": "0.0.0.0"
                  },
                  "source-protocol": "ietf-routing:direct",
                  "active": [null]
                },
                {
                  "destination-prefix": "10.10.255.0/24",
                  "route-preference": 0,
                  "metric": 0,
                  "next-hop": {
                    "outgoing-interface": "GigabitEthernet3",
                    "next-hop-address": "0.0.0.0"
                  },
                  "source-protocol": "ietf-routing:direct",
                  "active": [null]
                },
                {
                  "destination-prefix": "10.10.255.1/32",
                  "route-preference": 0,
                  "metric": 0,
                  "next-hop": {
                    "outgoing-interface": "GigabitEthernet3",
                    "next-hop-address": "0.0.0.0"
                  },
                  "source-protocol": "ietf-routing:direct",
                  "active": [null]
                },
                {
                  "destination-prefix": "10.255.255.0/24",
                  "route-preference": 0,
                  "metric": 0,
                  "next-hop": {
                    "outgoing-interface": "GigabitEthernet2",
                    "next-hop-address": "0.0.0.0"
                  },
                  "source-protocol": "ietf-routing:direct",
                  "active": [null]
                },
                {
                  "destination-prefix": "10.255.255.1/32",
                  "route-preference": 0,
                  "metric": 0,
                  "next-hop": {
                    "outgoing-interface": "GigabitEthernet2",
                    "next-hop-address": "0.0.0.0"
                  },
                  "source-protocol": "ietf-routing:direct",
                  "active": [null]
                },
                {
                  "destination-prefix": "172.16.100.0/24",
                  "route-preference": 0,
                  "metric": 0,
                  "next-hop": {
                    "outgoing-interface": "Loopback100",
                    "next-hop-address": "0.0.0.0"
                  },
                  "source-protocol": "ietf-routing:direct",
                  "active": [null]
                },
                {
                  "destination-prefix": "172.16.100.1/32",
                  "route-preference": 0,
                  "metric": 0,
                  "next-hop": {
                    "outgoing-interface": "Loopback100",
                    "next-hop-address": "0.0.0.0"
                  },
                  "source-protocol": "ietf-routing:direct",
                  "active": [null]
                }
              ]
            }
          },
          {
            "name": "ipv6-default",
            "address-family": "ietf-routing:ipv6",
            "default-rib": false
          }
        ]
      }
    },
    {
      "name": "__Platform_iVRF:_ID00_",
      "type": "ietf-routing:vrf-routing-instance",
      "router-id": "0.0.0.0",
      "interfaces": {
        "interface": ["LIIN0"]
      },
      "routing-protocols": {
        "routing-protocol": [
          {
            "type": "ietf-routing:direct",
            "name": "0"
          }
        ]
      },
      "ribs": {
        "rib": [
          {
            "name": "ipv4-default",
            "address-family": "ietf-routing:ipv4",
            "default-rib": false,
            "routes": {
              "route": [
                {
                  "destination-prefix": "192.168.1.4/30",
                  "route-preference": 0,
                  "metric": 0,
                  "next-hop": {
                    "outgoing-interface": "LIIN0",
                    "next-hop-address": "0.0.0.0"
                  },
                  "source-protocol": "ietf-routing:direct",
                  "active": [null]
                },
                {
                  "destination-prefix": "192.168.1.6/32",
                  "route-preference": 0,
                  "metric": 0,
                  "next-hop": {
                    "outgoing-interface": "LIIN0",
                    "next-hop-address": "0.0.0.0"
                  },
                  "source-protocol": "ietf-routing:direct",
                  "active": [null]
                }
              ]
            }
          },
          {
            "name": "ipv6-default",
            "address-family": "ietf-routing:ipv6",
            "default-rib": false
          }
        ]
      }
    }
  ]
}