Using pySnmp 4.4.12
, I can successfully send v3
traps, but it seems impossible to change the source address (see below code), as it can be done for v1
use case (by adding a further specific var bind).
Any ideas?
Thank you for your kind help
Code:
from pysnmp.hlapi import *
errorIndication, errorStatus, errorIndex, varBinds = next(
sendNotification(
SnmpEngine(),
CommunityData('public'),
UdpTransportTarget(('demo.pysnmp.com', 162)),
ContextData(),
'trap',
NotificationType(
ObjectIdentity('1.3.6.1.4.1.20408.4.1.1.2.0.432'),
).addVarBinds(
# agent uptime
('1.3.6.1.2.1.1.3.0', 12345),
# agent address
('1.3.6.1.6.3.18.1.3.0', '127.0.0.1'),
# enterprise OID
('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'),
# user variable-bindings may follow
)
)
)
I have the same issue !! :(
In the context of sending SNMP v3 traps with PySNMP 4.4.12, changing the source address directly within the library might not be supported as it is for SNMP v1. SNMP v3, being a more secure version of SNMP, may have different considerations for source address handling.
If the PySNMP library does not provide a direct method to set the source IP address for SNMP v3 traps, you may need to rely on the operating system or network configurations to control the source address.