Routing Protocol Sessions and Policies

This category of questions reveals information regarding which routing protocol sessions are compatibly configured and which ones are established. It also allows to you analyze BGP routing policies.

BGP Session Compatibility

Returns the compatibility of configured BGP sessions.

Checks the settings of each configured BGP peering and reports any issue with those settings locally or incompatiblity with its remote counterparts. Each row represents one configured BGP peering on a node and contains information about the session it is meant to establish. For dynamic peers, there is one row per compatible remote peer. Statuses that indicate an independently misconfigured peerings include NO_LOCAL_AS, NO_REMOTE_AS, NO_LOCAL_IP (for eBGP single-hop peerings), LOCAL_IP_UNKNOWN_STATICALLY (for iBGP or eBGP multi-hop peerings), NO_REMOTE_IP (for point-to-point peerings), and NO_REMOTE_PREFIX (for dynamic peerings). INVALID_LOCAL_IP indicates that the peering’s configured local IP does not belong to any active interface on the node; UNKNOWN_REMOTE indicates that the configured remote IP is not present in the network. A locally valid point-to-point peering is deemed HALF_OPEN if it has no compatible remote peers, UNIQUE_MATCH if it has exactly one compatible remote peer, or MULTIPLE_REMOTES if it has multiple compatible remote peers. A locally valid dynamic peering is deemed NO_MATCH_FOUND if it has no compatible remote peers, or DYNAMIC_MATCH if it has at least one compatible remote peer.

Inputs

Name

Description

Type

Optional

Default Value

nodes

Include sessions whose first node matches this specifier.

NodeSpec

True

remoteNodes

Include sessions whose second node matches this specifier.

NodeSpec

True

status

Only include sessions for which compatibility status matches this specifier.

BgpSessionCompatStatusSpec

True

type

Only include sessions that match this specifier.

BgpSessionTypeSpec

True

Invocation

[5]:
result = bf.q.bgpSessionCompatibility().answer().frame()

Return Value

Name

Description

Type

Node

The node where this session is configured

str

VRF

The VRF in which this session is configured

str

Local_AS

The local AS of the session

int

Local_Interface

Local interface of the session

Interface

Local_IP

The local IP of the session

str

Remote_AS

The remote AS or list of ASes of the session

str

Remote_Node

Remote node for this session

str

Remote_Interface

Remote interface for this session

Interface

Remote_IP

Remote IP or prefix for this session

str

Address_Families

Address Families participating in this session

Set of str

Session_Type

The type of this session

str

Configured_Status

Configured status

str

Print the first 5 rows of the returned Dataframe

[6]:
result.head(5)
[6]:
Node VRF Local_AS Local_Interface Local_IP Remote_AS Remote_Node Remote_Interface Remote_IP Address_Families Session_Type Configured_Status
0 as1border1 default 1 None 1.1.1.1 1 as1core1 None 1.10.1.1 ['IPV4_UNICAST'] IBGP UNIQUE_MATCH
1 as1border1 default 1 None None 666 None None 3.2.2.2 [] EBGP_SINGLEHOP NO_LOCAL_IP
2 as1border1 default 1 None None 555 None None 5.6.7.8 [] EBGP_SINGLEHOP NO_LOCAL_IP
3 as1border1 default 1 None 10.12.11.1 2 as2border1 None 10.12.11.2 ['IPV4_UNICAST'] EBGP_SINGLEHOP UNIQUE_MATCH
4 as1border2 default 1 None 1.2.2.2 1 as1core1 None 1.10.1.1 ['IPV4_UNICAST'] IBGP UNIQUE_MATCH

Print the first row of the returned Dataframe

[7]:
result.iloc[0]
[7]:
Node                       as1border1
VRF                           default
Local_AS                            1
Local_Interface                  None
Local_IP                      1.1.1.1
Remote_AS                           1
Remote_Node                  as1core1
Remote_Interface                 None
Remote_IP                    1.10.1.1
Address_Families     ['IPV4_UNICAST']
Session_Type                     IBGP
Configured_Status        UNIQUE_MATCH
Name: 0, dtype: object

BGP Session Status

Returns the dynamic status of configured BGP sessions.

Checks whether configured BGP peerings can be established. Each row represents one configured BGP peering and contains information about the session it is configured to establish. For dynamic peerings, one row is shown per compatible remote peer. Possible statuses for each session are NOT_COMPATIBLE, ESTABLISHED, and NOT_ESTABLISHED. NOT_COMPATIBLE sessions are those where one or both peers are misconfigured; the BgpSessionCompatibility question provides further insight into the nature of the configuration error. NOT_ESTABLISHED sessions are those that are configured compatibly but will not come up because peers cannot reach each other (e.g., due to being blocked by an ACL). ESTABLISHED sessions are those that are compatible and are expected to come up.

