我无法设置甚至从设备本身获取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
$
现在当我从设备本身尝试时...这就是我得到的。我不能偷偷摸摸地或任何东西。为什么呢?
$ 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)
我希望能够从我的设备中更改某些值,以便我可以轻松地获取它并获取值。感谢所有帮助!
答案 0 :(得分:0)
显然localhost
无法正确解析,
getaddrinfo: localhost Name or service not known
您是否针对IP v4尝试127.0.0.1
,或针对IP v6尝试::1
?
答案 1 :(得分:0)
运行snmpwalk / snmpget命令的计算机似乎没有所需的所有MIB。或者也许不知道他们在哪里。
无论如何,我在Ubuntu 12机器上的docker容器中遇到了类似的错误。修复了“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