Reputation: 193
I tested the following code of a SNMP GET command with Python using pysnmp
g = getCmd( SnmpEngine(),
CommunityData( 'escom' ),
UdpTransportTarget( ( 'localhost', 161 ) ),
ContextData(),
ObjectType( ObjectIdentity( 'SNMPv2-MIB', 'sysDescr', 0 ) ) )
next( g )
When I run it with localhost
or 127.0.0.1
, it works, but when I use the IP of the computer, I get a timeout error.
I also tested an example I found with Java (snmp4j) and it's the same: it works with localhost
and 127.0.0.1
but not with the IP. If I make a ping to the IP, it works, so I don't understand why this happens.
I'm using Windows 10 and configured the SNMP agent following this tutorial.
Is there a way to avoid the timeout when I use the IP?
Upvotes: 0
Views: 3480
Reputation: 5555
First thing first -- are you certain that your remote SNMP agent is configured to respond to you? Do you use the same SNMP community name and SNMP version as your remote agent is configured to use?
That may also be a network connectivity problem. Off the top of my head, that can be a firewall rule that drops incoming SNMP packets (e.g. responses) or asymmetrical routing meaning that you originate SNMP packet from one local interface while response comes to another.
To test the second hypotheses you could try querying public SNMP agent at demo.snmplabs.com. If it does not respond to you, that's a sign that you are not getting the response packets.
The other direction you can take is to set up Wireshark at your local machine and see if SNMP traffic (UDP, port 161) is getting back to you.
Upvotes: 4