没有来自Ubuntu 14.04 LTS服务器客户端机器的SNMP查询响应

好吧,我有两个虚拟机都在ESXi下运行。 一台VM正在托pipeObservium,它使用SNMP来获取其信息。 我直接在我的ESXi主机上指出了Observium,它运行良好,所以Observium没有问题。 尝试使用正确的设置添加设备(尝试过SNMP v1v2cv3 ),服务器始终没有响应。

在这种情况下,服务器的主机名是cal ,客户端的主机名是default ,只是为了说明。

我发送SNMP请求的客户端是全新安装的Ubuntu Server 14.04 LTS。 我所做的只是安装snmpd软件包,并对其进行configuration。

这是我的/etc/snmp/snmpd.conf

 com2sec readonly default taylor group MyROGroup v1 readonly group MyROGroup v2c readonly group MyROGroup usm readonly view all included .1 80 access MyROGroup “” any noauth exact all none none syslocation “San Francisco, CA” syscontact [email protected] 

据我的理解,在社区名称(即taylor )之前放置default意味着它将接受来自任何IP的SNMP请求。

和我的/etc/default/snmpd

 export MIBS= SNMPDRUN=yes SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf' TRAPDRUN=no TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid' 

所以我认为我已经configuration好了,我发出一个snmpwalk来testing:

 taylor@cal:~$ snmpwalk -v 2c -c taylor default Timeout: No Response from default 

我可以ping得很好:

 taylor@cal:~$ ping default PING default.mywebsite.com (192.168.1.130) 56(84) bytes of data. 64 bytes from default.mywebsite.com (192.168.1.130): icmp_seq=1 ttl=64 time=0.350 ms 64 bytes from default.mywebsite.com (192.168.1.130): icmp_seq=2 ttl=64 time=0.235 ms 64 bytes from default.mywebsite.com (192.168.1.130): icmp_seq=3 ttl=64 time=0.192 ms taylor@default:~$ ping cal PING cal.taylorjthurlow.com (192.168.1.112) 56(84) bytes of data. 64 bytes from cal.taylorjthurlow.com (192.168.1.112): icmp_seq=1 ttl=64 time=0.306 ms 64 bytes from cal.taylorjthurlow.com (192.168.1.112): icmp_seq=2 ttl=64 time=0.188 ms 64 bytes from cal.taylorjthurlow.com (192.168.1.112): icmp_seq=3 ttl=64 time=0.264 ms 

为了确保我们有stream量,我在发送端和接收端都发送一个tcpdump

发送(SNMP服务器):

 02:22:51.569041 IP cal.mywebsite.com.42979 > default.mywebsite.com.snmp: C=taylor GetNextRequest(25) 02:22:52.569547 IP cal.mywebsite.com.42979 > default.mywebsite.com.snmp: C=taylor GetNextRequest(25) 02:22:53.570659 IP cal.mywebsite.com.42979 > default.mywebsite.com.snmp: C=taylor GetNextRequest(25) 02:22:54.571775 IP cal.mywebsite.com.42979 > default.mywebsite.com.snmp: C=taylor GetNextRequest(25) 02:22:55.572715 IP cal.mywebsite.com.42979 > default.mywebsite.com.snmp: C=taylor GetNextRequest(25) 02:22:56.573874 IP cal.mywebsite.com.42979 > default.mywebsite.com.snmp: C=taylor GetNextRequest(25) 

接收(SNMPD客户端):

 02:22:51.858750 IP cal.mywebsite.com.42979 > default.mywebsite.com.snmp: C=taylor GetNextRequest(25) 02:22:52.859290 IP cal.mywebsite.com.42979 > default.mywebsite.com.snmp: C=taylor GetNextRequest(25) 02:22:53.860371 IP cal.mywebsite.com.42979 > default.mywebsite.com.snmp: C=taylor GetNextRequest(25) 02:22:54.861495 IP cal.mywebsite.com.42979 > default.mywebsite.com.snmp: C=taylor GetNextRequest(25) 02:22:55.862424 IP cal.mywebsite.com.42979 > default.mywebsite.com.snmp: C=taylor GetNextRequest(25) 02:22:56.863590 IP cal.mywebsite.com.42979 > default.mywebsite.com.snmp: C=taylor GetNextRequest(25) 

所以,基本上是一样的东西,只是稍微不同的时间戳。 有关的事情是没有响应数据包被发送。 好吧,也许有防火墙或端口问题。

我禁用ufw disable Ubuntu的Uncomplicated Firewall ,并确认它没有以ufw status运行。

然后我检查了我的iptables ,它们是从新安装中清空的。 我在SNMPD客户端添加了端口161的传入和传出规则。

 taylor@default:~$ sudo iptables -nL Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:161 Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:161 

