OneWhoKnocks
OneWhoKnocks

Reputation: 91

Unable to create snmpv3 session and send snmpv3 trap

1. Not able to create SNMPv3 session

I am using NET::SNMP perl library to send snmpv3 trap.It was working fine with snmpv1 and snmpv2 but i am unable to send snmpv3 trap. I am using Mg-soft trap ringer for receiving traps but i am unable to even create a session.

Code for snmpv3 session creation:

my ($session, $error) = Net::SNMP->session( 
-hostname     => 'my_host_name', 
-version     => '3',
-username     => 'user-md5',
-authprotocol => 'md5',
-authpassword => 'abcd1234'
);

Here the username is the security user name added in Mg-soft trap ringer. Why am i not able to create session.Or please suggest me how can i receive snmpv3 trap sent through NET::SNMP library.

2. Not able to send SNMPv3 trap

I am able to create session for snmpv3 with some trap receiver snmp server configuration i found somewhere. But while sending trap using NET::SNMP library i am getting following error:

Must be an authoritative SNMP engine to generate a SNMPv2-Trap-PDUdf

Here is the code snippet i used:

my $OID_sysContact = '1.5.2.9.4.6.6.5.4';
my $result = $session->snmpv2_trap(
-varbindlist => [ $OID_sysContact, OCTET_STRING, 'Help Desk x911' ],
);

Please suggest me why am i getting this error.

Upvotes: 1

Views: 1161

Answers (1)

Bala Krishnan
Bala Krishnan

Reputation: 374

I see a few missing fields from your snippet as far SNMPv3 is concerned.

I doubt why Net::SNMP does not have the security level field for v3 connections. There are three levels of security - noAuthnoPriv , authNoPriv and authPriv. Based on the these levels, an SNMPv3 connection request can be formed.

Firstly, in your connection request, you only have authentication related information and nothing about the privacy protocol/privacy key. Second, I suggest you to use version value as snmpv3 instead of just 3.

For the trap part, it seems like the sender must be an authoritative SNMP engine - not yet supported by Net::SNMP module. Quoted below from Net::SNMP

snmpv2_trap() - send a SNMP snmpV2-trap to the remote manager
NOTE: This method can only be used when the version of the object is set to SNMPv2c. SNMPv2-Trap-PDUs are supported by SNMPv3, but require the sender of the message to be an authoritative SNMP engine which is not currently supported by the Net::SNMP module.

Upvotes: 0

Related Questions