Inputs

Name

Description

Type

Optional

Default Value

nodes

Include sessions whose first node matches this specifier.

NodeSpec

True

remoteNodes

Include sessions whose second node matches this specifier.

NodeSpec

True

status

Only include sessions for which status matches this specifier.

BgpSessionStatusSpec

True

type

Only include sessions that match this specifier.

BgpSessionTypeSpec

True

Invocation

[10]:
result = bf.q.bgpSessionStatus().answer().frame()

Return Value

Name

Description

Type

Node

The node where this session is configured

str

VRF

The VRF in which this session is configured

str

Local_AS

The local AS of the session

int

Local_Interface

Local interface of the session

Interface

Local_IP

The local IP of the session

str

Remote_AS

The remote AS or list of ASes of the session

str

Remote_Node

Remote node for this session

str

Remote_Interface

Remote interface for this session

Interface

Remote_IP

Remote IP or prefix for this session

str

Address_Families

Address Families participating in this session

Set of str

Session_Type

The type of this session

str

Established_Status

Established status

str

Print the first 5 rows of the returned Dataframe

[11]:
result.head(5)
[11]:
Node VRF Local_AS Local_Interface Local_IP Remote_AS Remote_Node Remote_Interface Remote_IP Address_Families Session_Type Established_Status
0 as1border1 default 1 None 1.1.1.1 1 as1core1 None 1.10.1.1 ['IPV4_UNICAST'] IBGP ESTABLISHED
1 as1border1 default 1 None None 666 None None 3.2.2.2 [] EBGP_SINGLEHOP NOT_COMPATIBLE
2 as1border1 default 1 None None 555 None None 5.6.7.8 [] EBGP_SINGLEHOP NOT_COMPATIBLE
3 as1border1 default 1 None 10.12.11.1 2 as2border1 None 10.12.11.2 ['IPV4_UNICAST'] EBGP_SINGLEHOP ESTABLISHED
4 as1border2 default 1 None 1.2.2.2 1 as1core1 None 1.10.1.1 ['IPV4_UNICAST'] IBGP ESTABLISHED

Print the first row of the returned Dataframe

[12]:
result.iloc[0]
[12]:
Node                        as1border1
VRF                            default
Local_AS                             1
Local_Interface                   None
Local_IP                       1.1.1.1
Remote_AS                            1
Remote_Node                   as1core1
Remote_Interface                  None
Remote_IP                     1.10.1.1
Address_Families      ['IPV4_UNICAST']
Session_Type                      IBGP
Established_Status         ESTABLISHED
Name: 0, dtype: object

BGP Edges

Returns BGP adjacencies.

Lists all BGP adjacencies in the network.

Inputs

Name

Description

Type

Optional

Default Value

nodes

Include adjacencies whose first node matches this name or regex.

NodeSpec

True

.*

remoteNodes

Include adjacencies whose second node matches this name or regex.

NodeSpec

True

.*

Invocation

[15]:
result = bf.q.bgpEdges().answer().frame()

Return Value

Name

Description

Type

Node

Node from which the edge originates

str

IP

IP at the side of originator

str

Interface

Interface at which the edge originates

str

AS_Number

AS Number at the side of originator

str

Remote_Node

Node at which the edge terminates

str

Remote_IP

IP at the side of the responder

str

Remote_Interface

Interface at which the edge terminates

str

Remote_AS_Number

AS Number at the side of responder

str

Print the first 5 rows of the returned Dataframe

[16]:
result.head(5)
[16]:
Node IP Interface AS_Number Remote_Node Remote_IP Remote_Interface Remote_AS_Number
0 as1border2 1.2.2.2 None 1 as1core1 1.10.1.1 None 1
1 as1core1 1.10.1.1 None 1 as1border1 1.1.1.1 None 1
2 as2dist2 2.1.3.2 None 2 as2core2 2.1.2.2 None 2
3 as3border2 3.2.2.2 None 3 as3core1 3.10.1.1 None 3
4 as3border1 10.23.21.3 None 3 as2border2 10.23.21.2 None 2

Print the first row of the returned Dataframe

[17]:
result.iloc[0]
[17]:
Node                as1border2
IP                     1.2.2.2
Interface                 None
AS_Number                    1
Remote_Node           as1core1
Remote_IP             1.10.1.1
Remote_Interface          None
Remote_AS_Number             1
Name: 0, dtype: object

