Routing and Forwarding Tables

This category of questions allows you to query the RIBs and FIBs computed by Batfish.

Routes

Returns routing tables.

Shows routes for specified RIB, VRF, and node(s).

Inputs

Name

Description

Type

Optional

Default Value

nodes

Return routes on nodes matching this specifier.

NodeSpec

True

network

Return routes for networks matching this prefix.

str

True

prefixMatchType

Use this prefix matching criterion: EXACT, LONGEST_PREFIX_MATCH, LONGER_PREFIXES, SHORTER_PREFIXES.

str

True

protocols

Return routes for protocols matching this specifier.

RoutingProtocolSpec

True

vrfs

Return routes on VRFs matching this name or regex.

str

True

rib

Only return routes from a given protocol RIB.

str

True

Invocation

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

Return Value

Name

Description

Type

Node

Node

str

VRF

VRF name

str

Network

Network for this route

str

Next_Hop_IP

Route’s Next Hop IP

str

Next_Hop_Interface

Route’s Next Hop Interface

str

Protocol

Route’s Protocol

str

Metric

Route’s Metric

int

Admin_Distance

Route’s Admin distance

int

Tag

Tag for this route

int

Print the first 5 rows of the returned Dataframe

[6]:
result.head(5)
[6]:
Node VRF Network Next_Hop_IP Next_Hop_Interface Protocol Metric Admin_Distance Tag
0 as1border1 default 1.0.1.0/24 AUTO/NONE(-1l) GigabitEthernet0/0 connected 0 0 None
1 as1border1 default 1.0.1.1/32 AUTO/NONE(-1l) GigabitEthernet0/0 local 0 0 None
2 as1border1 default 1.0.2.0/24 1.0.1.2 GigabitEthernet0/0 ospf 2 110 None
3 as1border1 default 1.1.1.1/32 AUTO/NONE(-1l) Loopback0 connected 0 0 None
4 as1border1 default 1.2.2.2/32 1.0.1.2 GigabitEthernet0/0 ospf 3 110 None

Print the first row of the returned Dataframe

[7]:
result.iloc[0]
[7]:
Node                          as1border1
VRF                              default
Network                       1.0.1.0/24
Next_Hop_IP               AUTO/NONE(-1l)
Next_Hop_Interface    GigabitEthernet0/0
Protocol                       connected
Metric                                 0
Admin_Distance                         0
Tag                                 None
Name: 0, dtype: object

BGP RIB

Returns routes in the BGP RIB.

Shows BGP routes for specified VRF and node(s). This question is not available in Batfish containers on dockerhub prior to March 29, 2021.

Inputs

Name

Description

Type

Optional

Default Value

nodes

Examine routes on nodes matching this specifier.

NodeSpec

True

network

Examine routes for networks matching this prefix.

str

True

prefixMatchType

Use this prefix matching criterion: EXACT, LONGEST_PREFIX_MATCH, LONGER_PREFIXES, SHORTER_PREFIXES.

str

True

vrfs

Examine routes on VRFs matching this name or regex.

str

True

status

Examine routes whose status matches this specifier.

BgpRouteStatusSpec

True

Invocation

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

Return Value

Name

Description

Type

Node

Node

str

VRF

VRF name

str

Network

Network for this route

str

Status

Route’s statuses

List of str

Next_Hop_IP

Route’s Next Hop IP

str

Next_Hop_Interface

Route’s Next Hop Interface

str

Protocol

Route’s Protocol

str

AS_Path

Route’s AS path

str

Metric

Route’s Metric

int

Local_Pref

Route’s Local Preference

int

Communities

Route’s List of communities

List of str

Origin_Protocol

Route’s Origin protocol

str

Origin_Type

Route’s Origin type

str

Originator_Id

Route’s Originator ID

str

Cluster_List

Route’s Cluster List

List of int

Weight

Route’s BGP Weight

int

Tag

Tag for this route

int

Print the first 5 rows of the returned Dataframe

[11]:
result.head(5)
[11]:
Node VRF Network Status Next_Hop_IP Next_Hop_Interface Protocol AS_Path Metric Local_Pref Communities Origin_Protocol Origin_Type Originator_Id Cluster_List Weight Tag
0 as1border1 default 1.0.1.0/24 ['BEST'] AUTO/NONE(-1l) null_interface bgp 0 100 [] connected igp 1.1.1.1 None 32768 None
1 as1border1 default 1.0.2.0/24 ['BEST'] 1.0.1.2 dynamic bgp 2 100 [] ospf igp 1.1.1.1 None 32768 None
2 as1border1 default 2.128.0.0/16 ['BEST'] 10.12.11.2 dynamic bgp 2 50 350 ['2:1'] bgp igp 2.1.1.1 None 0 None
3 as1border1 default 3.0.1.0/24 ['BEST'] 10.13.22.3 dynamic ibgp 3 50 350 ['3:1'] ibgp igp 1.2.2.2 [17432833] 0 None
4 as1border1 default 3.0.2.0/24 ['BEST'] 10.13.22.3 dynamic ibgp 3 50 350 ['3:1'] ibgp igp 1.2.2.2 [17432833] 0 None

Print the first row of the returned Dataframe

[12]:
result.iloc[0]
[12]:
Node                      as1border1
VRF                          default
Network                   1.0.1.0/24
Status                      ['BEST']
Next_Hop_IP           AUTO/NONE(-1l)
Next_Hop_Interface    null_interface
Protocol                         bgp
AS_Path
Metric                             0
Local_Pref                       100
Communities                       []
Origin_Protocol            connected
Origin_Type                      igp
Originator_Id                1.1.1.1
Cluster_List                    None
Weight                         32768
Tag                             None
Name: 0, dtype: object

