[AGENT++] Changing the source IP (agent-addr) of the Traps. (Newbie)
Jochen Katz
katz at agentpp.com
Wed Sep 28 20:45:12 CEST 2011
Hi,
> I notice that the trap I've set up has agent-addr set as the localhost
> Ip (127.0.0.1).
> I'd like to change that to the proper IP, also because my device has
> multiple interfaces.
as the mib entries for a v1 trap don't allow to set the agent address,
it is not set in the pdu by agent++. snmp++ then tries to set it to the
IP for the host name returned by gethostname() function. Obviously this
name resolves to 127.0.0.1.
As a short term solution, you can patch the
NotificationOriginator::send_notify() function to call
pdu.set_v1_trap_address() right below the line "if (mpModel == mpV1) {".
I can think of two possible enhancements:
1) provide a static conversion table that maps IP ranges to agent
addresses to NotifiactionOriginator. This could look like
192.168.0.0/16 --> 192.168.0.1
10.0.0.0/24 --> 10.0.0.254
10.0.1.0/24 --> 10.0.1.1
0.0.0.0/0 --> 10.4.4.4 (default)
2) Add some code that tries to find out with which source IP the trap
will be sent and use this IP as agent address.
Regards,
Jochen
More information about the AGENTPP
mailing list