BSNMPGET(1)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’– bsnmpget(1) πŸ’– β€” General Commands Manual, section 1

okay so before we even start: this is the manual for bsnmpget, bsnmpwalk and bsnmpset, and they live in section 1 of the General Commands Manual. three little tools, one big page, and honestly? they're lowkey iconic once you get what they do. let's go 🫢


✨ NAME ✨

bsnmpget, bsnmpwalk, bsnmpset β€” simple tools for querying SNMP agents πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

bsnmpget [-aDdehnK] [-A options] [-b buffersize] [-C options]
         [-I options] [-i filelist] [-l filename] [-M max-repetitions]
         [-N non-repeaters] [-o output] [-P options] [-p pdu]
         [-r retries] [-s [trans::][community@][server][:port]]
         [-t timeout] [-U options] [-v version] [OID ...]

bsnmpwalk [-dhnK] [-A options] [-b buffersize] [-C options] [-I options]
         [-i filelist] [-l filename] [-o output] [-P options]
         [-r retries] [-s [trans::][community@][server][:port]]
         [-t timeout] [-U options] [-v version] [OID ...]

bsnmpset [-adehnK] [-A options] [-b buffersize] [-C options]
         [-I options] [-i filelist] [-l filename] [-o output]
         [-P options] [-r retries]
         [-s [trans::][community@][server][:port]] [-t timeout]
         [-U options] [-v version] OID= syntax:value
         [OID= syntax:value ...]

🌸 DESCRIPTION 🌸

okay so picture this: bsnmpget, bsnmpwalk and bsnmpset are your three little besties for talking to a Simple Network Management Protocol (SNMP) agent. two of them retrieve management information from it, and one of them sets management information on it. slay πŸ’…

depending on the options you give it, bsnmpget builds either a SNMP GetRequest, a GetNextRequest or a GetBulkRequest packet, fills in the object identifiers (OIDs) of the objects whose values you wanna retrieve, waits for a response, and prints it if it came back successfully. no cap, that's the whole vibe.

Bsnmpwalk is the wanderer of the group β€” it queries an agent with ether SNMP GetNextRequest or GetBulkRequest packets, asking for values of OID instances that are a part of the object subtree rooted at the OIDs you provided. it's giving "walk the whole tree, bestie" 🌳

Bsnmpset is the one that actually changes things: it constructs a SNMP SetRequest packet, fills in the OIDs (object identifiers), syntaxes and values of the objects whose values are to be set, and then waits for a response from the server. main character energy, but be careful with this one πŸ‘‘


πŸŽ€ OPTIONS πŸŽ€

here's the rundown, bestie β€” and note that not all of these apply to all three programs (iykyk):

  • -A options β€” authentication options to use with SNMPv3 PDUs πŸ”
    • proto=[md5|sha] β€” the protocol to use when calculating the PDU message digest.
    • key=authkey β€” a binary localized authentication key to use when calculating the PDU message digest.
by default, SNMPv3 PDUs are sent unauthenticated. that's the default, not a judgement πŸ’€
  • -a β€” skip any sanity checks when adding OIDs to a Protocol Data Unit (PDU): ignore syntax/access type, allow adding of non-leaf objects for GetPdu and read-only objects to a SetPDU. it's giving "I know what I'm doing" β€” hopefully you do πŸ™ˆ
  • -b buffersize β€” tune the size of buffers used to send and receive packets. the default size is 10000 bytes, which should be enough unless an agent sends a really large octetstring. the maximum allowed length is 65535 according to the Structure of Management Information (SMIv2). big buffer energy ✨
  • -C options β€” the context to query with SNMPv3 PDUs.
    • context=name β€” the context name. default is "" (empty).
    • context-engine=engine-id β€” the SNMP Engine ID of the context to query with SNMPv3 PDUs, represented as binary octet string. by default, this is set to the Engine ID of the SNMP agent.
  • -D β€” perform SNMP USM Engine Discovery, rather than sending a request for the value of a specific object. it's giving detective mode πŸ”
  • -d β€” turn on debugging. this option will cause the packets sent and received to be dumped to the terminal. honestly the most fun you can have with a terminal, ngl πŸ›
  • -e β€” retry on error. if an error is returned in the response PDU, resend the request removing the variable that caused the error until a valid response is received. this is only useful for a GetRequest- and a GetNextRequest-PDU. stubborn little icon πŸ’…
  • -h β€” print a short help text with default values for various options. when in doubt, -h it out 🫢
  • -I options β€” load each MIB description file from the given list to translate symbolic object names to their numerical representation and vice versa. use the other options to obtain a non-default behaviour:
    • cut=OID β€” specifies the initial OID that was cut by gensnmpdef(1) when producing the MIB description file. the default value is .iso(1).org(3).dod(6) which is what should have been used for all the files installed under /usr/share/snmp/defs. use this only if you generated your own files, providing a -c option to gensnmpdef(1).
    • path=filedir β€” the directory where files in the list will be searched. the default is /usr/share/snmp/defs.
    • file=filelist β€” a comma separated list of files to which the two options above will apply.
