Posted on 2009-01-22 07:38:08-08 by buschti
Howto Disable DNS Lookup for Net::SNMP->Session
Hello, I use Net::SNMP to send a SNMP-Trap in a corporate Network. By using
my ($session, $error) = Net::SNMP->session( -hostname => configuration->getWDConfigValue(constants->HOST_IP_ADDRESS), -community => configuration->getCommunity(), -port => configuration->getWDConfigValue(constants->SNMP_PORT), -domain => 'udp' );
Where hostname is a IP-Adress (10.1.10.162)
I get the error: Unable to resolve UDP/IPv4 address '"10.1.10.162"'
There is no real DNS in this network. An nslookup fails also.
I think that during creation of the session a DNS Lookup is done. Is there a possibility to disable this lookup?
any answers are kindly appreciated
kind regards
Timo
Direct Responses: 9784 | Write a response
Posted on 2009-01-22 13:02:25-08 by dtown in response to 9782
Re: Howto Disable DNS Lookup for Net::SNMP->Session
The Net::SNMP module calls the inet_aton() from the IO::Socket module. The actual implementation would depend on your OS. In all of the implementations that I have encountered, a dotted decimal IP address passed to the inet_aton() function does not result in a DNS look up. In your code, could you actually try passing the IP address directly as a string to the session constructor (i.e. -hostname => '10.1.10.162')? I am not sure how your "constants" are formed, but this would eliminate on possible problem area.
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.