OSPF Session Compatibility

Returns compatible OSPF sessions.

Returns compatible OSPF sessions in the network. A session is compatible if the interfaces involved are not shutdown and do run OSPF, are not OSPF passive and are associated with the same OSPF area.

Inputs

Name

Description

Type

Optional

Default Value

nodes

Include nodes matching this name or regex.

NodeSpec

True

remoteNodes

Include remote nodes matching this name or regex.

NodeSpec

True

statuses

Only include sessions matching this status specifier.

OspfSessionStatusSpec

True

Invocation

[20]:
result = bf.q.ospfSessionCompatibility().answer().frame()

Return Value

Name

Description

Type

Interface

Interface

Interface

VRF

VRF

str

IP

Ip

str

Area

Area

int

Remote_Interface

Remote Interface

Interface

Remote_VRF

Remote VRF

str

Remote_IP

Remote IP

str

Remote_Area

Remote Area

int

Session_Status

Status of the OSPF session

str

Print the first 5 rows of the returned Dataframe

[21]:
result.head(5)
[21]:
Interface VRF IP Area Remote_Interface Remote_VRF Remote_IP Remote_Area Session_Status
0 as2core2[GigabitEthernet0/0] default 2.12.22.2 1 as2border2[GigabitEthernet1/0] default 2.12.22.1 1 ESTABLISHED
1 as2core2[GigabitEthernet1/0] default 2.12.12.2 1 as2border1[GigabitEthernet2/0] default 2.12.12.1 1 ESTABLISHED
2 as2border1[GigabitEthernet1/0] default 2.12.11.1 1 as2core1[GigabitEthernet0/0] default 2.12.11.2 1 ESTABLISHED
3 as2border1[GigabitEthernet2/0] default 2.12.12.1 1 as2core2[GigabitEthernet1/0] default 2.12.12.2 1 ESTABLISHED
4 as2core2[GigabitEthernet3/0] default 2.23.21.2 1 as2dist1[GigabitEthernet1/0] default 2.23.21.3 1 ESTABLISHED

Print the first row of the returned Dataframe

[22]:
result.iloc[0]
[22]:
Interface             as2core2[GigabitEthernet0/0]
VRF                                        default
IP                                       2.12.22.2
Area                                             1
Remote_Interface    as2border2[GigabitEthernet1/0]
Remote_VRF                                 default
Remote_IP                                2.12.22.1
Remote_Area                                      1
Session_Status                         ESTABLISHED
Name: 0, dtype: object

OSPF Edges

Returns OSPF adjacencies.

Lists all OSPF adjacencies in the network.

Inputs

Name

Description

Type

Optional

Default Value

nodes

Include adjacencies whose first node matches this name or regex.

NodeSpec

True

.*

remoteNodes

Include edges whose second node matches this name or regex.

NodeSpec

True

.*

Invocation

[25]:
result = bf.q.ospfEdges().answer().frame()

Return Value

Name

Description

Type

Interface

Interface from which the edge originates

Interface

Remote_Interface

Interface at which the edge terminates

Interface

Print the first 5 rows of the returned Dataframe

[26]:
result.head(5)
[26]:
Interface Remote_Interface
0 as1border1[GigabitEthernet0/0] as1core1[GigabitEthernet1/0]
1 as1core1[GigabitEthernet1/0] as1border1[GigabitEthernet0/0]
2 as1border2[GigabitEthernet1/0] as1core1[GigabitEthernet0/0]
3 as1core1[GigabitEthernet0/0] as1border2[GigabitEthernet1/0]
4 as2border1[GigabitEthernet1/0] as2core1[GigabitEthernet0/0]

Print the first row of the returned Dataframe

[27]:
result.iloc[0]
[27]:
Interface           as1border1[GigabitEthernet0/0]
Remote_Interface      as1core1[GigabitEthernet1/0]
Name: 0, dtype: object

Test Route Policies

Evaluates the processing of a route by a given policy.

Find how the specified route is processed through the specified routing policies.

Inputs

Name

Description

Type

Optional

Default Value

nodes

Only examine filters on nodes matching this specifier.

NodeSpec

True

policies

Only consider policies that match this specifier.

RoutingPolicySpec

True

inputRoutes

The BGP route announcements to test the policy on.

List of BgpRoute

False

direction

The direction of the route, with respect to the device (IN/OUT).

str

False

Invocation