⚠️ the file suboption has to come after the other suboptions so that their non-default values will be applied to the list of files. the order of the other suboptions before each file suboption can be random. suboptions may be separated either by commas or by spaces. if using spaces, make sure the entire option string is one argument β€” for example using quotes. no cap, this trips people up 😭
  • -i filelist β€” list of MIB description files produced by gensnmpdef(1) which bsnmpget, bsnmpwalk or bsnmpset will search to translate numerical OIDs to their symbolic object names. multiple files can be provided either giving this option multiple times or a comma separated list of file names. if a filename begins with a letter, the default directory, /usr/share/snmp/defs, will be searched. πŸ—‚οΈ
  • -K β€” calculate and display the localized authentication and privacy keys corresponding to a plain text password. the password is obtained via the environment. additionally, if one or more OIDs are specified, the calculated keys are used when processing the SNMPv3 requests. key girl summer πŸ”‘πŸ‘‘
  • -l filename β€” the path of the posix local (unix domain) socket if local transport is used.
  • -M max-repetitions β€” the value for the max-repetitions field in a GetBulk PDU. default is 10.
  • -N non-repeaters β€” the value for the non-repeaters field in a GetBulk PDU. default is 0.
  • -n β€” only use numerical representations for input and output OIDs and do not try to resolve symbolic object names. note that bsnmpget, bsnmpwalk and bsnmpset will print numerical OIDs anyway if the corresponding string representation is not found in the MIB description files. numbers only, no names, no vibes πŸ”’
  • -o [quiet|short|verbose] β€” the format used to print the received response. quiet only prints values; short (default) prints an abbreviated OID representation and the value. in addition to the short output, verbose prints the type before the value. choose your aesthetic πŸ’«
  • -P options β€” privacy options to use with SNMPv3 PDUs πŸ”’
    • proto=[aes|des] β€” the protocol to use when encrypting/decrypting SNMPv3 PDU data.
    • key=privkey β€” a binary localized privacy key to use when encrypting/decrypting SNMPv3 PDU data.
by default plain text SNMPv3 PDUs are sent. yes, plain text. that's just what the default is πŸ™ˆ
  • -p [get|getnext|getbulk] β€” the PDU type to send by bsmpget and bsnmpwalk. default is get for bsmpget and getnext for bsnmpwalk. Getbulk allows executing the so called SNMP "bulkwalks", allowing the values of multiple columns to be retrieved in a single PDU by bsnmpwalk. bulk it up, bestie πŸ”₯
  • -r retries β€” number of resends of request packets before giving up if the agent does not respond after the first try. default is 3. never give up, never surrender (for three tries) 😀
  • -s [trans::][community@][server][:port] β€” each of the server specification components is optional but at least one has to be provided if the s option is used. the server specification is constructed in the following manner:
    • trans:: β€” transport type may be one of udp, stream or dgram. if this option is not provided, an UDP inet/inet6 socket will be used, which is the most common. Stream stands for a posix local stream socket and a posix local datagram socket will be used if dgram is specified.
    • community@ β€” specify an SNMP community string to be used when sending packets. if the option is skipped, the default "public" will be used for bsnmpget and bsnmpwalk and the default "private" community string will be used for bsnmpset.
    • server β€” this might be either the IP address or the hostname where the agent is listening. the default is "localhost". 🏠
    • port β€” the destination port to send the requests to. this is useful if the SNMP agent listens on a non-default port. default is given by the "snmp" entry in /etc/services, port 161.
  • -t timeout β€” number of seconds before resending a request packet if the agent does not respond. the default value is 3 seconds. ⏰
  • -U options β€” user credentials when sending SNMPv3 PDUs.
    • engine=id β€” the Engine ID of the SNMP agent represented as a binary octet string.
    • engine-boots=value β€” the value of the snmpEngineBoots of the SNMP agent.
    • engine-time=value β€” the value of the snmpEngineTime of the SNMP agent.
