网络管理人员应该掌握这个小工具,命令虽简单,但在交换机、路由器监控上有可以起到不小作用。在企业内,很多管理员都可能会被这样一个问题困扰:企业内部员工有不同的网络权限,有些可以上外网,有些不能上外网。这样有些员会私自更改IP,网络管理员很难立即去发现这个问题,只有等到有员工报IP冲突故障时才发现有人盗用IP,然后管理才开始去查谁谁盗用了这个IP,可能有些管理人员还查不出来是谁盗用了这个IP,没法了,只有把这个IP权限改了
snmpwalk 可以有效解决这个问题
方法:
1:在企业内部核心交换机上,开启SNMP功能
2:找到交换机的一个特殊OID号,默认是1.3.6.1.4.1.2011.5.25.123.1.12
3:读取IP对应的MAC
4:实例:/usr/bin/snmpwalk -v 2c -c 'xxxxx' 192.168.1.1
1.3.6.1.4.1.2011.5.25.123.1.12
snmpwalk :手册
snmpwalk - retrieve a subtree of management values using SNMP GETNEXT requests
SYNOPSIS
snmpwalk [APPLICATION OPTIONS] [COMMON OPTIONS] [OID]
DESCRIPTION
snmpwalk is an SNMP application that uses SNMP GETNEXT requests to query a network entity for a tree of infor-
mation.
An object identifier (OID) may be given on the command line. This OID specifies which portion of the object
identifier space will be searched using GETNEXT requests. All variables in the subtree below the given OID are
queried and their values presented to the user. Each variable name is given in the format specified in vari-
ables(5).
If no OID argument is present, snmpwalk will search the subtree rooted at SNMPv2-SMI::mib-2 (including any MIB
object values from other MIB modules, that are defined as lying within this subtree). If the network entity
has an error processing the request packet, an error packet will be returned and a message will be shown, help-
ing to pinpoint why the request was malformed.
If the tree search causes attempts to search beyond the end of the MIB, the message "End of MIB" will be dis-
played.
OPTIONS
-Cc Do not check whether the returned OIDs are increasing. Some agents (LaserJets are an example) return
OIDs out of order, but can complete the walk anyway. Other agents return OIDs that are out of order
and can cause snmpwalk to loop indefinitely. By default, snmpwalk tries to detect this behavior and
warns you when it hits an agent acting illegally. Use -Cc to turn off this check.
-CE {OID}
End the walk at the specified OID, rather than a simple subtree. This can be used to walk a partial
subtree, selected columns of a table, or even two or more tables within a single command.
-Ci Include the given OID in the search range. Normally snmpwalk uses GETNEXT requests starting with the
OID you specified and returns all results in the MIB subtree rooted at that OID. Sometimes, you may
wish to include the OID specified on the command line in the printed results if it is a valid OID in
the tree itself. This option lets you do this explicitly.
-CI In fact, the given OID will be retrieved automatically if the main subtree walk returns no useable val-
ues. This allows a walk of a single instance to behave as generally expected, and return the specified
instance value. This option turns off this final GET request, so a walk of a single instance will
return nothing.
-Cp Upon completion of the walk, print the number of variables found.
-Ct Upon completion of the walk, print the total wall-clock time it took to collect the data (in seconds).
Note that the timer is started just before the beginning of the data request series and stopped just
after it finishes. Most importantly, this means that it does not include snmp library initialization,
shutdown, argument processing, and any other overhead.
In addition to these options, snmpwalk takes the common options described in the snmpcmd(1) manual page.
EXAMPLES
The command:
snmpwalk -Os -c public -v 1 zeus system
will retrieve all of the variables under system:
sysDescr.0 = STRING: "SunOS zeus.net.cmu.edu 4.1.3_U1 1 sun4m"
sysObjectID.0 = OID: enterprises.hp.nm.hpsystem.10.1.1
sysUpTime.0 = Timeticks: (155274552) 17 days, 23:19:05
sysContact.0 = STRING: ""
sysName.0 = STRING: "zeus.net.cmu.edu"
sysLocation.0 = STRING: ""
sysServices.0 = INTEGER: 72
(plus the contents of the sysORTable).
The command:
snmpwalk -Os -c public -v 1 -CE sysORTable zeus system
will retrieve the scalar values, but omit the sysORTable.
SEE ALSO
snmpcmd(1), snmpbulkwalk(1), variables(5).
4th Berkeley Distribution 08 Feb 2002 SNMPWALK(1)
转载于:https://blog.51cto.com/1277594/1110985