Technical Tip: How to monitor BGP state with SNMP
Description
Scope
FortiGate.
Solution
This is based on BGP4-MIB.
This example is for an Active peering with remote neighbor 10.129.1.226:
BGP4-MIB::bgpVersion.0 = Hex-STRING: 10
BGP4-MIB::bgpLocalAs.0 = INTEGER: 65002
BGP4-MIB::bgpPeerIdentifier.10.129.1.226 = IpAddress: 0.0.0.0
BGP4-MIB::bgpPeerState.10.129.1.226 = INTEGER: active(3)
BGP4-MIB::bgpPeerAdminStatus.10.129.1.226 = INTEGER: start(2)
BGP4-MIB::bgpPeerNegotiatedVersion.10.129.1.226 = INTEGER: 0
BGP4-MIB::bgpPeerLocalAddr.10.129.1.226 = IpAddress: 0.0.0.0
BGP4-MIB::bgpPeerLocalPort.10.129.1.226 = INTEGER: 179
BGP4-MIB::bgpPeerRemoteAddr.10.129.1.226 = IpAddress: 10.129.1.226
BGP4-MIB::bgpPeerRemotePort.10.129.1.226 = INTEGER: 0
BGP4-MIB::bgpPeerRemoteAs.10.129.1.226 = INTEGER: 65001
BGP4-MIB::bgpPeerInUpdates.10.129.1.226 = Wrong Type (should be Counter32): INTEGER: 0
BGP4-MIB::bgpPeerOutUpdates.10.129.1.226 = Wrong Type (should be Counter32): INTEGER: 0
BGP4-MIB::bgpPeerInTotalMessages.10.129.1.226 = Wrong Type (should be Counter32): INTEGER: 894
BGP4-MIB::bgpPeerOutTotalMessages.10.129.1.226 = Wrong Type (should be Counter32): INTEGER: 899
BGP4-MIB::bgpPeerLastError.10.129.1.226 = Hex-STRING: 06 00
BGP4-MIB::bgpPeerFsmEstablishedTransitions.10.129.1.226 = Wrong Type (should be Counter32): INTEGER: 1
BGP4-MIB::bgpPeerFsmEstablishedTime.10.129.1.226 = Gauge32: 0 seconds
BGP4-MIB::bgpPeerConnectRetryInterval.10.129.1.226 = INTEGER: 120 seconds
BGP4-MIB::bgpPeerHoldTime.10.129.1.226 = INTEGER: 0 seconds
BGP4-MIB::bgpPeerKeepAlive.10.129.1.226 = INTEGER: 0 seconds
BGP4-MIB::bgpPeerHoldTimeConfigured.10.129.1.226 = INTEGER: 180 seconds
BGP4-MIB::bgpPeerKeepAliveConfigured.10.129.1.226 = INTEGER: 60 seconds
BGP4-MIB::bgpPeerMinASOriginationInterval.10.129.1.226 = INTEGER: 0 seconds
BGP4-MIB::bgpPeerMinRouteAdvertisementInterval.10.129.1.226 = INTEGER: 30 seconds
BGP4-MIB::bgpPeerInUpdateElapsedTime.10.129.1.226 = Gauge32: 873759 seconds
BGP4-MIB::bgpIdentifier.0 = IpAddress: 10.129.1.227
Looking at BGP status directly on the FortiGate with CLI, the equivalent is seen:
BGP router identifier 10.129.1.227, local AS number 65002
BGP table version is 1
0 BGP AS-PATH entries
0 BGP community entries
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.129.1.226 4 65001 894 899 0 0 0 never Active
Total number of neighbors 1
Here is another example for ‘Established’ BGP peering:
BGP4-MIB::bgpVersion.0 = Hex-STRING: 10
BGP4-MIB::bgpLocalAs.0 = INTEGER: 65002
BGP4-MIB::bgpPeerIdentifier.10.129.1.226 = IpAddress: 10.129.1.226
BGP4-MIB::bgpPeerState.10.129.1.226 = INTEGER: established(6)
BGP4-MIB::bgpPeerAdminStatus.10.129.1.226 = INTEGER: start(2)
BGP4-MIB::bgpPeerNegotiatedVersion.10.129.1.226 = INTEGER: 4
BGP4-MIB::bgpPeerLocalAddr.10.129.1.226 = IpAddress: 10.129.1.227
BGP4-MIB::bgpPeerLocalPort.10.129.1.226 = INTEGER: 179
BGP4-MIB::bgpPeerRemoteAddr.10.129.1.226 = IpAddress: 10.129.1.226
BGP4-MIB::bgpPeerRemotePort.10.129.1.226 = INTEGER: 1040
BGP4-MIB::bgpPeerRemoteAs.10.129.1.226 = INTEGER: 65001
BGP4-MIB::bgpPeerInUpdates.10.129.1.226 = Wrong Type (should be Counter32): INTEGER: 0
BGP4-MIB::bgpPeerOutUpdates.10.129.1.226 = Wrong Type (should be Counter32): INTEGER: 0
BGP4-MIB::bgpPeerInTotalMessages.10.129.1.226 = Wrong Type (should be Counter32): INTEGER: 896
BGP4-MIB::bgpPeerOutTotalMessages.10.129.1.226 = Wrong Type (should be Counter32): INTEGER: 901
BGP4-MIB::bgpPeerLastError.10.129.1.226 = Hex-STRING: 06 00
BGP4-MIB::bgpPeerFsmEstablishedTransitions.10.129.1.226 = Wrong Type (should be Counter32): INTEGER: 2
BGP4-MIB::bgpPeerFsmEstablishedTime.10.129.1.226 = Gauge32: 22 seconds
BGP4-MIB::bgpPeerConnectRetryInterval.10.129.1.226 = INTEGER: 120 seconds
BGP4-MIB::bgpPeerHoldTime.10.129.1.226 = INTEGER: 180 seconds
BGP4-MIB::bgpPeerKeepAlive.10.129.1.226 = INTEGER: 60 seconds
BGP4-MIB::bgpPeerHoldTimeConfigured.10.129.1.226 = INTEGER: 180 seconds
BGP4-MIB::bgpPeerKeepAliveConfigured.10.129.1.226 = INTEGER: 60 seconds
BGP4-MIB::bgpPeerMinASOriginationInterval.10.129.1.226 = INTEGER: 0 seconds
BGP4-MIB::bgpPeerMinRouteAdvertisementInterval.10.129.1.226 = INTEGER: 30 seconds
BGP4-MIB::bgpPeerInUpdateElapsedTime.10.129.1.226 = Gauge32: 874704 seconds
BGP4-MIB::bgpIdentifier.0 = IpAddress: 10.129.1.227
The corresponding CLI status is seen as:
BGP router identifier 10.129.1.227, local AS number 65002
BGP table version is 1
0 BGP AS-PATH entries
0 BGP community entries
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.129.1.226 4 65001 898 904 0 0 0 00:02:37 0
Total number of neighbors 1
Note: In snmpd, the function 'rmt_as' is reused for both Local AS and Remote AS and should not be confused.
OfficeA # get router info bgp summary
VRF 0 BGP router identifier 10.199.186.1, local AS number 75400
BGP table version is 1
2 BGP AS-PATH entries
0 BGP community entries
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.10.1.1 4 65400 27 29 0 0 0 00:00:24 1
Total number of neighbors 1
SNMP Debug:
2025-07-16 08:29:05 snmpd: update bgppeer_cache: vfid=0(root) type=4 total=4 dumpped=4
2025-07-16 08:29:05 snmpd: bgppeer_cache: dump peer4 entry key(rmt_addr_idx1=10.10.1.1) loc_addr=10.10.1.3
flags=0x0 vd=1
rtr_id=192.219.1.3 state=6 adm_status=2 last_err=2/2 nego_ver=4 loc_port=179 rmt_port=24288 rmt_as=65400 in_updt=3
out_updt=2 in_tot_msg=28 out_tot_msg=32
fsm_est_trans=1 fsm_est_time=95 con_rtr_intvl=120 hold_time=180 keep_alive=60 min_as_orig_intvl=0
min_rt_advt_intv=30 in_updt_elapdt=94
2025-07-16 08:29:05 snmpd: bgppeer_cache: dump peer4 entry key(rmt_addr_idx1=0.0.0.0) loc_addr=0.0.0.0 flags=0x1
vd=1
rtr_id=10.199.186.1 state=1 adm_status=2 last_err=0/0 nego_ver=0 loc_port=179 rmt_port=0 rmt_as=75400 in_updt=0
out_updt=0 in_tot_msg=0 out_tot_msg=0
fsm_est_trans=0 fsm_est_time=0 con_rtr_intvl=120 hold_time=0 keep_alive=0 min_as_orig_intvl=0 min_rt_advt_intv=0
in_updt_elapdt=18022
2025-07-16 08:29:05 snmpd: bgppeer_cache: key(rmt_addr_idx1=0.0.0.0) next=0 self=1 vd=1 found:
entry(rmt_addr_idx1=0.0.0.0 flags=0x1)
) -> 0
2025-07-16 08:29:05 snmpd: get-next: bgpVersion.1 -> () -> 4
2025-07-16 08:29:05 snmpd: get-next: bgpLocalAs -> (
2025-07-16 08:29:05 snmpd: bgppeer_cache: try to find key(rmt_addr_idx1=0.0.0.0) next=0 self=1 vd=1
2025-07-16 08:29:05 snmpd: bgppeer_cache: key(rmt_addr_idx1=0.0.0.0) next=0 self=1 vd=1 found:
entry(rmt_addr_idx1=0.0.0.0 flags=0x1)
) -> 0
