snmpd.conf clientaddr not working for sending trap /inform with given IP source address

回眸只為那壹抹淺笑 提交于 2019-12-08 11:13:25

问题


Given the following sample/simple snmpd.conf (Net-SNMP 5.7.2 on RHEL 7.4)

rwcommunity private 192.168.56.101

trapsess -Ci --clientaddr=192.168.56.128 -v 2c -c private 192.168.56.101:162

when starting a SNMP Daemon

snmpd -f -Lo -D -C -c data/snmpd_test.conf udp:192.168.56.128:161

We obtain ''Start Up'' InformRequest with IP source 192.56.168.1 instead of ...128 (WireShark snapshot below)

It is not surprising as the -D option allows us to output the debug information saying that

trace: netsnmp_config_process_memory_list(): read_config.c, 696: read_config:mem: processing memory: clientaddr 192.168.56.128 trace: run_config_handler(): read_config.c, 562: 9:read_config:parser: clientaddr handler not registered for this time

Web sources however say:

snmp.conf

...This value is also used by snmpd when generating notifications.

snmpd.conf

trapsess [SNMPCMD_ARGS] HOST provides a more generic mechanism for defining notification destinations. SNMPCMD_ARGS should be the command-line options required for an equivalent snmptrap (or snmpinform) command to send the desired notification

I read also some old threads like this one

  • However this option is working well with snmptrap

    snmptrap -D -Lo -Ci --clientaddr=192.168.56.128 -M+path_to_my_mibs -v 2c -c private 192.168.56.101:162 "" .1.3.6.1.4.1.a.b.c.d.e.f.0 i 0

  • This option is also working when placed in snmp.conf ( mind there is no 'd' here ) and then it applies to snmpset and snmpget (and maybe other)

So my question is: Is it a documentation error, a bug, a misuse of the Net-SNMP stack ?


回答1:


After a long struggle I may have an answer and I write a short note as I just found a trick

It seems that clientaddr is not parsed correctly wherever in the snmpd.conf

(I tried not also inside the trapsess line)

But it seems to be a valid option in the command line of snmpd

like it was a valid option in the snmptrap command line. So I assumed it could be the same parsing mechanism for both.

a condition also is that the IP addres must be valid one

which means that

snmpd -f -Lo -D -C -c data/snmpd_test.conf --clientaddr=192.168.56.128 udp:192.168.56.128:161

seems to fully solve my problem.

I will perform more tests and if accurate format this answer a little bit better but it seems a good hint.



来源:https://stackoverflow.com/questions/53767608/snmpd-conf-clientaddr-not-working-for-sending-trap-inform-with-given-ip-source

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!