if any of the above is not specified, SNMP USM Engine Discovery is attempted. this is also the default behavior.
  • name=username β€” the USM user name to include in the SNMPv3 PDUs. by default, the user name is obtained via the environment. 🫢
  • -v version β€” the SNMP protocol version to use when sending requests. SNMP versions 1, 2 and 3 are supported. if no version option is provided, bsnmpget, bsnmpwalk and bsnmpset will use version 2. note that GetBulkRequest-PDUs were introduced in SNMPv2, thus setting the version to 1 is incompatible with sending a GetBulk PDU. πŸ’€ don't do that to yourself.
  • OID β€” the object identifier whose value to retrieve. at least one OID should be provided for bsnmpget to be able to send a request. one is the minimum, bestie 🌟

  • OID β€” and here's the tea for bsnmpwalk specifically πŸ«– this is the root object identifier of the subtree whose values are gonna get retrieved. And if you don't hand over an OID at all? No stress, bestie, bsnmpwalk will just walk the whole mib2 subtree rooted at .iso(1).org(3).dod(6).internet(1).mgmt(2).mib2(1). Default slay ✨

Any of the formats used to print a single variable is valid as input OID too β€” literally any of them πŸ’…

1.3.6.1.2.1.25.1.1.0

sysDescr

ifPhysAddress.1

ifRcvAddressStatus.2.6.255.255.255.255.255.255

ifRcvAddressType[2,ff:ff:ff:ff:ff:ff]

ifRcvAddressStatus[Integer:1,OctetString:ff:ff:ff:ff:ff:ff]
  (requires the -o verbose option)

So those square brackets [ ]? They're how you denote an entry's indexes πŸŽ€ But heads up β€” when you use them in an input OID, the square brackets may have to be escaped, or the whole OID has to be quoted, to protect it from the shell. Your shell is not your friend here, she's the main character of her own story 😭 And yeah, there is no difference between ifName.1 and "ifName[1]" β€” same thing, different outfit πŸ’–

  • OID=[syntax:]value β€” the object identifier, plus its syntax type, plus the value that's about to be set πŸ‘‘ At least one such OID=[syntax:]value string should be provided to bsnmpset to be able to send a request. Zero of them = no request, no vibes, nothing sent πŸ™ˆ
    • OID β€” and this one is flexible fr fr. OID may be input as:
      • a string,
      • a string followed by a random number of integers (suboids) separated by dots,
      • a sequence of integers separated by dots β€” that is, if the n option is used β€” and in such case a syntax is required for every value,
      • or a string followed by square brackets (used to denote an entry's indexes) and corresponding indexes.

And any of the formats used to print a single variable by bsnmpset is valid as input OID as well 😌

1.3.6.1.2.1.25.1.1.0=TimeTicks:537615486

sysLocation=OctetString:"@ Home" (with -o verbose option)

sysLocation.0="@ Home"

1.3.6.1.2.1.2.2.1.6.1=OctetString:ffffffffffff

ifPhysAddress.1="00:02:b3:1d:1c:a3"

ifRcvAddressStatus.1.6.255.255.255.255.255.255=1

ifRcvAddressStatus[Integer:1,OctetString:ff:ff:ff:ff:ff:ff]=Integer:1
  (with the -o verbose option)
  • syntax β€” where the syntax string is one of: Integer, OctetString, OID, IpAddress, Counter32, Gauge, TimeTicks, Counter64. That's the whole squad, no additions, no substitutions 🧚
  • value β€” the value to be set πŸ’œ IP addresses go in the form u.u.u.u, for example 1.3.1.6.1.2.0=IpAddress:192.168.0.1. Strings require inverted-commas if they contain any special characters or spaces. All the other numeric types? They do not. Numeric girlies don't need the quotes πŸ”₯

🌸 ENVIRONMENT 🌸

bsnmpget, bsnmpwalk and bsnmpset use the following environment variables β€” yes, all three of them, this is a shared situation 🫢

  • SNMPAUTH β€” specifies a default SNMP USM authentication protocol.
  • SNMPPRIV β€” specifies a default SNMP USM privacy protocol.
  • SNMPUSER β€” specifies a default SNMP USM user name.
  • SNMPPASSWD β€” specifies the SNMP USM plain text password to use when calculating localized authentication and privacy keys. And the iconic plot twist: if this variable exists in the environment, SNMPv3 is the default version to use for outgoing requests. Not me setting one env var and changing my whole default version πŸ˜­πŸ’…

πŸ¦‹ SEE ALSO πŸ¦‹

  • gensnmpdef(1)

Go read that one too, bestie, it's giving required reading πŸ“šβœ¨


πŸ‘‘ AUTHORS πŸ‘‘

Shteryana Shopova <syrinx@FreeBSD.org>

An absolute legend, no cap πŸ™Œ


So yeah, that's the whole vibe β€” this page comes from the Debian crowd, dated January 10, 2012, and honestly it still ate πŸ’– Go forth and poll your hearts out, you've got this fr fr πŸŽ€πŸ¦‹βœ¨

πŸ“¦ where this page comes from