仍然有同样的问题。 SuperUser或ServerFault上的另一篇文章解决了同样的问题,因为他们的/etc/hosts.allowiptables阻止了stream量。 这是我的:

 taylor@default:~$ cat /etc/hosts.allow # /etc/hosts.allow: list of hosts that are allowed to access the system. # See the manual pages hosts_access(5) and hosts_options(5). # # Example: ALL: LOCAL @some_netgroup # ALL: .foobar.edu EXCEPT terminalserver.foobar.edu # # If you're going to protect the portmapper use the name "rpcbind" for the # daemon name. See rpcbind(8) and rpc.mountd(8) for further information. taylor@default:~$ cat /etc/hosts.deny # /etc/hosts.deny: list of hosts that are _not_ allowed to access the system. # See the manual pages hosts_access(5) and hosts_options(5). # # Example: ALL: some.host.name, .some.domain # ALL EXCEPT in.fingerd: other.host.name, .other.domain # # If you're going to protect the portmapper use the name "rpcbind" for the # daemon name. See rpcbind(8) and rpc.mountd(8) for further information. # # The PARANOID wildcard matches any host whose name does not match its # address. # # You may wish to enable this to ensure any programs that don't # validate looked up hostnames still leave understandable logs. In past # versions of Debian this has been the default. # ALL: PARANOID 

在这一点上我没有任何想法。 任何build议,我可以尝试让这个东西实际回复我的SNMP查询?


编辑:这是我的客户端上的/var/log/syslog

 Dec 9 01:48:24 default snmpd[2888]: NET-SNMP version 5.7.2 Dec 9 01:48:27 default snmpd[2888]: Connection from UDP: [192.168.1.112]:41109->[192.168.1.130]:161 Dec 9 01:50:54 default kernel: [ 8359.253571] nf_conntrack version 0.5.0 (7951 buckets, 31804 max) Dec 9 01:48:32 default snmpd[2888]: message repeated 5 times: [ Connection from UDP: [192.168.1.112]:41109->[192.168.1.130]:161] Dec 9 01:52:53 default snmpd[2888]: Connection from UDP: [192.168.1.112]:40482->[192.168.1.130]:161 Dec 9 01:54:05 default kernel: [ 8550.718971] ip6_tables: (C) 2000-2006 Netfilter Core Team Dec 9 01:52:58 default snmpd[2888]: message repeated 5 times: [ Connection from UDP: [192.168.1.112]:40482->[192.168.1.130]:161] Dec 9 01:54:11 default snmpd[2888]: Connection from UDP: [192.168.1.112]:59617->[192.168.1.130]:161 Dec 9 01:54:16 default snmpd[2888]: message repeated 5 times: [ Connection from UDP: [192.168.1.112]:59617->[192.168.1.130]:161] Dec 9 01:56:43 default snmpd[2888]: Received TERM or STOP signal... shutting down... Dec 9 01:56:45 default snmpd[3165]: NET-SNMP version 5.7.2 Dec 9 02:00:06 default snmpd[3165]: Received TERM or STOP signal... shutting down... Dec 9 02:00:08 default snmpd[3216]: NET-SNMP version 5.7.2 Dec 9 02:00:18 default snmpd[3216]: Connection from UDP: [192.168.1.112]:45692->[192.168.1.130]:161 Dec 9 02:00:23 default snmpd[3216]: message repeated 5 times: [ Connection from UDP: [192.168.1.112]:45692->[192.168.1.130]:161] Dec 9 02:02:36 default snmpd[3216]: Received TERM or STOP signal... shutting down... Dec 9 02:02:38 default snmpd[3242]: Error opening specified endpoint "udp:161" Dec 9 02:02:38 default snmpd[3242]: Server Exiting with code 1 Dec 9 02:07:16 default snmpd[3281]: duplicate registration: MIB modules pass and pass (oid .1.3.6.1.4.1.4413.4.1). Dec 9 02:07:16 default snmpd[3281]: Error opening specified endpoint "udp:161" Dec 9 02:07:16 default snmpd[3281]: Server Exiting with code 1 Dec 9 02:17:01 default CRON[3283]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Dec 9 02:23:55 default kernel: [10340.925233] device eth0 left promiscuous mode 

看起来有一些是因为我看包,然后有一些提到Error opening specified endpoint "udp:161"但它们是零星的。 可能是一些东西。

编辑:这实际上是由于我尝试agentAddress udp:161,udp6:[::1]:161 。 日志只是零星地说,因为我是启用和禁用该行。 所以,回到原点。

我不确定为什么这个工作,但我似乎已经解决了我的问题。 在我的/etc/snmp/snmpd.conf ,我replace了这一行:

 com2sec readonly default taylor 

 rocommunity taylor 

一切都很好

从您的日志中,SNMP守护进程无法绑定到端口161,然后退出:

 Dec 9 02:07:16 default snmpd[3281]: Error opening specified endpoint "udp:161" Dec 9 02:07:16 default snmpd[3281]: Server Exiting with code 1 

所以你没有得到任何答复的原因是snmpd实际上并没有在运行。

如果出现语法问题,您可以尝试注释agentAddress行,但也可能是其他事件绑定到UDP端口161的情况。请检查netstat -lnp | grep :161 netstat -lnp | grep :161这将显示你绑定到那个端口的东西。