Skip to main content

Cómo instalar y usar snmpwalk

Instalación y algunos ejemplos de Snmpwalk

Snmpwalk se encuentra en la mayoría de los repositorios de Linux

apt install snmp

La sintaxis para utilizar snmpwalk es simple y amplia:

root@nms:/etc/snmp# snmpwalk --help
USAGE: snmpwalk [OPTIONS] AGENT [OID]

  Version:  5.9
  Web:      http://www.net-snmp.org/
  Email:    net-snmp-coders@lists.sourceforge.net

OPTIONS:
  -h, --help		display this help message
  -H			display configuration file directives understood
  -v 1|2c|3		specifies SNMP version to use
  -V, --version		display package version number
SNMP Version 1 or 2c specific
  -c COMMUNITY		set the community string
SNMP Version 3 specific
  -a PROTOCOL		set authentication protocol (MD5|SHA|SHA-224|SHA-256|SHA-384|SHA-512)
  -A PASSPHRASE		set authentication protocol pass phrase
  -e ENGINE-ID		set security engine ID (e.g. 800000020109840301)
  -E ENGINE-ID		set context engine ID (e.g. 800000020109840301)
  -l LEVEL		set security level (noAuthNoPriv|authNoPriv|authPriv)
  -n CONTEXT		set context name (e.g. bridge1)
  -u USER-NAME		set security name (e.g. bert)
  -x PROTOCOL		set privacy protocol (DES|AES)
  -X PASSPHRASE		set privacy protocol pass phrase
  -Z BOOTS,TIME		set destination engine boots/time
General communication options
  -r RETRIES		set the number of retries
  -t TIMEOUT		set the request timeout (in seconds)
Debugging
  -d			dump input/output packets in hexadecimal
  -D[TOKEN[,...]]	turn on debugging output for the specified TOKENs
			   (ALL gives extremely verbose debugging output)
General options
  -m MIB[:...]		load given list of MIBs (ALL loads everything)
  -M DIR[:...]		look in given list of directories for MIBs
    (default: $HOME/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf)
  -P MIBOPTS		Toggle various defaults controlling MIB parsing:
			  u:  allow the use of underlines in MIB symbols
			  c:  disallow the use of "--" to terminate comments
			  d:  save the DESCRIPTIONs of the MIB objects
			  e:  disable errors when MIB symbols conflict
			  w:  enable warnings when MIB symbols conflict
			  W:  enable detailed warnings when MIB symbols conflict
			  R:  replace MIB symbols from latest module
  -O OUTOPTS		Toggle various defaults controlling output display:
			  0:  print leading 0 for single-digit hex characters
			  a:  print all strings in ascii format
			  b:  do not break OID indexes down
			  e:  print enums numerically
			  E:  escape quotes in string indices
			  f:  print full OIDs on output
			  n:  print OIDs numerically
			  p PRECISION:  display floating point values with specified PRECISION (printf format string)
			  q:  quick print for easier parsing
			  Q:  quick print with equal-signs
			  s:  print only last symbolic element of OID
			  S:  print MIB module-id plus last element
			  t:  print timeticks unparsed as numeric integers
			  T:  print human-readable text along with hex strings
			  u:  print OIDs using UCD-style prefix suppression
			  U:  don't print units
			  v:  print values only (not OID = value)
			  x:  print all strings in hex format
			  X:  extended index format
  -I INOPTS		Toggle various defaults controlling input parsing:
			  b:  do best/regex matching to find a MIB node
			  h:  don't apply DISPLAY-HINTs
			  r:  do not check values for range/type legality
			  R:  do random access to OID labels
			  u:  top-level OIDs must have '.' prefix (UCD-style)
			  s SUFFIX:  Append all textual OIDs with SUFFIX before parsing
			  S PREFIX:  Prepend all textual OIDs with PREFIX before parsing
  -L LOGOPTS		Toggle various defaults controlling logging:
			  e:           log to standard error
			  o:           log to standard output
			  n:           don't log at all
			  f file:      log to the specified file
			  s facility:  log to syslog (via the specified facility)

			  (variants)
			  [EON] pri:   log to standard error, output or /dev/null for level 'pri' and above
			  [EON] p1-p2: log to standard error, output or /dev/null for levels 'p1' to 'p2'
			  [FS] pri token:    log to file/syslog for level 'pri' and above
			  [FS] p1-p2 token:  log to file/syslog for levels 'p1' to 'p2'
  -C APPOPTS		Set various application specific behaviours:
			  p:  print the number of variables found
			  i:  include given OID in the search range
			  I:  don't include the given OID, even if no results are returned
			  c:  do not check returned OIDs are increasing
			  t:  Display wall-clock time to complete the walk
			  T:  Display wall-clock time to complete each request
			  E {OID}:  End the walk at the specified OID

La sintaxis más común es la siguiente: snmpwalk -v [Version_SNMP] -c [Comunidad_SNMP] IP

Ejecutamos

snmpwalk -v2c -c public 192.168.1.1

Ejemplo de salida (truncada)

