Playing with Wake-On-Lan (WOL)

Pre-req:
+ Must have php5 with –enable-sockets

What is a magic packet?
It’s a udp packet sent through the broadcast address to all servers on the network (ie, all servers serviced by the broadcast address). It’s called magic, because the format of the message is so strange. A mac address looks like this, 00:30:1B:BA:FA:47, it’s a series of 6 hexidecimal numbers. The magic packet message is a 6 char header, then the mac address, converted to a character sequence, repeated 16 times.

Read morePlaying with Wake-On-Lan (WOL)

Net_IPv4 Coolness

Available from the PEAR website, http://pear.php.net/package/Net_IPv4, the Net_IPv4 package is pretty cool. Check this out:

<?php
require_once(“IPv4.php”);
$ip = $argv[1];
$netmask = $argv[2];

$ip_calc = new Net_IPv4();
$ip_calc->ip = $ip;
$ip_calc->netmask = $netmask;
$ip_calc->calculate();
$ip_calc->min = $ip_calc->network;
$ip_calc->max = $ip_calc->broadcast;
$ip_calc->min_long = $ip_calc->ip2double($ip_calc->network);
$ip_calc->max_long = $ip_calc->ip2double($ip_calc->broadcast);
$ip_calc->gateway = long2ip($ip_calc->max_long-1);

print_r($ip_calc);
?>

Read moreNet_IPv4 Coolness