Dynamic Routing

This section covers the following topics:

  • E-BGP
  • BGP route policy
  • BGP prefix list
  • BGP redistribution list

Configuration of these features are covered in detail in the Docker Labs portion of the FlexSwitch documentation.

For E-BGP, see Docker Lab 1, Stage 3.

For BGP route policy, prefix list, and redistribution list, see Docker Lab 1, Stage 4.


Configuring e-BGP

Enabling e-BGP

root@leaf1:/#  curl -sX PATCH -d '{"ASNum":"65001","RouterId":"10.0.0.1"}' 'http://localhost:8080/public/v1/config/BGPGlobal' | python -m json.tool
{
    "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": "ea26be22-0b6e-4dc3-53c4-d90a58b5834d",
    "Result": "Success"
}

Configuring Neighbors

root@leaf1:/#  curl -sX POST -d '{"NeighborAddress":"10.1.1.2","PeerAS":"65002","UpdateSource":"10.1.1.1"}' 'http://localhost:8080/public/v1/config/BGPv4Neighbor' | python -m json.tool
{
    "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": "d0d44606-002d-404a-72a5-ef749d4f5b61",
    "Result": "Success"
}

root@leaf1:/#   curl -sX POST -d '{"NeighborAddress":"10.1.3.2","PeerAS":"65003","UpdateSource":"10.1.3.1"}' 'http://localhost:8080/public/v1/config/BGPv4Neighbor' | python -m json.tool
{
    "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": "74574ea5-75be-4efa-415d-9e42d2103ef4",
    "Result": "Success"
}

Verify Configuration

root@leaf1:~#  curl -s GET 'http://localhost:8080/public/v1/state/BGPGlobal' | python -m json.tool
{
    "Object": {
        "AS": "65001",
        "DefaultMED": 0,
        "Defaultv4Route": false,
        "Defaultv6Route": false,
        "Disabled": false,
        "EBGPAllowMultipleAS": false,
        "EBGPMaxPaths": 0,
        "IBGPMaxPaths": 0,
        "RouterId": "10.0.0.1",
        "TotalPaths": 0,
        "Totalv4Prefixes": 0,
        "Totalv6Prefixes": 0,
        "UseMultiplePaths": false,
        "Vrf": "default"
    },
    "ObjectId": ""
}

root@leaf1:~#  curl -s GET 'http://localhost:8080/public/v1/state/BGPv4Neighbors' | python -m json.tool
{
    "CurrentMarker": 0,
    "MoreExist": false,
    "NextMarker": 0,
    "ObjCount": 2,
    "Objects": [
        {
            "Object": {
                "AddPathsMaxTx": 0,
                "AddPathsRx": false,
                "AdjRIBInFilter": "",
                "AdjRIBOutFilter": "",
                "AuthPassword": "",
                "BfdNeighborState": "",
                "ConnectRetryTime": 120,
                "Description": "",
                "Disabled": false,
                "HoldTime": 180,
                "IntfRef": "",
                "KeepaliveTime": 60,
                "LocalAS": "65001",
                "MaxPrefixes": 0,
                "MaxPrefixesDisconnect": false,
                "MaxPrefixesRestartTimer": 0,
                "MaxPrefixesThresholdPct": 80,
                "Messages": {
                    "Received": {
                        "Notification": 0,
                        "Update": 0
                    },
                    "Sent": {
                        "Notification": 0,
                        "Update": 0
                    }
                },
                "MultiHopEnable": false,
                "MultiHopTTL": 0,
                "NeighborAddress": "10.1.1.2",
                "NextHopSelf": false,
                "PeerAS": "65002",
                "PeerGroup": "",
                "PeerType": 1,
                "Queues": {
                    "Input": 0,
                    "Output": 0
                },
                "RouteReflectorClient": false,
                "RouteReflectorClusterId": 0,
                "SessionState": 6,
                "SessionStateDuration": "4m41.303925641s",
                "TotalPrefixes": 0,
                "UpdateSource": "10.1.1.1"
            },
            "ObjectId": "d0d44606-002d-404a-72a5-ef749d4f5b61"
        },
        {
            "Object": {
                "AddPathsMaxTx": 0,
                "AddPathsRx": false,
                "AdjRIBInFilter": "",
                "AdjRIBOutFilter": "",
                "AuthPassword": "",
                "BfdNeighborState": "",
                "ConnectRetryTime": 120,
                "Description": "",
                "Disabled": false,
                "HoldTime": 180,
                "IntfRef": "",
                "KeepaliveTime": 60,
                "LocalAS": "65001",
                "MaxPrefixes": 0,
                "MaxPrefixesDisconnect": false,
                "MaxPrefixesRestartTimer": 0,
                "MaxPrefixesThresholdPct": 80,
                "Messages": {
                    "Received": {
                        "Notification": 0,
                        "Update": 0
                    },
                    "Sent": {
                        "Notification": 0,
                        "Update": 0
                    }
                },
                "MultiHopEnable": false,
                "MultiHopTTL": 0,
                "NeighborAddress": "10.1.3.2",
                "NextHopSelf": false,
                "PeerAS": "65003",
                "PeerGroup": "",
                "PeerType": 1,
                "Queues": {
                    "Input": 0,
                    "Output": 0
                },
                "RouteReflectorClient": false,
                "RouteReflectorClusterId": 0,
                "SessionState": 6,
                "SessionStateDuration": "4m26.756497343s",
                "TotalPrefixes": 0,
                "UpdateSource": "10.1.3.1"
            },
            "ObjectId": "74574ea5-75be-4efa-415d-9e42d2103ef4"
        }
    ]
}

