1

我无法从我的设备本身设置甚至获取 SNMP 值,但我可以从远程位置。

这是我的 snmpd.conf 文件。如您所见,仅在本次测试中,我有两个社区我授予了完全访问权限。(之后我会将我的公共社区改为只读,别担心)

com2sec rw default public
com2sec rw localhost private
group public v1 rw
group public v2c rw
group public usm rw
group private v1 rw
group private v2c rw
group private usm rw
view all included .1
access public "" any noauth exact all all all
access private "" any noauth exact all all all

在这里,我可以从远程位置设置和获取我的 SNMP 值。

$ snmpget -v2c -c public x.x.x.x SNMPv2-MIB::sysName.0
SNMPv2-MIB::sysName.0 = STRING: default
$ snmpset -v2c -c public x.x.x.x SNMPv2-MIB::sysName.0 s "TEST_TEST"
SNMPv2-MIB::sysName.0 = STRING: TEST_TEST
$ snmpget -v2c -c public x.x.x.x SNMPv2-MIB::sysName.0
SNMPv2-MIB::sysName.0 = STRING: TEST_TEST
$

现在,当我从设备本身尝试时……这就是我得到的。我不能 snmpwalk 它或任何东西。为什么?

$ snmpget -v2c -c private localhost SNMPv2-MIB::sysName.0
Cannot find module (SNMP-VIEW-BASED-ACM-MIB): At line 0 in (none)
Cannot find module (SNMP-COMMUNITY-MIB): At line 0 in (none)
Cannot find module (SNMP-FRAMEWORK-MIB): At line 0 in (none)
Cannot find module (SNMP-MPD-MIB): At line 0 in (none)
Cannot find module (SNMP-USER-BASED-SM-MIB): At line 0 in (none)
Cannot find module (TUNNEL-MIB): At line 0 in (none)
Cannot find module (IPV6-FLOW-LABEL-MIB): At line 0 in (none)
Cannot find module (UCD-DLMOD-MIB): At line 0 in (none)
Cannot find module (IP-MIB): At line 0 in (none)
Cannot find module (IF-MIB): At line 0 in (none)
Cannot find module (TCP-MIB): At line 0 in (none)
Cannot find module (UDP-MIB): At line 0 in (none)
Cannot find module (HOST-RESOURCES-MIB): At line 0 in (none)
Cannot find module (SNMPv2-MIB): At line 0 in (none)
Cannot find module (SNMPv2-SMI): At line 0 in (none)
Cannot find module (NOTIFICATION-LOG-MIB): At line 0 in (none)
Cannot find module (DISMAN-EVENT-MIB): At line 0 in (none)
Cannot find module (DISMAN-SCHEDULE-MIB): At line 0 in (none)
getaddrinfo: localhost Name or service not known
snmpget: Unknown host (localhost) (No such file or directory)

我希望能够从我的设备中更改一些值,以便我可以 snmpwalk 它并获取这些值。感谢所有帮助!

4

2 回答 2

0

运行您的 snmpwalk / snmpget 命令的机器似乎没有它需要的所有 MIB。或者也许不知道他们在哪里。

无论如何,我在 Docker 容器中的 Ubuntu 12 机器上遇到了类似的错误。使用“apt-get install snmp-mibs-downloader”修复,但该软件包仅在您将其添加到 /etc/apt/sources.list 时可用(不要忘记“apt-get update”):

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://us.archive.ubuntu.com/ubuntu/ precise multiverse" >>  /etc/apt/sources.list
deb-src http://us.archive.ubuntu.com/ubuntu/ precise multiverse" >>  /etc/apt/sources.list
deb http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse" >>  /etc/apt/sources.list
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates multiverse" >>  /etc/apt/sources.list
于 2014-02-28T05:45:29.460 回答
0

显然localhost无法正确解决,

getaddrinfo: localhost Name or service not known

您尝试127.0.0.1了 IP v4 还是::1IP v6?

于 2013-10-26T01:58:05.813 回答