EVPN RIB

Returns routes in the EVPN RIB.

Shows EVPN routes for specified VRF and node(s). This question is not available in Batfish containers on dockerhub prior to March 29, 2021.

Inputs

Name

Description

Type

Optional

Default Value

nodes

Examine routes on nodes matching this specifier.

NodeSpec

True

network

Examine routes for networks matching this prefix.

str

True

prefixMatchType

Use this prefix matching criterion: EXACT, LONGEST_PREFIX_MATCH, LONGER_PREFIXES, SHORTER_PREFIXES.

str

True

vrfs

Examine routes on VRFs matching this name or regex.

str

True

Invocation

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

Return Value

Name

Description

Type

Node

Node

str

VRF

VRF name

str

Network

Network for this route

str

Status

Route’s statuses

List of str

Route_Distinguisher

Route distinguisher

str

Next_Hop_IP

Route’s Next Hop IP

str

Next_Hop_Interface

Route’s Next Hop Interface

str

Protocol

Route’s Protocol

str

AS_Path

Route’s AS path

str

Metric

Route’s Metric

int

Local_Pref

Route’s Local Preference

int

Communities

Route’s List of communities

List of str

Origin_Protocol

Route’s Origin protocol

str

Origin_Type

Route’s Origin type

str

Originator_Id

Route’s Originator ID

str

Cluster_List

Route’s Cluster List

List of int

Weight

Route’s BGP Weight

int

Tag

Tag for this route

int

Print the first 5 rows of the returned Dataframe

[16]:
result.head(5)
[16]:
Node VRF Network Status Route_Distinguisher Next_Hop_IP Next_Hop_Interface Protocol AS_Path Metric Local_Pref Communities Origin_Protocol Origin_Type Originator_Id Cluster_List Weight Tag
0 dc1-bl1a Tenant_A_WAN_Zone 192.168.254.8/32 ['BEST'] 192.168.255.8:15005 AUTO/NONE(-1l) null_interface bgp 0 100 ['2:15005:15005'] None egp 192.168.255.8 None 0 None
1 dc1-bl1a Tenant_B_WAN_Zone 192.168.254.8/32 ['BEST'] 192.168.255.8:25021 AUTO/NONE(-1l) null_interface bgp 0 100 ['2:25021:25021'] None egp 192.168.255.8 None 0 None
2 dc1-bl1a Tenant_C_WAN_Zone 192.168.254.8/32 ['BEST'] 192.168.255.8:35031 AUTO/NONE(-1l) null_interface bgp 0 100 ['2:35031:35031'] None egp 192.168.255.8 None 0 None
3 dc1-bl1a default 10.1.10.0/24 ['BEST'] 192.168.255.3:15001 192.168.255.3 dynamic bgp 65001 65101 0 100 ['2:15001:15001'] bgp igp 192.168.255.1 None 0 None
4 dc1-bl1a default 10.1.10.0/24 ['BEST'] 192.168.255.4:15001 192.168.255.4 dynamic bgp 65001 65102 0 100 ['2:15001:15001'] bgp igp 192.168.255.1 None 0 None

Print the first row of the returned Dataframe

[17]:
result.iloc[0]
[17]:
Node                              dc1-bl1a
VRF                      Tenant_A_WAN_Zone
Network                   192.168.254.8/32
Status                            ['BEST']
Route_Distinguisher    192.168.255.8:15005
Next_Hop_IP                 AUTO/NONE(-1l)
Next_Hop_Interface          null_interface
Protocol                               bgp
AS_Path
Metric                                   0
Local_Pref                             100
Communities              ['2:15005:15005']
Origin_Protocol                       None
Origin_Type                            egp
Originator_Id                192.168.255.8
Cluster_List                          None
Weight                                   0
Tag                                   None
Name: 0, dtype: object

Longest Prefix Match

Returns routes that are longest prefix match for a given IP address.

Return longest prefix match routes for a given IP in the RIBs of specified nodes and VRFs.

Inputs

Name

Description

Type

Optional

Default Value

ip

IP address to run LPM on.

str

False

nodes

Examine routes on nodes matching this specifier.

NodeSpec

True

.*

vrfs

Examine routes on VRFs matching this name or regex.

str

True

.*

Invocation

[20]:
result = bf.q.lpmRoutes(ip='2.34.201.10').answer().frame()

Return Value

Name

Description

Type

Node

Node where the route is present

str

VRF

VRF where the route is present

str

Ip

IP that was being matched on

str

Network

The longest-prefix network that matched

str

Num_Routes

Number of routes that matched (in case of ECMP)

int

Print the first 5 rows of the returned Dataframe

[21]:
result.head(5)
[21]:
Node VRF Ip Network Num_Routes
0 as2border1 default 2.34.201.10 2.34.201.0/24 2
1 as2border2 default 2.34.201.10 2.34.201.0/24 2
2 as2core1 default 2.34.201.10 2.34.201.0/24 1
3 as2core2 default 2.34.201.10 2.34.201.0/24 1
4 as2dept1 default 2.34.201.10 2.34.201.0/24 1

Print the first row of the returned Dataframe

[22]:
result.iloc[0]
[22]:
Node             as2border1
VRF                 default
Ip              2.34.201.10
Network       2.34.201.0/24
Num_Routes                2
Name: 0, dtype: object