|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #17400 getting ip for eth0
Submitted: 2002-05-23 20:29 UTC Modified: 2017-11-27 15:20 UTC
Avg. Score:2.9 ± 1.3
Reproduced:3 of 6 (50.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: e at arix dot com Assigned: pollita (profile)
Status: Closed Package: *General Issues
PHP Version: 7.0 OS:
Private report: No CVE-ID: None
 [2002-05-23 20:29 UTC] e at arix dot com
I'd like to request a function to retrieve the IP address(es) of a given network interface... something that would let me:

  $ip = ifaddr("eth0");

maybe even something more general like:

  $info = ifconfig("eth0")

echo $info["HWAddr"], $info["Mask"];
echo $info["RX-packets"], $info["RX-errors"],



Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-24 00:37 UTC]
If you can think of a cross-platform way ... which I doubt.

Just execute /sbin/ifconfig and parse it's output.
 [2002-05-24 02:22 UTC]
reclassify as feature request
 [2013-10-27 11:05 UTC]
-Package: Feature/Change Request +Package: *General Issues
 [2013-10-27 12:42 UTC]
Because _nobody_ should have to wait more than a decade for a decent answer:

Not able to attach patch to bug, will do when systems are fixed ... stupid hackers ...

Who is gonna do windows ??
 [2013-10-27 12:47 UTC]
Oh I forgot to mention, we can provide some of the information you requested in a portable (across posix implementations) way. 

It's not so easy to provide RX/TX counters and status.

Providing proper names and addresses should allow you to write the non-portable stuff for the platform you are targeting, in php ...
 [2013-11-05 08:20 UTC]
-Assigned To: +Assigned To: ab
 [2013-11-05 08:20 UTC]
gonna do the windows part
 [2014-12-30 15:14 UTC]
-PHP Version: 4.2.1 +PHP Version: 7.0
 [2014-12-30 15:14 UTC]
Anatol, any update on this?
 [2014-12-30 16:07 UTC]
Hi Ferenc,

heh, no implementation started, and will not be soon unfortunately. Still too much stuff for master + ongoing bugs for stable branches. Thanks for poking, I'll keep this one in mind (except one took over before).


 [2015-03-12 09:38 UTC]
got something now

Joe, please check the linux part, ported onto the current master.

 [2015-06-17 12:16 UTC]
Anatol, question; Why is this integrated in Zend/ and not in main/ where other network related functionality exists?
 [2015-06-17 21:13 UTC]
So was it in the Joe's original patch, I just extended it with the Windows part. But i'm not sure we should take it - Joe seems to be not interested/busy, so I'm not sure a sufficient testing can be done.

 [2017-01-10 06:32 UTC]
I just forgot about this ... it would be nice if we could implement at least one of these 15 year old feature requests ...

I still think this is valuable, many places in php can actually make use of interface names but we still have no good way to determine them.

@ab can you fixup for master please, and open a clean PR on github ?
 [2017-10-23 00:34 UTC]
-Assigned To: ab +Assigned To: krakjoe
 [2017-10-23 00:34 UTC]
@joe I think the implementation looks just fine, but as I noted earlier it should probably be located in main/ or ext/standard and use the naming convention we already have inherited, like getnetworkinterfaces() or something in the manner
 [2017-11-23 22:50 UTC]
-Assigned To: krakjoe +Assigned To: pollita
 [2017-11-23 22:50 UTC]
With permission from joe and anatol, I've adopted their diff and merged it with my own and produced:

Planning to merge it to 7.3 soon, unless internals@ has objections.
 [2017-11-27 15:20 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 01 12:01:29 2024 UTC