Solution
Use snmp context. SNMP context needs to be mapped to the SNMP group and the VRF which has those BGP neighbours.
Create new context mapping under VRF configuration:
#context <context_name>
SNMP context enabling configuration:
#snmp-server context <context_name>
Apply snmp context mapping to snmp group configuration
#snmp-server group <group_name> v3 <privacy_and_authentication_type> context <context_name>
Note: Depending on your release, the context command may get replace by snmp context command. See the CIsco IOS Network Managemnet Command Refrence for more information
Configuration example:
Configure context bgp under vrf
R1(config)#ip vrf test
R1(config)#context bgp
Associate context bgp to snmp configuration and apply on snmp-server group configuration
R1(config)#do show run | sec snmp
snmp-server group testgroup v3 priv context bgp
snmp-server context bgp
R1(config)#do show snmp user
User name: testuser
Engine ID: 800000090300002CC8818300
storage-type: nonvolatile active
Authentication Protocol: MD5
Privacy Protocol: AES128
Group-name: testgroup
Test VRF which contains the BGP neighbours:
R1#sh ip bgp vpnv4 vrf test summary
BGP router identifier 1.1.1.1, local AS number 1
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.1.1.2 4 2 0 0 1 0 0 never Idle
Polling result with the use of the context (use the “-n” attribute to add the context when you poll):
ade # snmpwalk -v3 -u testuser -l authPriv -n bgp -a md5 -A BGL@dmin1 -x aes -X BGL@dmin1 10.201.168.29 1.3.6.1.2.1.15
SNMPv2-SMI::mib-2.15.1.0 = Hex-STRING: 10
SNMPv2-SMI::mib-2.15.2.0 = INTEGER: 1
SNMPv2-SMI::mib-2.15.3.1.1.10.1.1.2 = IpAddress: 0.0.0.0
SNMPv2-SMI::mib-2.15.3.1.2.10.1.1.2 = INTEGER: 1
SNMPv2-SMI::mib-2.15.3.1.3.10.1.1.2 = INTEGER: 2
SNMPv2-SMI::mib-2.15.3.1.4.10.1.1.2 = INTEGER: 4
SNMPv2-SMI::mib-2.15.3.1.5.10.1.1.2 = IpAddress: 0.0.0.0
SNMPv2-SMI::mib-2.15.3.1.6.10.1.1.2 = INTEGER: 0
SNMPv2-SMI::mib-2.15.3.1.7.10.1.1.2 = IpAddress: 10.1.1.2
SNMPv2-SMI::mib-2.15.3.1.8.10.1.1.2 = INTEGER: 0
SNMPv2-SMI::mib-2.15.3.1.9.10.1.1.2 = INTEGER: 2
SNMPv2-SMI::mib-2.15.3.1.10.10.1.1.2 = Counter32: 0
SNMPv2-SMI::mib-2.15.3.1.11.10.1.1.2 = Counter32: 0
SNMPv2-SMI::mib-2.15.3.1.12.10.1.1.2 = Counter32: 0
SNMPv2-SMI::mib-2.15.3.1.13.10.1.1.2 = Counter32: 0