Req #42918 [Com]: IPv6 addresses not supported in SNMP extension
| From: | ch@php.net | Date: | Fri, 29 Jul 2011 01:17:55 +0000 |
| Subject: | Req #42918 [Com]: IPv6 addresses not supported in SNMP extension | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-162252@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=42918&edit=1
ID: 42918
Comment by: ch@php.net
Reported by: estesp at fastmail dot us
Summary: IPv6 addresses not supported in SNMP extension
Status: Open
Type: Feature/Change Request
Package: SNMP related
Operating System: Linux
PHP Version: 5CVS-2007-10-10 (snap)
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2010-04-14 14:39:00] j dot ek at gmx dot net
Actually the code mentioned above occurs two times. First time in function "php_snmpv3"
(for SNMPv3) and second in "php_snmp" (for v1 and v2c).
It also seems that some other things should be updated to support IPv6 addresses, e.g. not only
support IpAddress SMIv2 Base Type but also the more generic address schema described in RFC3291. On
the other hand I cannot say whether the net-snmp library already does support this, but as they
claim to be fully IPv6 compatible, it's worth a try.
------------------------------------------------------------------------
[2007-10-10 14:39:20] 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.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=42918&edit=1