[30]:
result = bf.q.testRoutePolicies(policies='/as1_to_/', direction='in', inputRoutes=list([BgpRoute(network='10.0.0.0/24', originatorIp='4.4.4.4', originType='egp', protocol='bgp', asPath=[[64512, 64513], [64514]], communities=['64512:42', '64513:21'])])).answer().frame()

Return Value

Name

Description

Type

Node

The node that has the policy

str

Policy_Name

The name of this policy

str

Input_Route

The input route

BgpRoute

Action

The action of the policy on the input route

str

Output_Route

The output route, if any

BgpRoute

Difference

The difference between the input and output routes, if any

BgpRouteDiffs

Trace

Route policy trace that shows which clauses/terms matched the input route. If the trace is empty, either nothing matched or tracing is not yet been implemented for this policy type. This is an experimental feature whose content and format is subject to change.

List of TraceTree

Print the first 5 rows of the returned Dataframe

[31]:
result.head(5)
[31]:
Node Policy_Name Input_Route Action Output_Route Difference Trace
0 as1border1 as1_to_as2 BgpRoute(network='10.0.0.0/24', originatorIp='4.4.4.4', originType='egp', protocol='bgp', asPath=[{'asns': [64512, 64513], 'confederation': False}, {'asns': [64514], 'confederation': False}], communities=['64512:42', '64513:21'], localPreference=0, metric=0, nextHopIp=None, sourceProtocol=None, tag=0, weight=0) DENY None None
1 as1border1 as1_to_as3 BgpRoute(network='10.0.0.0/24', originatorIp='4.4.4.4', originType='egp', protocol='bgp', asPath=[{'asns': [64512, 64513], 'confederation': False}, {'asns': [64514], 'confederation': False}], communities=['64512:42', '64513:21'], localPreference=0, metric=0, nextHopIp=None, sourceProtocol=None, tag=0, weight=0) DENY None None
2 as1border2 as1_to_as2 BgpRoute(network='10.0.0.0/24', originatorIp='4.4.4.4', originType='egp', protocol='bgp', asPath=[{'asns': [64512, 64513], 'confederation': False}, {'asns': [64514], 'confederation': False}], communities=['64512:42', '64513:21'], localPreference=0, metric=0, nextHopIp=None, sourceProtocol=None, tag=0, weight=0) DENY None None
3 as1border2 as1_to_as3 BgpRoute(network='10.0.0.0/24', originatorIp='4.4.4.4', originType='egp', protocol='bgp', asPath=[{'asns': [64512, 64513], 'confederation': False}, {'asns': [64514], 'confederation': False}], communities=['64512:42', '64513:21'], localPreference=0, metric=0, nextHopIp=None, sourceProtocol=None, tag=0, weight=0) DENY None None
4 as1border2 as1_to_as4 BgpRoute(network='10.0.0.0/24', originatorIp='4.4.4.4', originType='egp', protocol='bgp', asPath=[{'asns': [64512, 64513], 'confederation': False}, {'asns': [64514], 'confederation': False}], communities=['64512:42', '64513:21'], localPreference=0, metric=0, nextHopIp=None, sourceProtocol=None, tag=0, weight=0) PERMIT BgpRoute(network='10.0.0.0/24', originatorIp='4.4.4.4', originType='egp', protocol='bgp', asPath=[{'asns': [64512, 64513], 'confederation': False}, {'asns': [64514], 'confederation': False}], communities=['1:4', '64512:42', '64513:21'], localPreference=0, metric=50, nextHopIp=None, sourceProtocol=None, tag=0, weight=0) BgpRouteDiffs(diffs=[BgpRouteDiff(fieldName='communities', oldValue='[64512:42, 64513:21]', newValue='[1:4, 64512:42, 64513:21]'), BgpRouteDiff(fieldName='metric', oldValue='0', newValue='50')]) - Matched route-map as1_to_as4 clause 2

Print the first row of the returned Dataframe

[32]:
result.iloc[0]
[32]:
Node                                                                                                                                                                                                                                                                                                                          as1border1
Policy_Name                                                                                                                                                                                                                                                                                                                   as1_to_as2
Input_Route     BgpRoute(network='10.0.0.0/24', originatorIp='4.4.4.4', originType='egp', protocol='bgp', asPath=[{'asns': [64512, 64513], 'confederation': False}, {'asns': [64514], 'confederation': False}], communities=['64512:42', '64513:21'], localPreference=0, metric=0, nextHopIp=None, sourceProtocol=None, tag=0, weight=0)
Action                                                                                                                                                                                                                                                                                                                              DENY
Output_Route                                                                                                                                                                                                                                                                                                                        None
Difference                                                                                                                                                                                                                                                                                                                          None
Trace
Name: 0, dtype: object

