phpubuntu-12.04snmpnet-snmpip-fragmentation

PHP SNMP v2 Walk Fragmenting/Blocked


How do I set the maximum message size when using snmp v2 in PHP?

I am using PHP to do an SNMP walk of devices, and my organization has very stringent firewalls in place. I am running into an issue where (snmp2_real_walk, or snmp2_walk) are resulting in timeouts from my production server if the packets are larger and getting fragmented. I'm wondering if there is a way to set the maximum packet size to something smaller to prevent fragmentation.

I am using php 5.4.10 on Ubuntu 12.04, and Net-SNMP 5.4.3.

When I capture the traffic, it turns out the snmp2_real_walk is using getBulkRequest. I get a response that is saying the packet is fragmented, and a smaller follow up packet. On my local machine, same environment aside from firewall, this works. On my production machine, it's failing.

var_dump(snmp2_real_walk("a.b.c.d", "public", '.o.i.d'));

If I call it via command line, it works with smaller packets. I don't understand why. There has to be a way to set the packet/message size, right?

snmpbulkwalk -v2c -cpublic a.b.c.d .o.i.d

(sensitive data removed).


Solution

  • It doesn't appear there is a way to tell PHP to request a custom max-repetitions setting. Also, PHP's get next doesn't work too well, as it will continue going through the SNMP tree into the next branch (i.e. if you're traversing .17.x, the last one on 17.z will give you 18.1).

    To get around this issue, I ended up using exec and sanitizing the data to ensure no variables could hijack the system.