note 34797 added to ref.network
| From: | anderson at piq dot com dot br | Date: | Thu, 07 Aug 2003 03:10:03 +0000 |
| Subject: | note 34797 added to ref.network | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-53545@lists.php.net to get a copy of this message | ||
If you want to get the interface of an IP, based on the local route table, use this.
function GetIfaceforIP($user_ip)
{
$route = "/bin/netstat -rn";
exec($route, $aoutput);
foreach($aoutput as $key => $line)
{
if($key > 1)
{
$line = ereg_replace("[[:space:]]+",",",$line);
list($network, $gateway, $mask, $flags, $mss, $window, $irtt, $iface) =
explode(",", $line)
if((ip2long($user_ip) & ip2long($mask)) == ip2long($network))
{
return $iface;
}
}
}
}
----
Manual Page -- http://www.php.net/manual/en/ref.network.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34797
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34797&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34797&report=yes