iso.3.6.1.2.1.1.1.0 = STRING: "Cisco NX-OS(tm) nxos.9.3.8.bin, Software (nxos), Version 9.3(8), RELEASE SOFTWARE Copyright (c) 2002-2021 by Cisco Systems, Inc. Compiled 8/4/2021 13:00:00"
iso.3.6.1.2.1.1.2.0 = OID: iso.3.6.1.4.1.9.12.3.1.3.1163
iso.3.6.1.2.1.1.3.0 = Timeticks: (1675649094) 193 days, 22:34:50.94
iso.3.6.1.2.1.1.4.0 = STRING: "email@ejemplo.com"
iso.3.6.1.2.1.1.5.0 = STRING: "CISCONEXUS1"
iso.3.6.1.2.1.1.6.0 = STRING: "Dirección postal de la ubicación del Equipo"
iso.3.6.1.2.1.1.7.0 = INTEGER: 70
iso.3.6.1.2.1.1.8.0 = Timeticks: (4294967262) 497 days, 2:27:52.62
iso.3.6.1.2.1.1.9.1.2.1 = OID: iso.3.6.1.6.3.1
iso.3.6.1.2.1.1.9.1.2.2 = OID: iso.3.6.1.6.3.16.2.2.1
iso.3.6.1.2.1.1.9.1.2.3 = OID: iso.3.6.1.6.3.10.3.1.1
iso.3.6.1.2.1.1.9.1.2.4 = OID: iso.3.6.1.6.3.11.3.1.1
iso.3.6.1.2.1.1.9.1.2.5 = OID: iso.3.6.1.6.3.15.2.1.1
iso.3.6.1.2.1.1.9.1.3.1 = STRING: "The MIB module for SNMPv2 entities"
iso.3.6.1.2.1.1.9.1.3.2 = STRING: "View-based Access Control Model for SNMP."
iso.3.6.1.2.1.1.9.1.3.3 = STRING: "The SNMP Management Architecture MIB."
iso.3.6.1.2.1.1.9.1.3.4 = STRING: "The MIB for Message Processing and Dispatching."
iso.3.6.1.2.1.1.9.1.3.5 = STRING: "The management information definitions for the SNMP User-based Security Model."
iso.3.6.1.2.1.1.9.1.4.1 = Timeticks: (4294967262) 497 days, 2:27:52.62
iso.3.6.1.2.1.1.9.1.4.2 = Timeticks: (4294967262) 497 days, 2:27:52.62
iso.3.6.1.2.1.1.9.1.4.3 = Timeticks: (4294967262) 497 days, 2:27:52.62
iso.3.6.1.2.1.1.9.1.4.4 = Timeticks: (4294967262) 497 days, 2:27:52.62
iso.3.6.1.2.1.1.9.1.4.5 = Timeticks: (4294967262) 497 days, 2:27:52.62
iso.3.6.1.2.1.2.1.0 = INTEGER: 66
iso.3.6.1.2.1.2.2.1.1.83886080 = INTEGER: 83886080
iso.3.6.1.2.1.2.2.1.1.151060481 = INTEGER: 151060481
iso.3.6.1.2.1.2.2.1.1.151060520 = INTEGER: 151060520
iso.3.6.1.2.1.2.2.1.1.151060681 = INTEGER: 151060681
iso.3.6.1.2.1.2.2.1.1.151060682 = INTEGER: 151060682
iso.3.6.1.2.1.2.2.1.1.151060683 = INTEGER: 151060683
iso.3.6.1.2.1.2.2.1.1.151060684 = INTEGER: 151060684
iso.3.6.1.2.1.2.2.1.1.369098752 = INTEGER: 369098752
iso.3.6.1.2.1.2.2.1.1.369098755 = INTEGER: 369098755
iso.3.6.1.2.1.2.2.1.1.369098764 = INTEGER: 369098764
iso.3.6.1.2.1.2.2.1.1.369098765 = INTEGER: 369098765
iso.3.6.1.2.1.2.2.1.1.369098766 = INTEGER: 369098766
iso.3.6.1.2.1.2.2.1.1.369098780 = INTEGER: 369098780
iso.3.6.1.2.1.2.2.1.1.369098781 = INTEGER: 369098781

Para ver únicamente la información de un solo OID

SysLocation

root@nms:/etc/snmp# snmpwalk -v2c -c public 192.168.1.1 SNMPv2-MIB::sysLocation.0
SNMPv2-MIB::sysLocation.0 = STRING: Dirección postal de la ubicación del Equipo

sysName

root@nms:/etc/snmp# snmpwalk -v2c -c public 192.168.1.1 SNMPv2-MIB::sysName.0
SNMPv2-MIB::sysLocation.0 = STRING: CISCONEXUS1

También podemos utilizar el valor OID 

root@nms:/etc/snmp# snmpwalk -v2c -c public 192.168.1.1 .1.3.6.1.2.1.1.6.0
SNMPv2-MIB::sysLocation.0 = STRING: Dirección postal de la ubicación del Equipo