|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-10-10 14:39 UTC] estesp at fastmail dot us
Description:
------------
The snmp interface code in php5 does not properly support IPv6 addresses for the hostname. Since net-snmp 5.x the SNMP daemon can be listening on udp6 port and therefore, the hostname passed could be a valid IPv6 address.
However, the code in the snmp extension has:
if ((pptr = strchr (hostname, ':'))) {
remote_port = strtol (pptr + 1, NULL, 0);
}
So, instead of defaulting to the usual (default) snmp port, given an IPv6 address, it is taking everything past the first colon as the port number.. which, I believe is going to give a very interesting port number for most IPv6 addresses :)
Reproduce code:
---------------
Just call snmpget() with an IPv6 IP address.. you will get a host not found, or similar:
$host = '0000:0000:0000:0000:0000:0000:0000:0001';
$community = 'public';
$sysName = snmpget($host, $community, "system.sysName.0");
print "$sysName
Expected result:
----------------
snmpget() should work for IPv6 addresses given you have a net-snmp version with IPv6 support and have snmpd listening on an IPv6 transport.
Actual result:
--------------
PHP Warning: snmpget(): Could not open snmp connection: Unknown host
(0000:0000:0000:0000:0000:0000:0000:0001) in /my_ipv6_php on line 4
There may be other issues here as "unknown host" sounds like a getaddrinfo problem, but since doing an snmpget on the server in Ipv6 mode outside of php5 works, I have to bet that something in the snmp interface in php5 is broken with respect to IPv6.
Patchesphp_bug42918.diff (last revision 2011-08-21 23:35 UTC by ch@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 18:00:01 2025 UTC |
Ping! This is 2011 and IPv6 spreading! Fixing this issue shouldn't be very hard as the underlying Net_SNMP library already supports IPv6: $ snmpwalk -v 2c -c public 'udp6:[::1]' sysname SNMPv2-MIB::sysName.0 = STRING: james $ snmpwalk -v 2c -c public 'udp6:::1' sysname SNMPv2-MIB::sysName.0 = STRING: james For testing the following hast to be put into /etc/snmp/snmpd.conf: agentAddress udp:127.0.0.1:161,udp6:[::1]:161 rwcommunity6 private ::1 rocommunity6 public ::1 Currently PHP still gives the following error: $ ~/workspace/php-src-5.4/sapi/cli/php -r 'echo snmpget("::1", "private", "IF-MIB::ifAlias.1");' Warning: snmpget(): Could not open snmp connection: Unknown host (::1) (Illegal seek) in Command line code on line 1 Different formats like "[::1]:161" or "::1:161" make no difference.