Search Route Policies

Finds route announcements for which a route policy has a particular behavior.

This question finds route announcements for which a route policy has a particular behavior. The behaviors can be: that the policy permits the route (permit) or that it denies the route (deny). Constraints can be imposed on the input route announcements of interest and, in the case of a permit action, also on the output route announcements of interest. Route policies are selected using node and policy specifiers, which might match multiple policies. In this case, a (possibly different) answer will be found for each policy. Note: This question currently does not support all of the route policy features that Batfish supports. The question only supports common forms of matching on prefixes, communities, and AS-paths, as well as common forms of setting communities, the local preference, and the metric. The question logs all unsupported features that it encounters as warnings. Due to unsupported features, it is possible for the question to return no answers even for route policies that can in fact exhibit the specified behavior.

Inputs

Name

Description

Type

Optional

Default Value

nodes

Only examine policies on nodes matching this specifier.

NodeSpec

True

policies

Only consider policies that match this specifier.

RoutingPolicySpec

True

inputConstraints

Constraints on the set of input BGP route announcements to consider.

BgpRouteConstraints

True

action

The behavior to be evaluated. Specify exactly one of permit or deny.

str

True

outputConstraints

Constraints on the set of output BGP route announcements to consider.

BgpRouteConstraints

True

perPath

Run the analysis separately for each execution path of a route map.

bool

True

Invocation

[35]:
result = bf.q.searchRoutePolicies(nodes='/^as1/', policies='/as1_to_/', inputConstraints=BgpRouteConstraints(prefix=["10.0.0.0/8:8-32", "172.16.0.0/28:28-32", "192.168.0.0/16:16-32"]), action='permit').answer().frame()

Return Value

Name

Description

Type

Node

The node that has the policy

str

Policy_Name

The name of this policy

str

Input_Route

The input route

BgpRoute

Action

The action of the policy on the input route

str

Output_Route

The output route, if any

BgpRoute

Difference

The difference between the input and output routes, if any

BgpRouteDiffs

Trace

Route policy trace that shows which clauses/terms matched the input route. If the trace is empty, either nothing matched or tracing is not yet been implemented for this policy type. This is an experimental feature whose content and format is subject to change.

List of TraceTree

Print the first 5 rows of the returned Dataframe

[36]:
result.head(5)
[36]:
Node Policy_Name Input_Route Action Output_Route Difference Trace
0 as1border2 as1_to_as4 BgpRoute(network='10.0.0.0/8', originatorIp='0.0.0.0', originType='egp', protocol='bgp', asPath=[], communities=[], localPreference=100, metric=0, nextHopIp='0.0.0.1', sourceProtocol=None, tag=0, weight=0) PERMIT BgpRoute(network='10.0.0.0/8', originatorIp='0.0.0.0', originType='egp', protocol='bgp', asPath=[], communities=['1:4'], localPreference=100, metric=50, nextHopIp='0.0.0.1', sourceProtocol=None, tag=0, weight=0) BgpRouteDiffs(diffs=[BgpRouteDiff(fieldName='communities', oldValue='[]', newValue='[1:4]'), BgpRouteDiff(fieldName='metric', oldValue='0', newValue='50')]) - Matched route-map as1_to_as4 clause 2

Print the first row of the returned Dataframe

[37]:
result.iloc[0]
[37]:
Node                                                                                                                                                                                                                     as1border2
Policy_Name                                                                                                                                                                                                              as1_to_as4
Input_Route           BgpRoute(network='10.0.0.0/8', originatorIp='0.0.0.0', originType='egp', protocol='bgp', asPath=[], communities=[], localPreference=100, metric=0, nextHopIp='0.0.0.1', sourceProtocol=None, tag=0, weight=0)
Action                                                                                                                                                                                                                       PERMIT
Output_Route    BgpRoute(network='10.0.0.0/8', originatorIp='0.0.0.0', originType='egp', protocol='bgp', asPath=[], communities=['1:4'], localPreference=100, metric=50, nextHopIp='0.0.0.1', sourceProtocol=None, tag=0, weight=0)
Difference                                                             BgpRouteDiffs(diffs=[BgpRouteDiff(fieldName='communities', oldValue='[]', newValue='[1:4]'), BgpRouteDiff(fieldName='metric', oldValue='0', newValue='50')])
Trace                                                                                                                                                                                       - Matched route-map as1_to_as4 clause 2
Name: 0, dtype: object