Hello all!
I am working already for some time on the following goal: I want to wake up other workstations/servers using a PHP-page running on the QNAP TS-809U (Version 3.3.4 build 1019T) Please note: I do NOT want to wake up the Turbonas, but use it to wake other stations.
The target machine is WOL enabled and it works fine to wake it up using other WOL-tools on other workstations.
When trying the well known scripts (e.g. http://stephan.mestrona.net/wol/hilfe.php) nothing happens. Further investigation gave me the intention, that on the QNAP it is not allowed to create IPv4-UDP-sockets and/or to send broadcasts via this socket.
- Is this correct?
- Can this be configured?
- Are there any other solutions for this?
Best regards,
Markus Seifert (MSE)
FSOCKOPEN broadcast fails/was:How to wake OTHER workstations
-
- New here
- Posts: 4
- Joined: Wed Jan 12, 2011 4:49 pm
FSOCKOPEN broadcast fails/was:How to wake OTHER workstations
Last edited by MSE on Thu Jan 13, 2011 5:30 pm, edited 1 time in total.
-
- New here
- Posts: 4
- Joined: Wed Jan 12, 2011 4:49 pm
FSOCKOPEN broadcast fails /was: How to wake OTHER workstatio
Really odd:
fsockopen(udp://10.76.123.6, 7, $errno, $errstr, 4) ==>Error: 0
fsockopen(udp://10.76.255.255, 7, $errno, $errstr, 4) ==>Error: 13 Permission denied
It seems as if only broadcasts are not allowed. Any Hint?
fsockopen(udp://10.76.123.6, 7, $errno, $errstr, 4) ==>Error: 0
fsockopen(udp://10.76.255.255, 7, $errno, $errstr, 4) ==>Error: 13 Permission denied
It seems as if only broadcasts are not allowed. Any Hint?
-
- New here
- Posts: 4
- Joined: Wed Jan 12, 2011 4:49 pm
Re: FSOCKOPEN broadcast fails/was:How to wake OTHER workstat
Alternative does not work:
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP) ===> Error:13:Permission denied
socket_bind($sock,"0.0.0.0",7) ===> Error:13:Permission denied
socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, 1) ===> Error:13:Permission denied
socket_sendto($sock, "Hello", strlen("Hello"), 0, "255.255.255.255", 7) ===> Error:13:Permission denied
socket_close($sock) ===> Error:13:Permission denied
Oddly the "socket_create" gives sometimes when reloading the page Error "116 No route to host" or "22 Invalid argument" ???
Really really odd...
Best regards,
Markus Seifert (MSE)
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP) ===> Error:13:Permission denied
socket_bind($sock,"0.0.0.0",7) ===> Error:13:Permission denied
socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, 1) ===> Error:13:Permission denied
socket_sendto($sock, "Hello", strlen("Hello"), 0, "255.255.255.255", 7) ===> Error:13:Permission denied
socket_close($sock) ===> Error:13:Permission denied
Oddly the "socket_create" gives sometimes when reloading the page Error "116 No route to host" or "22 Invalid argument" ???
Really really odd...
Best regards,
Markus Seifert (MSE)
-
- New here
- Posts: 5
- Joined: Sat May 21, 2011 3:11 am
Re: FSOCKOPEN broadcast fails/was:How to wake OTHER workstat
Has someone found found a solution for this problem?
Or are there any other ideas how to perform a wakeon lan via the web interface?
Or are there any other ideas how to perform a wakeon lan via the web interface?
-
- Guru
- Posts: 12455
- Joined: Sat Dec 29, 2007 1:39 am
- Location: Stockholm, Sweden (UTC+01:00)
Re: FSOCKOPEN broadcast fails/was:How to wake OTHER workstat
I use the feature integrated in DD-WRT for that task.
RAID have never ever been a replacement for backups. Without backups on a different system (preferably placed at another site), you will eventually lose data!
A non-RAID configuration (including RAID 0, which isn't really RAID) with a backup on a separate media protects your data far better than any RAID-volume without backup.
All data storage consists of both the primary storage and the backups. It's your money and your data, spend the storage budget wisely or pay with your data!
A non-RAID configuration (including RAID 0, which isn't really RAID) with a backup on a separate media protects your data far better than any RAID-volume without backup.
All data storage consists of both the primary storage and the backups. It's your money and your data, spend the storage budget wisely or pay with your data!
-
- New here
- Posts: 5
- Joined: Sat May 21, 2011 3:11 am
Re: FSOCKOPEN broadcast fails/was:How to wake OTHER workstat
I found the follwoing script on the official PHP site:
<?php
# Wake on LAN - (c) HotKey (at SPR dot AT), upgraded by Murzik <tomurzik@inbox.ru>
flush();
function WakeOnLan($addr, $mac)
{
$addr_byte = explode(':', $mac);
$hw_addr = '';
for ($a=0; $a < 6; $a++) $hw_addr .= chr(hexdec($addr_byte[$a]));
$msg = chr(255).chr(255).chr(255).chr(255).chr(255).chr(255);
for ($a = 1; $a <= 16; $a++) $msg .= $hw_addr;
// send it to the broadcast address using UDP
// SQL_BROADCAST option isn't help!!
$s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
if ($s == false)
{
echo "Error creating socket!\n";
echo "Error code is '".socket_last_error($s)."' - " . socket_strerror(socket_last_error($s));
}
else
{
// setting a broadcast option to socket:
$opt_ret = socket_set_option($s, 1, 6, TRUE);
if($opt_ret < 0)
{
echo "setsockopt() failed, error: " . strerror($opt_ret) . "\n";
}
$e = socket_sendto($s, $msg, strlen($msg), 0, $addr, 2050);
echo $e;
socket_close($s);
echo "Magic Packet sent (".$e.") to ".$addr.", MAC=".$mac;
}
}
#WakeOnLan('yourIPorDomain.dyndns.org', 'your:MAC:address');
#WakeOnLan('192.168.0.2', '00:30:84:2A:90:42');
#WakeOnLan('192.168.1.2', '00:05:1C:10:04:05');
//if you have switch or other routing devices in LAN, sendign to
// the local IP isn't helps! you need send to the broadcast address like this:
WakeOnLan('192.168.0.255', 'xx:xx:xx:xx:xx:xx');
?>
It works perfect. The point is that by default broadcasts are disabled for sockeds. The socket_set_option command enables broadcast messages.
So have fun with it.
<?php
# Wake on LAN - (c) HotKey (at SPR dot AT), upgraded by Murzik <tomurzik@inbox.ru>
flush();
function WakeOnLan($addr, $mac)
{
$addr_byte = explode(':', $mac);
$hw_addr = '';
for ($a=0; $a < 6; $a++) $hw_addr .= chr(hexdec($addr_byte[$a]));
$msg = chr(255).chr(255).chr(255).chr(255).chr(255).chr(255);
for ($a = 1; $a <= 16; $a++) $msg .= $hw_addr;
// send it to the broadcast address using UDP
// SQL_BROADCAST option isn't help!!
$s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
if ($s == false)
{
echo "Error creating socket!\n";
echo "Error code is '".socket_last_error($s)."' - " . socket_strerror(socket_last_error($s));
}
else
{
// setting a broadcast option to socket:
$opt_ret = socket_set_option($s, 1, 6, TRUE);
if($opt_ret < 0)
{
echo "setsockopt() failed, error: " . strerror($opt_ret) . "\n";
}
$e = socket_sendto($s, $msg, strlen($msg), 0, $addr, 2050);
echo $e;
socket_close($s);
echo "Magic Packet sent (".$e.") to ".$addr.", MAC=".$mac;
}
}
#WakeOnLan('yourIPorDomain.dyndns.org', 'your:MAC:address');
#WakeOnLan('192.168.0.2', '00:30:84:2A:90:42');
#WakeOnLan('192.168.1.2', '00:05:1C:10:04:05');
//if you have switch or other routing devices in LAN, sendign to
// the local IP isn't helps! you need send to the broadcast address like this:
WakeOnLan('192.168.0.255', 'xx:xx:xx:xx:xx:xx');
?>
It works perfect. The point is that by default broadcasts are disabled for sockeds. The socket_set_option command enables broadcast messages.
So have fun with it.
-
- Starting out
- Posts: 26
- Joined: Fri Jan 20, 2012 3:19 pm
Re: FSOCKOPEN broadcast fails/was:How to wake OTHER workstat
Installing Python from optware and doing it with Python? Long shot, but I figure maybe someone on the Internet will find this thread like I did...
wol.py
Where the MAC is E2:33:95:C3:FF:E4.
wol.py
Code: Select all
import socket
s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
s.sendto('\xff'*6+'\xe2\x33\x95\xc3\xff\xe4'*16, ('<broadcast>',9))
Where the MAC is E2:33:95:C3:FF:E4.