Description

This article describes how to poll information from an SNMPv3 server, which is located in a non-default routing-instance.

Solution

Topology

DUT(RI:test1)--------SNMP server 
  • The DUT (router) connects to the SNMP server via a routing-instance, which is named test.

  • SNMPv3 is configured on the DUT.

  • The SNMP server uses the snmpwalk -v3 command to poll information from the DUT.

  • Instance name: test1
    
    

In addition to the normal SNMPv3 configuration, another context-prefix in the [snmp v3 access group] hierarchy must be added:

access {
    group snmpgroup {
        context-prefix test1 {  >>> Set context-prefix to Routing instance’s name. 
            security-model usm {
                security-level authentication {
                    read-view allmibs;
                }
            }
        }
    }
} 
(...)
}
routing-instance-access >>> Enable SNMP managers in instances
other than the default one


Example - SNMP Server Polling Command

When polling from the SNMPv3 server, the add -n option must be added with the context of the routing-instance's name:

snmpwalk -v3 -u nnmsnmpuser -l AuthNoPriv -a MD5 -A site1 -n test1 15.15.15.1 system

Example - Full Configuration and Output

SNMPv3 Router Configuration

[edit]
test1@router-re0# show snmp
v3 {
    usm {
        local-engine {
            user nnmsnmpuser {
                authentication-md5 {
                    authentication-key "$ABC123"; ## SECRET-DATA
                }
            }
        }
    }
    vacm {
        security-to-group {
            security-model usm {
                security-name nnmsnmpuser {
                    group snmpgroup;
                }
            }
        }
        access {
            group snmpgroup {
                context-prefix test1 {  
                    security-model usm {
                        security-level authentication {
                            read-view allmibs;
                        }
                    }
                }
            }
        }
    }
}
engine-id {
    use-default-ip-address;
}
view allmibs {
    oid .1.3.6.1 include;
}
routing-instance-access;

Example - SNMP Server Polling Command

user$ snmpwalk -v3 -u nnmsnmpuser -l AuthNoPriv -a MD5 -A herndon1 -n test1 15.15.15.1 system 

SNMPv2-MIB::sysDescr.0 = STRING: Juniper Networks, Inc. mx480 internet router, kernel JUNOS 11.4R2.14 #0: 2012-03-17 16:57:48 UTC [email protected]:/volume/build/junos/11.4/release/11.4R2.14/obj-i386/bsd/kernels/JUNIPER/kernel Build date: 2012-03-17 18:22:46 UTC Copyright
SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.2636.1.1.1.2.25
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (26109399) 3 days, 0:31:33.99
SNMPv2-MIB::sysContact.0 = STRING:
SNMPv2-MIB::sysName.0 = STRING: test1@router-re0
SNMPv2-MIB::sysLocation.0 = STRING:
SNMPv2-MIB::sysServices.0 = INTEGER: 6

Alternative for Logical Systems

If SNMP packets are from an interface belonging to a custom routing-instance but under logical-system, the following configuration should be added instead:

context-prefix test-snmp/default {   <<< set logical-system-name/routing-instance-name
    security-model usm {
        security-level privacy {
            read-view all;
        }
    }
}

Example: Polling MIB System from routing-instance "default" in logical-system "test-snmp"

#snmpwalk -v 3 -a MD5 -A juniper123 -x AES -X juniper123 -l authPriv -u bradley -n test-snmp/default 1.1.1.1 system  | more
SNMPv2-MIB::sysDescr.0 = STRING: Juniper Networks, Inc. mx480 internet router, kernel JUNOS 21.1R1.2, Build date: 2021-02-12 21:38:31 UTC Copyright (c) 1996-2021 Juniper Networks, Inc.
SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::zeroDotZero.0
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (70111887) 8 days, 2:45:18.87
SNMPv2-MIB::sysContact.0 = STRING:
SNMPv2-MIB::sysName.0 = STRING: test-snmp/[email protected]
SNMPv2-MIB::sysLocation.0 = STRING:
SNMPv2-MIB::sysServices.0 = INTEGER: 4

Modification History

2019-04-13: Fixed formatting

2020-02-26: minor non-technical edits

2022-08-26: Added UNIX command for polling data from logical-system