CLI

Configuring e-BGP

leaf1(config)#router bgp 65001
leaf1(config-router-bgp-65001)#router_id 10.0.0.1
leaf1(config-router-bgp-65001)#apply

Configuring e-BGP Neighbors

leaf1(config-router-bgp-65001)# neighbor ip 10.1.1.2
leaf1(config-router-bgp-65001-neighbor-10.1.1.1)# update_source 10.1.1.1
leaf1(config-router-bgp-65001-neighbor-10.1.1.1)# peer_as 65002
leaf1(config-router-bgp-65001-neighbor-10.1.1.1)#exit
leaf1(config-router-bgp-65001)# neighbor ip 10.1.3.2
leaf1(config-router-bgp-65001-neighbor-10.1.2.2)# update_source 10.1.3.1
leaf1(config-router-bgp-65001-neighbor-10.1.2.2)# peer_as 65003
leaf1(config-router-bgp-65001-neighbor-10.1.2.2)# apply

leaf1#show ip bgp global
Applying Show:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Vrf        AS       RouterId    Disabled    UseMultiplePaths    EBGPMaxPaths    EBGPAllowMultipleA    IBGPMaxPaths    DefaultMED    Defaultv4Route    Defaultv6Route    TotalPaths    Totalv4Prefixes    Totalv6Prefixes
                                                                                 S

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 default    65001    10.0.0.1    False       False               0               False                 0               0             False             False             0             0             0

leaf1#show ip bgp neighbor
Applying Show:

-------------------------------------------------------------------------------------------------------------------
 Neighbor    LocalAS    PeerAS    State          RxMsg    TxMsg    Description    Prefixes_Rcvd    ElapsedTime
-------------------------------------------------------------------------------------------------------------------
 10.1.1.2    65001      65002     Established    0        0                       0                3m53.555885154s
 10.1.3.2    65001      65003     Established    0        0                       0                3m39.008456742s

API

Redistribution requires policies that can be used for granular matching of routes to be redistributed from one routing protocol to another. In this example, we are redistributed connected routes to BGP. We do not want to filter any connected routes so we will create a policy that allows all routes.

To perform the redistribution with the folowing steps:

  1. Create a PolicyStmt (Policy Statment) object with Action permit and no other conditions or setActions.
  2. Create a PolicyDefintion object that references the previously created Statement object with a priority of 0.
  3. Update the BGPGlobal Object to redistribute CONNECTED routes using the PolicyDefinition.

Repeat this on all three leaves. Then, verify that BGPv4Route state objects and IPv4Route state objects are present.

Creating a Policy Statement

root@leaf1:/# curl -sX POST  -d '{"Name":"s1_permit","Action":"permit"}' 'http://localhost:8080/public/v1/config/PolicyStmt' | python -m json.tool
{
    "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": "99cb63ae-6e30-4456-7c46-0b1817677c43",
    "Result": "Success"
}

Creating a Policy Definition Object

root@leaf1:/# curl -sX POST -d '{"Name":"p1_match_all","StatementList":[{"Priority":0,"Statement":"s1_permit"}]}' 'http://localhost:8080/public/v1/config/PolicyDefinition' | python -m json.tool
{
    "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": "60282760-7e37-48f2-6880-e86b7d17395d",
    "Result": "Success"
}

