Configuring Static Routes on FlexSwitch

This topic guides you through creating static routes on FlexSwitch using both the CLI and the REST interface.

In the following examples we wil create a static route for the IP Address 2.2.2.2 .

Static Route Configuration Using the FlexSwitch CLI

Configuring a Static Route using the FlexSwitch CLI. For more information about the CLI, see Using the CLI.

Check for Existing Routes

Check existing IP routes using the CLI commands shown in the example below. In this case it is simply the show command applied to the ip route context.

localhost#show ip route

Applying Show:
IP Route Table\m
'[x/y]' denotes [preference/metric]

10.1.1.0/24 ubest/mbest: 1/0, Policy: []
   via 10.1.1.1, fpPort1, [-1/0], 2033-11-20 20:07:37.81667484 +0000 UTC, CONNECTED
sdk:printIPv4RouteStates() result: SUCCESS

Nothing was returned, demonstrating that there are no static IP routes configured.

Create a Static IP Route

In this example we will:

  • Name the route.
  • Assign a network mask.
  • Assign the IP address of the next hop.
  • Apply the configuration.

Use the following CLI commands to create a static route.

localhost(config): ip route 2.2.2.2
localhost(config-route-2.2.2.2): networkmask 255.255.255.255
localhost(config-route-2.2.2.2): nexthop_ip 10.1.1.4
localhost(config-route-2.2.2.2-nexthop_ip-10.1.1.4)#apply
Applying Config:
id: 33  object: IPv4Route   status: APPLIED CONFIG  valid: True delete: False num user cmds: 3
 command                        attr           value                          model attr       iskey    required    userprov    time provisioned
---------------------------------------------------------------------------------------------------------------------------------------------------------
 ip route 2.2.2.2               route          2.2.2.2                        DestinationNw    True     X           X           Sun Nov 20 20:29:38 2033
 networkmask 255.255.255.255    networkmask    255.255.255.255                NetworkMask      True     X           X           Sun Nov 20 20:29:44 2033
 nexthop_ip 10.1.1.4            nexthop_ip     [{'nexthop_ip': '10.1.1.4',    NextHop          True     X           X           Sun Nov 20 20:29:56 2033
                                               u'nexthopintref': u'',
                                               u'weight': 0}]

sdk:createIPv4Route(2.2.2.2,255.255.255.255,[{u'NextHopIntRef': u'', u'Weight': 0, u'NextHopIp': '10.1.1.4'}],NullRoute=False,Protocol=STATIC,Cost=0) result: SUCCESS: http status code: 201

Verify the Configuration

Use the following CLI command to verify that the route was created.

localhost(config): show ip route
Applying Show:
IP Route Table\m
'[x/y]' denotes [preference/metric]

10.1.1.0/24 ubest/mbest: 1/0, Policy: []
   via 10.1.1.1, fpPort1, [-1/0], 2033-11-20 20:07:37.81667484 +0000 UTC, CONNECTED
2.2.2.2/32 ubest/mbest: 1/0, Policy: []
   via 10.1.1.4, fpPort1, [-1/0],2033-11-20 20:29:59.013483679 +0000 UTC, STATIC

sdk:printIPv4RouteStates() result: SUCCESS

Static Route Curl Configuration

Check for Existing Routes

Execute the following cURL commands to check for existing routes.

bash-4.3$ curl -sX GET -u admin --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' -d '{}' 'http://192.168.100.215:8080/public/v1/config/IPv4Routes' | python -m json.tool
Enter host password for user 'admin':
{
    "CurrentMarker": 0,
    "MoreExist": false,
    "NextMarker": 0,
    "ObjCount": 0,
    "Objects": []
}

Create a Static IP Route

Execute the following cURL command to create a static route.

bash-4.3$ curl -sX POST -u admin -d '{"DestinationNw":"2.2.2.2","NetworkMask":"255.255.255.255","NextHop":[{"NextHopIp":"10.1.1.4"}]}' 'http://localhost:8080/public/v1/config/Ipv4Route' | python -m json.tool
Enter host password for user 'admin':
{
    "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept",
    "Access-Control-Allow-Methods": "POST, GET, OPTIONS, PATCH, DELETE",
    "Access-Control-Allow-Origin": "*",
    "Access-Control-Max_age": "86400",
    "ObjectId": "872189da-8008-4338-402a-83e6291da961",
    "Result": "Success"
}

Verify the Confuguration

Execute the following cURL command to check the route.

Tip

The example shown below retrieves the records for a specific route that matches all the criteria (keys) passed in the request. If you execute a GET ALL type request ( curl -k -u : -Xs GET http://device-management-IP:443/public/v1/state/IpvrRoutes ) it returns all routes.

bash-4.3$ curl -sX GET -u admin -d '{"DestinationNw":"2.2.2.2","NetworkMask":"255.255.255.255","NextHop":[{"NextHopIp":"10.1.1.4"}]}' 'http://localhost:8080/public/v1/config/Ipv4Route' | python -m json.tool
Enter host password for user 'admin':
{
    "Object": {
        "Cost": 0,
        "DestinationNw": "2.2.2.2",
        "NetworkMask": "255.255.255.255",
        "NextHop": [
            {
                "NextHopIntRef": "",
                "NextHopIp": "10.1.1.4",
                "Weight": 0
            }
        ],
        "NullRoute": false,
        "Protocol": "STATIC"
    },
    "ObjectId": "872189da-8008-4338-402a-83e6291da961"
}