PDA

Ver la versión completa : Realizar peticiones SNMP (v2) a OLT utilizando SO Windows o Linux



carlosenrique
29/10/2020, 11:52
En este post mostraremos como realizar peticiones SNMP (v2) a OLTs utilizando SO Windows o Linux.

1Para dispositivos Windows necesitamos descargar e instalar el siguiente programa https://sourceforge.net/projects/net-snmp/files/net-snmp%20binaries/5.5-binaries/net-snmp-5.5.0-2.x64.exe/download.

1Para dispositivos Linux instalar los siguientes paquetes:


# Instalar paquete SNMP:
sudo apt-get install snmp
sudo apt-get install libsnmp-dev snmp-mibs-downloader

# Cargar archivos SNMP MIB a Linux:
sudo sed -i 's/mibs :/# mibs :/g' /etc/snmp/snmp.conf

Con ello ya podremos realizar peticiones SNMP utilizando la consola de Windows o Linux.

2Datos necesarios para llamadas SNMP:


Host: IP o DNS del dispositivo (example.com.mx)
Puerto: 4161
Comunidad lectura: myreadcommunity
Comunidad escritura: mywritecommunity

OIDs: los OID son identificadores compuestos de números y dígitos que se utilizan para obtener información a través del protocolo SNMP. (ejemplo: 1.3.6.1.2.1.1.3 -> System Uptime)

3Tipos de llamadas SNMP:

1. snmpget
2. snmpset
3. snmpwalk
4. snmpbulkwalk

4Estructura y componentes de llamada SNMP:


1.- Tipo de llamada
2.- Versión (-v)
3.- Comunidad letura o escritura (-c)
4.- Host
5.- Puerto
6.- OID
Podemos saber si el valor al que apunta el OID puede ser modificado o simplemente es de lectura. Para ello debemos verificar la documentación del mismo.
sysLocation OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-write --------------------> Lectura y Escritura
STATUS mandatory
DESCRIPTION
"The physical location of this node (e.g.,
`telephone closet, 3rd floor')."
::= { system 6 }

<tipo_llamada_snmp> -v <version> -c <comunidad lectura o escritura> <host>:<puerto> <OID>

5Ejemplo SNMPWALK:

SNMPWALK se utiliza para obtener uno o muchos valores pertenecientes a un OID, ejemplo 1.3.6.1.4.1.2011.6.128.1.1.2.21.1.1 -> obtiene toda la información perteneciente al OID hasta encontrar el siguiente OID perteneciente al grupo, el cual es 1.3.6.1.4.1.2011.6.128.1.1.2.21.1.2.


OID:
Padre:
ifXEntry = "1.3.6.1.2.1.31.1.1.1" -> OID padre, perteneciente al grupo de informacion de las interfaces de la OLT.

Hijos:
ifName = "1.3.6.1.2.1.31.1.1.1.1" -> Nombre de la interfaz
ifInMulticastPkts = "1.3.6.1.2.1.31.1.1.1.2" -> siguiente OID perteneciente al grupo ifXEntry.

Llamada:
snmpwalk -v 2c -c myreadcommunity example.com.mx:4161 1.3.6.1.2.1.31.1.1.1.1

Respuesta:
IF-MIB::ifName.128 = STRING: InLoopBack0
IF-MIB::ifName.262 = STRING: null0
IF-MIB::ifName.263 = STRING: meth0
IF-MIB::ifName.234938368 = STRING: ethernet0/7/0
IF-MIB::ifName.234938432 = STRING: ethernet0/7/1
IF-MIB::ifName.234938496 = STRING: ethernet0/7/2
IF-MIB::ifName.234938560 = STRING: ethernet0/7/3
IF-MIB::ifName.234946560 = STRING: ethernet0/8/0
IF-MIB::ifName.234946624 = STRING: ethernet0/8/1
IF-MIB::ifName.234946688 = STRING: ethernet0/8/2
IF-MIB::ifName.234946752 = STRING: ethernet0/8/3
IF-MIB::ifName.235020288 = STRING: ethernet0/17/0
IF-MIB::ifName.235020352 = STRING: ethernet0/17/1
IF-MIB::ifName.235028480 = STRING: ethernet0/18/0
IF-MIB::ifName.235028544 = STRING: ethernet0/18/1
IF-MIB::ifName.4194336768 = STRING: GPON 0/4/0
IF-MIB::ifName.4194337024 = STRING: GPON 0/4/1
IF-MIB::ifName.4194337280 = STRING: GPON 0/4/2
IF-MIB::ifName.4194337536 = STRING: GPON 0/4/3
IF-MIB::ifName.4194337792 = STRING: GPON 0/4/4
IF-MIB::ifName.4194338048 = STRING: GPON 0/4/5
IF-MIB::ifName.4194338304 = STRING: GPON 0/4/6
IF-MIB::ifName.4194338560 = STRING: GPON 0/4/7
IF-MIB::ifName.4194338816 = STRING: GPON 0/4/8
IF-MIB::ifName.4194339072 = STRING: GPON 0/4/9
IF-MIB::ifName.4194339328 = STRING: GPON 0/4/10
IF-MIB::ifName.4194339584 = STRING: GPON 0/4/11
IF-MIB::ifName.4194339840 = STRING: GPON 0/4/12
IF-MIB::ifName.4194340096 = STRING: GPON 0/4/13
IF-MIB::ifName.4194340352 = STRING: GPON 0/4/14
IF-MIB::ifName.4194340608 = STRING: GPON 0/4/15
IF-MIB::ifName.4194394112 = STRING: GPON 0/11/0
IF-MIB::ifName.4194394368 = STRING: GPON 0/11/1
IF-MIB::ifName.4194394624 = STRING: GPON 0/11/2
IF-MIB::ifName.4194394880 = STRING: GPON 0/11/3
IF-MIB::ifName.4194395136 = STRING: GPON 0/11/4
IF-MIB::ifName.4194395392 = STRING: GPON 0/11/5
IF-MIB::ifName.4194395648 = STRING: GPON 0/11/6
IF-MIB::ifName.4194395904 = STRING: GPON 0/11/7