Updating the BGPGlobal Object

root@leaf1:/# curl -sX PATCH -d '{"Redistribution":[{"policy":"p1_match_all","Sources":"CONNECTED"}]}' 'http://localhost:8080/public/v1/config/BGPGlobal' | python -m json.tool
{
    "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": "812405a0-dd6d-4504-46cd-8ae5ca1a3a57",
    "Result": "Success"
}

BGPv4Route object has a large number of attributes. For simplicity, only a subset of attributes are displayed below.

root@leaf1:~# curl -s 'http://localhost:8080/public/v1/state/BGPv4Routes'  | python -m json.tool | egrep "CIDRLen|Network|NextHop"
                "CIDRLen": 32,
                "Network": "10.0.0.3",
                        "NextHop": "10.1.1.2",
                        "NextHop": "10.1.3.2",
                "CIDRLen": 30,
                "Network": "10.1.3.0",
                        "NextHop": "0.0.0.0",
                        "NextHop": "10.1.3.2",
                "CIDRLen": 32,
                "Network": "10.0.0.1",
                        "NextHop": "0.0.0.0",
                "CIDRLen": 32,
                "Network": "10.0.0.2",
                        "NextHop": "10.1.1.2",
                        "NextHop": "10.1.3.2",
                "CIDRLen": 30,
                "Network": "10.1.1.0",
                        "NextHop": "10.1.1.2",
                        "NextHop": "0.0.0.0",
                "CIDRLen": 30,
                "Network": "10.1.2.0",
                        "NextHop": "10.1.1.2",
                        "NextHop": "10.1.3.2",

Similarly for IPv4Routes object, this example filters the displayed attributes.

root@leaf1:~# curl -s 'http://localhost:8080/public/v1/state/IPv4Routes'  | python -m json.tool | egrep "Nw"
                "DestinationNw": "10.1.1.0/30",
                "DestinationNw": "10.0.0.3/32",
                "DestinationNw": "10.1.2.0/30",
                "DestinationNw": "10.0.0.1/32",
                "DestinationNw": "10.0.0.2/32",
                "DestinationNw": "10.1.3.0/30",

CLI

leaf1(config)#route_policy_statement s1_permit
leaf1(config-route-policy-statement)#action permit
leaf1(config-route-policy-statement)#apply
leaf1(config)#route_policy p1_match_all
leaf1(config-route-policy)#priority_stmt 0
leaf1(config-route-policy-stmt-0)#match_statement s1_permit
leaf1(config-route-policy-stmt-0)#apply

leaf1(config)#router bgp 65001
leaf1(config-router-bgp-65001)#redistribute CONNECTED
leaf1(config-router-bgp-65001-policy-CONNECTED)#policy p1_match_all
leaf1(config-router-bgp-65001-policy-CONNECTED)#apply


leaf1#show ip bgp network
Applying Show:
 Network        NextHop     BP       MP       Metric    LocalPref    Updated                Path
---------------------------------------------------------------------------------------------------------------
 10.0.0.1/32    0.0.0.0     True     True     0         0            2017-05-19 09:23:44    None
 10.0.0.2/32    10.1.1.2    True     True     0         0            2017-05-19 09:23:05    ['65002']
 10.0.0.2/32    10.1.3.2    False    False    0         0            2017-05-19 09:23:05    ['65003', '65002']
 10.0.0.3/32    10.1.1.2    False    False    0         0            2017-05-19 09:23:05    ['65002', '65003']
 10.0.0.3/32    10.1.3.2    True     True     0         0            2017-05-19 09:23:05    ['65003']
 10.1.1.0/30    10.1.1.2    False    False    0         0            2017-05-19 09:23:05    ['65002']
 10.1.1.0/30    0.0.0.0     True     True     0         0            2017-05-19 09:23:44    None
 10.1.2.0/30    10.1.1.2    True     True     0         0            2017-05-19 09:23:05    ['65002']
 10.1.2.0/30    10.1.3.2    False    False    0         0            2017-05-19 09:23:05    ['65003']
 10.1.3.0/30    0.0.0.0     True     True     0         0            2017-05-19 09:23:44    None
 10.1.3.0/30    10.1.3.2    False    False    0         0            2017-05-19 09:23:05    ['65003']

leaf1#show ip route
Applying Show:
FAILED TO GET OBJECT for show state: cannot concatenate 'str' and 'tuple' objects  ******* bug on CLI...