1SNMPCMD(1) Net-SNMP SNMPCMD(1)
2
3
4
6 snmpcmd - options and behaviour common to most of the Net-SNMP command-
7 line tools
8
10 snmpcmd [OPTIONS] AGENT [PARAMETERS]
11
13 This manual page describes the common options for the SNMP commands:
14 snmpbulkget, snmpbulkwalk, snmpdelta, snmpget, snmpgetnext, snmpnet‐
15 stat, snmpset, snmpstatus, snmptable, snmptest, snmptrap, snmpdf, snm‐
16 pusm , snmpwalk . The command line applications use the SNMP protocol
17 to communicate with an SNMP capable network entity, an agent. Individ‐
18 ual applications typically (but not necessarily) take additional param‐
19 eters that are given after the agent specification. These parameters
20 are documented in the manual pages for each application.
21
22
24 -3[MmKk] 0xHEXKEY
25 Sets the keys to be used for SNMPv3 transactions. These options
26 allow you to set the master authentication and encryption keys
27 (-3m and -3M respectively) or set the localized authentication
28 and encryption keys (-3k and -3K respectively). SNMPv3 keys can
29 be either passed in by hand using these flags, or by the use of
30 keys generated from passwords using the -A and -X flags dis‐
31 cussed below. For further details on SNMPv3 and its usage of
32 keying information, see the Net-SNMP tutorial web site (
33 http://www.Net-SNMP.org/tutorial-5/commands/ ). Overrides the
34 defAuthMasterKey (-3m), defPrivMasterKey (-3M), defAuthLocal‐
35 izedKey (-3k) or defPrivLocalizedKey (-3K) tokens, respectively,
36 in the snmp.conf file, see snmp.conf(5).
37
38 -a authProtocol
39 Set the authentication protocol (MD5 or SHA) used for authenti‐
40 cated SNMPv3 messages. Overrides the defAuthType token in the
41 snmp.conf file.
42
43 -A authPassword
44 Set the authentication pass phrase used for authenticated SNMPv3
45 messages. Overrides the defAuthPassphrase token in the
46 snmp.conf file. It is insecure to specify pass phrases on the
47 command line, see snmp.conf(5).
48
49 -c community
50 Set the community string for SNMPv1/v2c transactions. Overrides
51 the defCommunity token in the snmp.conf file.
52
53 -d Dump (in hexadecimal) the raw SNMP packets sent and received.
54
55 -D TOKEN[,...]
56 Turn on debugging output for the given TOKEN(s). Try ALL for
57 extremely verbose output.
58
59 -e engineID
60 Set the authoritative (security) engineID used for SNMPv3
61 REQUEST messages. It is typically not necessary to specify
62 this, as it will usually be discovered automatically.
63
64 -E engineID
65 Set the context engineID used for SNMPv3 REQUEST messages scope‐
66 dPdu. If not specified, this will default to the authoritative
67 engineID.
68
69 -h, --help
70 Display a brief usage message and then exit.
71
72 -H Display a list of configuration file directives understood by
73 the command and then exit.
74
75 -I [brRhu]
76 Specifies input parsing options. See INPUT OPTIONS below.
77
78 -l secLevel
79 Set the securityLevel used for SNMPv3 messages (noAuthNo‐
80 Priv|authNoPriv|authPriv). Appropriate pass phrase(s) must pro‐
81 vided when using any level higher than noAuthNoPriv. Overrides
82 the defSecurityLevel token in the snmp.conf file.
83
84 -L [eEfFoOsS]
85 Specifies output logging options. See LOGGING OPTIONS below.
86
87 -m MIBLIST
88 Specifies a colon separated list of MIB modules (not files) to
89 load for this application. This overrides (or augments) the
90 environment variable MIBS, the snmp.conf directive mibs, and the
91 list of MIBs hardcoded into the Net-SNMP library.
92
93 If MIBLIST has a leading '-' or '+' character, then the MIB mod‐
94 ules listed are loaded in addition to the default list, coming
95 before or after this list respectively. Otherwise, the speci‐
96 fied MIBs are loaded instead of this default list.
97
98 The special keyword ALL is used to load all MIB modules in the
99 MIB directory search list. Every file whose name does not begin
100 with "." will be parsed as if it were a MIB file.
101
102 -M DIRLIST
103 Specifies a colon separated list of directories to search for
104 MIBs. This overrides (or augments) the environment variable
105 MIBDIRS, the snmp.conf directive mibdirs, and the default direc‐
106 tory hardcoded into the Net-SNMP library (/usr/share/snmp/mibs).
107
108 If DIRLIST has a leading '-' or '+' character, then the given
109 directories are added to the default list, being searched before
110 or after the directories on this list respectively. Otherwise,
111 the specified directories are searched instead of this default
112 list.
113
114 Note that the directories appearing later in the list have have
115 precedence over earlier ones. To avoid searching any MIB direc‐
116 tories, set the MIBDIRS environment variable to the empty string
117 ("").
118
119 Note that MIBs specified using the -m option or the mibs config‐
120 uration directive will be loaded from one of the directories
121 listed by the -M option (or equivalents). The mibfile directive
122 takes a full path to the specified MIB file, so this does not
123 need to be in the MIB directory search list.
124
125 -n contextName
126 Set the contextName used for SNMPv3 messages. The default con‐
127 textName is the empty string "". Overrides the defContext token
128 in the snmp.conf file.
129
130 -O [abeEfnqQsStTuUvxX]
131 Specifies output printing options. See OUTPUT OPTIONS below.
132
133 -P [cdeRuwW]
134 Specifies MIB parsing options. See MIB PARSING OPTIONS below.
135
136 -r retries
137 Specifies the number of retries to be used in the requests. The
138 default is 5.
139
140 -t timeout
141 Specifies the timeout in seconds between retries. The default is
142 1.
143
144 -u secName
145 Set the securityName used for authenticated SNMPv3 messages.
146 Overrides the defSecurityName token in the snmp.conf file.
147
148 -v 1 | 2c | 3
149 Specifies the protocol version to use: 1 (RFCs 1155-1157), 2c
150 (RFCs 1901-1908), or 3 (RFCs 2571-2574). The default is typi‐
151 cally version 3. Overrides the defVersion token in the
152 snmp.conf file.
153
154 -V, --version
155 Display version information for the application and then exit.
156
157 -x privProtocol
158 Set the privacy protocol (DES or AES) used for encrypted SNMPv3
159 messages. Overrides the defPrivType token in the snmp.conf
160 file. This option is only valid if the Net-SNMP software was
161 build to use OpenSSL.
162
163 -X privPassword
164 Set the privacy pass phrase used for encrypted SNMPv3 messages.
165 Overrides the defPrivPassphrase token in the snmp.conf file. It
166 is insecure to specify pass phrases on the command line, see
167 snmp.conf(5).
168
169 -Z boots,time
170 Set the engineBoots and engineTime used for authenticated SNMPv3
171 messages. This will initialize the local notion of the agents
172 boots/time with an authenticated value stored in the LCD. It is
173 typically not necessary to specify this option, as these values
174 will usually be discovered automatically.
175
176 -Yname="value"
177
178 --name="value"
179 Allows to specify any token ("name") supported in the snmp.conf
180 file and sets its value to "value". Overrides the corresponding
181 token in the snmp.conf file. See snmp.conf(5) for the full list
182 of tokens.
183
184
186 The string AGENT in the SYNOPSIS above specifies the remote SNMP entity
187 with which to communicate. This specification takes the form:
188
189 [<transport-specifier>:]<transport-address>
190
191 At its simplest, the AGENT specification may consist of a hostname, or
192 an IPv4 address in the standard "dotted quad" notation. In this case,
193 communication will be attempted using UDP/IPv4 to port 161 of the given
194 host. Otherwise, the <transport-address> part of the specification is
195 parsed according to the following table:
196
197 <transport-specifier> <transport-address> format
198
199 udp hostname[:port] or IPv4-address[:port]
200
201 tcp hostname[:port] or IPv4-address[:port]
202
203 unix pathname
204
205 ipx [network]:node[/port]
206
207 aal5pvc or pvc [interface.][VPI.]VCI
208
209 udp6 or udpv6 or udpipv6 hostname[:port] or IPv6-address:port or
210 '['IPv6-address']'[:port]
211
212 tcp6 or tcpv6 or tcpipv6 hostname[:port] or IPv6-address:port or
213 '['IPv6-address']'[:port]
214
215 Note that <transport-specifier> strings are case-insensitive so that,
216 for example, "tcp" and "TCP" are equivalent. Here are some examples,
217 along with their interpretation:
218
219 hostname:161 perform query using UDP/IPv4 datagrams to host‐
220 name on port 161. The ":161" is redundant here
221 since that is the default SNMP port in any
222 case.
223
224 udp:hostname identical to the previous specification. The
225 "udp:" is redundant here since UDP/IPv4 is the
226 default transport.
227
228 TCP:hostname:1161 connect to hostname on port 1161 using TCP/IPv4
229 and perform query over that connection.
230
231 ipx::00D0B7AAE308 perform query using IPX datagrams to node num‐
232 ber 00D0B7AAE308 on the default network, and
233 using the default IPX port of 36879 (900F hexa‐
234 decimal), as suggested in RFC 1906.
235
236 ipx:0AE43409:00D0B721C6C0/1161
237 perform query using IPX datagrams to port 1161
238 on node number 00D0B721C6C0 on network number
239 0AE43409.
240
241 unix:/tmp/local-agent connect to the Unix domain socket /tmp/local-
242 agent, and perform the query over that connec‐
243 tion.
244
245 /tmp/local-agent identical to the previous specification, since
246 the Unix domain is the default transport iff
247 the first character of the <transport-address>
248 is a '/'.
249
250 AAL5PVC:100 perform the query using AAL5 PDUs sent on the
251 permanent virtual circuit with VPI=0 and
252 VCI=100 (decimal) on the first ATM adapter in
253 the machine.
254
255 PVC:1.10.32 perform the query using AAL5 PDUs sent on the
256 permanent virtual circuit with VPI=10 (decimal)
257 and VCI=32 (decimal) on the second ATM adapter
258 in the machine. Note that "PVC" is a synonym
259 for "AAL5PVC".
260
261 udp6:hostname:10161 perform the query using UDP/IPv6 datagrams to
262 port 10161 on hostname (which will be looked up
263 as an AAAA record).
264
265 UDP6:[fe80::2d0:b7ff:fe21:c6c0]
266 perform the query using UDP/IPv6 datagrams to
267 port 161 at address fe80::2d0:b7ff:fe21:c6c0.
268
269 tcpipv6:[::1]:1611 connect to port 1611 on the local host (::1 in
270 IPv6 parlance) using TCP/IPv6 and perform query
271 over that connection.
272
273 Note that not all the transport domains listed above will always be
274 available; for instance, hosts with no IPv6 support will not be able to
275 use udp6 transport addresses, and attempts to do so will result in the
276 error "Unknown host". Likewise, since AAL5 PVC support is only cur‐
277 rently available on Linux, it will fail with the same error on other
278 platforms.
279
280
282 The Net-SNMP MIB parser mostly adheres to the Structure of Management
283 Information (SMI). As that specification has changed through time, and
284 in recognition of the (ahem) diversity in compliance expressed in MIB
285 files, additional options provide more flexibility in reading MIB
286 files.
287
288 -Pc Allow ASN.1 comments to extend to the end of the MIB source
289 line. Strictly speaking, a second appearance of "--" should
290 terminate the comment, but this breaks some MIB files. This be‐
291 haviour can also be set with the configuration token strictCom‐
292 mentTerm.
293
294 -Pd Disables saving the DESCRIPTION of MIB objects when parsing MIB
295 files, reducing the amount of memory used by the running appli‐
296 cation.
297
298 -Pe Show errors encountered when parsing MIB files. These include
299 references to IMPORTed modules and MIB objects that cannot be
300 located in the MIB directory search list. This can also be set
301 with the configuration token showMibErrors.
302
303 -PR If the same MIB object (parent name and sub-identifier) appears
304 multiple times in the list of MIB definitions loaded, use the
305 last version to be read in. By default, the first version will
306 be used, and any duplicates discarded. This behaviour can also
307 be set with the configuration token mibReplaceWithLatest.
308
309 Such ordering is normally only relevant if there are two MIB
310 files with conflicting object definitions for the same OID (or
311 different revisions of the same basic MIB object).
312
313 -Pu Allow the underline character in MIB object names and other sym‐
314 bols. Strictly speaking, this is not valid SMI syntax, but some
315 vendor MIB files define such names. This can also be set with
316 the configuration token mibAllowUnderline.
317
318 -Pw Show various warning messages in parsing MIB files and building
319 the overall OID tree. This can also be set with the configura‐
320 tion directive mibWarningLevel 1
321
322 -PW Show some additional warning messages, mostly relating to pars‐
323 ing individual MIB objects. This can also be set with the con‐
324 figuration directive mibWarningLevel 2
325
326
328 The format of the output from SNMP commands can be controlled using
329 various parameters of the -O flag. The effects of these sub-options
330 can be seen by comparison with the following default output (unless
331 otherwise specified):
332 $ snmpget -c public -v 1 localhost sysUpTime.0
333 SNMPv2-MIB::sysUpTime.0 = Timeticks: (14096763) 1 day, 15:09:27.63
334
335
336 -Oa Display string values as ASCII strings (unless there is a DIS‐
337 PLAY-HINT defined for the corresponding MIB object). By
338 default, the library attempts to determine whether the value is
339 a printable or binary string, and displays it accordingly.
340
341 This option does not affect objects that do have a Display Hint.
342
343 -Ob Display table indexes numerically, rather than trying to inter‐
344 pret the instance subidentifiers as string or OID values:
345 $ snmpgetnext -c public -v 1 localhost vacmSecurityModel
346 SNMP-VIEW-BASED-ACM-MIB::vacmSecurityModel.0."wes" = xxx
347 $ snmpgetnext -c public -v 1 -Ob localhost vacmSecurityModel
348 SNMP-VIEW-BASED-ACM-MIB::vacmSecurityModel.0.3.119.101.115 = xxx
349
350 -Oe Removes the symbolic labels from enumeration values:
351 $ snmpget -c public -v 1 localhost ipForwarding.0
352 IP-MIB::ipForwarding.0 = INTEGER: forwarding(1)
353 $ snmpget -c public -v 1 -Oe localhost ipForwarding.0
354 IP-MIB::ipForwarding.0 = INTEGER: 1
355
356 -OE Modifies index strings to escape the quote characters:
357 $ snmpgetnext -c public -v 1 localhost vacmSecurityModel
358 SNMP-VIEW-BASED-ACM-MIB::vacmSecurityModel.0."wes" = xxx
359 $ snmpgetnext -c public -v 1 -OE localhost vacmSecurityModel
360 SNMP-VIEW-BASED-ACM-MIB::vacmSecurityModel.0.\"wes\" = xxx
361
362 This allows the output to be reused in shell commands.
363
364 -Of Include the full list of MIB objects when displaying an OID:
365 .iso.org.dod.internet.mgmt.mib-2.system.sysUpTime.0 =
366 Timeticks: (14096763) 1 day, 15:09:27.63
367
368 -On Displays the OID numerically:
369 .1.3.6.1.2.1.1.3.0 = Timeticks: (14096763) 1 day,
370 15:09:27.63
371
372 -Oq Removes the equal sign and type information when displaying
373 varbind values:
374 SNMPv2-MIB::sysUpTime.0 1:15:09:27.63
375
376 -OQ Removes the type information when displaying varbind values:
377 SNMPv2-MIB::sysUpTime.0 = 1:15:09:27.63
378
379 -Os Display the MIB object name (plus any instance or other subiden‐
380 tifiers):
381 sysUpTime.0 = Timeticks: (14096763) 1 day, 15:09:27.63
382
383 -OS Display the name of the MIB, as well as the object name:
384 SNMPv2-MIB::sysUpTime.0 = Timeticks: (14096763) 1 day,
385 15:09:27.63
386
387 This is the default OID output format.
388
389 -Ot Display TimeTicks values as raw numbers:
390 SNMPv2-MIB::sysUpTime.0 = 14096763
391
392 -OT If values are printed as Hex strings, display a printable ver‐
393 sion as well.
394
395 -Ou Display the OID in the traditional UCD-style (inherited from the
396 original CMU code). That means removing a series of "standard"
397 prefixes from the OID, and displaying the remaining list of MIB
398 object names (plus any other subidentifiers):
399 system.sysUpTime.0 = Timeticks: (14096763) 1 day,
400 15:09:27.63
401
402 -OU Do not print the UNITS suffix at the end of the value.
403
404 -Ov Display the varbind value only, not the OID:
405 $ snmpget -c public -v 1 -Oe localhost ipForwarding.0
406 INTEGER: forwarding(1)
407
408 -Ox Display string values as Hex strings (unless there is a DISPLAY-
409 HINT defined for the corresponding MIB object). By default, the
410 library attempts to determine whether the value is a printable
411 or binary string, and displays it accordingly.
412
413 This option does not affect objects that do have a Display Hint.
414
415 -OX Display table indexes in a more "program like" output, imitating
416 a traditional array-style index format:
417 $ snmpgetnext -c public -v 1 localhost ipv6RouteTable
418 IPv6-MIB::ipv6RouteIfIndex.63.254.1.0.255.0.0.0.0.0.0.0.0.0.0.0.64.1 = INTEGER: 2
419 $ snmpgetnext -c public -v 1 -OE localhost ipv6RouteTable
420 IPv6-MIB::ipv6RouteIfIndex[3ffe:100:ff00:0:0:0:0:0][64][1] = INTEGER: 2
421
422 Most of these options can also be configured via configuration tokens.
423 See the snmp.conf(5) manual page for details.
424
425
427 The mechanism and destination to use for logging of warning and error
428 messages can be controlled by passing various parameters to the -L
429 flag.
430
431 -Le Log messages to the standard error stream.
432
433 -Lf FILE
434 Log messages to the specified file.
435
436 -Lo Log messages to the standard output stream.
437
438 -Ls FACILITY
439 Log messages via syslog, using the specified facility ('d' for
440 LOG_DAEMON, 'u' for LOG_USER, or '0'-'7' for LOG_LOCAL0 through
441 LOG_LOCAL7).
442
443 There are also "upper case" versions of each of these options, which
444 allow the corresponding logging mechanism to be restricted to certain
445 priorities of message. Using standard error logging as an example:
446
447 -LE pri
448 will log messages of priority 'pri' and above to standard error.
449
450 -LE p1-p2
451 will log messages with priority between 'p1' and 'p2' (inclu‐
452 sive) to standard error.
453
454 For -LF and -LS the priority specification comes before the file or
455 facility token. The priorities recognised are:
456
457 0 or ! for LOG_EMERG,
458 1 or a for LOG_ALERT,
459 2 or c for LOG_CRIT,
460 3 or e for LOG_ERR,
461 4 or w for LOG_WARNING,
462 5 or n for LOG_NOTICE,
463 6 or i for LOG_INFO, and
464 7 or d for LOG_DEBUG.
465
466 Normal output is (or will be!) logged at a priority level of LOG_NOTICE
467
468
470 The interpretation of input object names and the values to be assigned
471 can be controlled using various parameters of the -I flag. The default
472 behaviour will be described at the end of this section.
473
474 -Ib specifies that the given name should be regarded as a regular
475 expression, to match (case-insensitively) against object names
476 in the MIB tree. The "best" match will be used - calculated as
477 the one that matches the closest to the beginning of the node
478 name and the highest in the tree. For example, the MIB object
479 vacmSecurityModel could be matched by the expression vacmsecuri‐
480 tymodel (full name, but different case), or vacm.*model (regexp
481 pattern).
482
483 Note that '.' is a special character in regular expression pat‐
484 terns, so the expression cannot specify instance subidentifiers
485 or more than one object name. A "best match" expression will
486 only be applied against single MIB object names. For example,
487 the expression sys*ontact.0 would not match the instance sysCon‐
488 tact.0 (although sys*ontact would match sysContact). Similarly,
489 specifying a MIB module name will not succeed (so
490 SNMPv2-MIB::sys.*ontact would not match either).
491
492 -Ih disables the use of DISPLAY-HINT information when assigning val‐
493 ues. This would then require providing the raw value:
494 snmpset ... HOST-RESOURCES-MIB::hrSystemData.0
495 x "07 D2 0C 0A 02 04 06 08"
496 instead of a formatted version:
497 snmpset ... HOST-RESOURCES-MIB::hrSystemDate.0
498 = 2002-12-10,2:4:6.8
499
500 -Ir disables checking table indexes and the value to be assigned
501 against the relevant MIB definitions. This will (hopefully)
502 result in the remote agent reporting an invalid request, rather
503 than checking (and rejecting) this before it is sent to the
504 remote agent.
505
506 Local checks are more efficient (and the diagnostics provided
507 also tend to be more precise), but disabling this behaviour is
508 particularly useful when testing the remote agent.
509
510 -IR enables "random access" lookup of MIB names. Rather than pro‐
511 viding a full OID path to the desired MIB object (or qualifying
512 this object with an explicit MIB module name), the MIB tree will
513 be searched for the matching object name. Thus
514 .iso.org.dod.internet.mib-2.system.sysDescr.0 (or
515 SNMPv2-MIB::sysDescr.0) can be specified simply as sysDescr.0.
516
517 Warning:
518 Since MIB object names are not globally unique, this
519 approach may return a different MIB object depending on
520 which MIB files have been loaded.
521
522 The MIB-MODULE::objectName syntax has the advantage of uniquely
523 identifying a particular MIB object, as well as being slightly
524 more efficient (and automatically loading the necessary MIB file
525 if necessary).
526
527 -Is SUFFIX
528 adds the specified suffix to each textual OID given on the com‐
529 mand line. This can be used to retrieve multiple objects from
530 the same row of a table, by specifying a common index value.
531
532 -IS PREFIX
533 adds the specified prefix to each textual OID given on the com‐
534 mand line. This can be used to specify an explicit MIB module
535 name for all objects being retrieved (or for incurably lazy typ‐
536 ists).
537
538 -Iu enables the traditional UCD-style approach to interpreting input
539 OIDs. This assumes that OIDs are rooted at the 'mib-2' point in
540 the tree (unless they start with an explicit '.' or include a
541 MIB module name). So the sysDescr instance above would be ref‐
542 erenced as system.sysDescr.0.
543
544
545 Object names specified with a leading '.' are always interpreted as
546 "fully qualified" OIDs, listing the sequence of MIB objects from the
547 root of the MIB tree. Such objects and those qualified by an explicit
548 MIB module name are unaffected by the -Ib, -IR and -Iu flags.
549
550 Otherwise, if none of the above input options are specified, the
551 default behaviour for a "relative" OID is to try and interpret it as an
552 (implicitly) fully qualified OID, then apply "random access" lookup
553 (-IR), followed by "best match" pattern matching (-Ib).
554
555
557 PREFIX The standard prefix for object identifiers (when using UCD-style
558 output). Defaults to .iso.org.dod.internet.mgmt.mib-2
559
560 MIBS The list of MIBs to load. Defaults to SNMPv2-TC:SNMPv2-MIB:IF-
561 MIB:IP-MIB:TCP-MIB:UDP-MIB:SNMP-VACM-MIB. Overridden by the -m
562 option.
563
564 MIBDIRS
565 The list of directories to search for MIBs. Defaults to
566 /usr/share/snmp/mibs. Overridden by the -M option.
567
568
570 /etc/snmp/snmpd.conf
571 Agent configuration file. See snmpd.conf(5).
572
573 /etc/snmp/snmp.conf
574
575 ~/.snmp/snmp.conf
576 Application configuration files. See snmp.conf(5).
577
578
580 snmpget(1), snmpgetnext(1), snmpset(1), snmpbulkget(1), snmpbulk‐
581 walk(1), snmpwalk(1), snmptable(1), snmpnetstat(1), snmpdelta(1),
582 snmptrap(1), snmpinform(1), snmpusm(1), snmpstatus(1), snmptest(1),
583 snmp.conf(5).
584
585
586
587
5884th Berkeley Distribution 29 Jun 2005 SNMPCMD(1)