LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   HOWTO: Make "Wake on LAN" (WOL) Work (https://www.linuxquestions.org/questions/linux-networking-3/howto-make-wake-on-lan-wol-work-712283/)

tredegar 03-17-2009 11:18 AM

HOWTO: Make "Wake on LAN" (WOL) Work
 
The following steps work for the 'buntus (tested on kubuntu 8.04) and probably all debian derived distros, mandriva et al have a different way of setting up networking, but I expect the same principles can be made to apply.

I have followed many HOWTOs to get WOL working. They didn't work.
I have even posted to a few threads here on LQ about the problem. No joy.

Some sites advised editing the /etc/init.d/halt script to remove the -i option when halt is finally called. This should work, but didn't, so I left that file alone.
Some sites advise running ethtool -s eth0 wol g as a startup script. That didn't work either.

The problem is that when linux shuts down, it completely powers off the LAN card. This saves a small amount of electricity, but the card is now truly OFF so it can no longer listen for the "Magic Packet" that is supposed to wake it up and make the computer boot.

Today I found a solution that works for me:

- I am assuming that eth0 is your LAN connection.
- You need the following utilities to be installed: ethtool and wakeonlan
- You need to know the MAC address of the LAN card in the PC you want to wake up. You can find the MAC address like this:
ifconfig eth0 | grep HW
- You may need to check that WOL is enabled in that PCs BIOS
- You need to check that that LAN card supports WOL (not all do) with
ethtool eth0

You'll need to be root to make these changes:
Create a very small script called activateWOL
It looks like this
Code:

#!/bin/bash
ethtool -s eth0 wol g

make it executable and move it into /usr/bin/
Now add a line to the /etc/network/interfaces file, in the part relevant to eth0 to call that script, like this
Code:

auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0

auto eth0
iface eth0 inet static
address 10.0.0.4
netmask 255.255.255.0
gateway 10.0.0.2
post-down /usr/bin/activateWOL

Restart networking to make sure this change is noticed:
/etc/init.d/networking restart

What this does is re-enable the WOL capability of the card after it has been shut down. It seems stupid to have to have a script with only one command in it, but when I tried just putting post-down ethtool -s eth0 wol g in the interfaces file, it didn't work.

When the PC has shut down and has kept WOL activated, I notice a little green light by the ethernet connector, even though the PC is "powered off".

Now you can now wake that pc from another PC on your LAN with the command
wakeonlan macaddress like this
Code:

wakeonlan 00:11:2E:A0:0B:55
With a bit of port-forwarding, I can now wake up, and shut down my home server from anywhere connected to the internet. Linux is awesome sometimes.

salasi 03-17-2009 05:16 PM

That's brilliant! It happens that just this morning, I was idly wondering what I would do if I wanted to make wol work...and then thought no more about it.

Should this be a 'how to'?

matnik 05-29-2009 11:20 AM

CentOS WOL
 
Thanks for the tip.
One variation if you use CentOS (at least in 4.6) :
-to enable wol you need to add execution of /usr/bin/activateWOL in /etc/sysconfig/network-scripts/ifup-post (I put it at the end of my ifup-post files before the exit 0 statement)
-to restart network do : /etc/init.d/network restart or reboot -n

you can check your settings with /sbin/ethtool eth0
Regards
Matnik

sipu123 07-14-2009 05:56 AM

hello i have applied these changes and WOL is working fine when i used it to wake my machine from turn off mode....

But it is not working when i switches my machine to sleep mode. My machine is not responding to magic packet sent , if it is in sleep mode. Also this all happens with ubuntu only .....If i go to sleep mode through Windows 7 ultimate. Then my machine can detect the magic packet and resume all the state of machine as earlier.

Can WOL for sleep/suspend/hibernate is possible in ubuntu......if yes do we require some more changes and what are those changes required.

please reply.

psvogelaar 08-30-2009 01:36 PM

Quote:

Originally Posted by matnik (Post 3556705)
Thanks for the tip.
One variation if you use CentOS (at least in 4.6) :
-to enable wol you need to add execution of /usr/bin/activateWOL in /etc/sysconfig/network-scripts/ifup-post (I put it at the end of my ifup-post files before the exit 0 statement)
-to restart network do : /etc/init.d/network restart or reboot -n

you can check your settings with /sbin/ethtool eth0
Regards
Matnik

I have all my bios settings correct and with Ubuntu Server 9.04 WOL was working a few weeks ago. Recently I installed CentOS 5.3, but now I can't get WOL to work. I added activateWOL and did the same as matnik, but when I do "shutdown -h now", I still see that the eth0 interface is shutting down.

Anyone suggestions??

Greetings,
Pieter

geekoutjoe 04-01-2010 11:20 PM

Thanks!
 
I had to join this forum to thank you for this post! I have tried for a little bit and after following a few different threads I found your solution that works.

Has anyone had any success making WOL work with suspend?

kheldar 02-26-2011 07:23 AM

Quote:

Originally Posted by matnik (Post 3556705)
Thanks for the tip.
One variation if you use CentOS (at least in 4.6) :
-to enable wol you need to add execution of /usr/bin/activateWOL in /etc/sysconfig/network-scripts/ifup-post (I put it at the end of my ifup-post files before the exit 0 statement)
-to restart network do : /etc/init.d/network restart or reboot -n

you can check your settings with /sbin/ethtool eth0
Regards
Matnik

On Centos5.3, this didn't work for me, but when I also put the actiateWOL command at the same point in ifdown-post, it did work. Wehey!


All times are GMT -5. The time now is 02:43 AM.