LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-17-2009, 11:18 AM   #1
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
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.
 
Old 03-17-2009, 05:16 PM   #2
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
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'?
 
Old 05-29-2009, 11:20 AM   #3
matnik
LQ Newbie
 
Registered: May 2009
Posts: 1

Rep: Reputation: 1
Smile 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
 
1 members found this post helpful.
Old 07-14-2009, 05:56 AM   #4
sipu123
LQ Newbie
 
Registered: Jul 2009
Posts: 4

Rep: Reputation: 0
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.
 
Old 08-30-2009, 01:36 PM   #5
psvogelaar
LQ Newbie
 
Registered: Aug 2009
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by matnik View Post
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
 
Old 04-01-2010, 11:20 PM   #6
geekoutjoe
LQ Newbie
 
Registered: Apr 2010
Posts: 1

Rep: Reputation: 0
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?
 
Old 02-26-2011, 07:23 AM   #7
kheldar
Member
 
Registered: Jul 2004
Location: Nottingham, England
Distribution: Fedora 17, Centos 6.3 x86_64
Posts: 35

Rep: Reputation: 2
Thumbs up

Quote:
Originally Posted by matnik View Post
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Wol (wake On Lan ) Problem sniffer_raghav Linux - Networking 0 06-02-2008 01:44 PM
ethtool can't seem to enable wake-on-LAN (wol) on my NIC bellsal Linux - Newbie 4 10-28-2007 04:28 AM
Choosing your OS on wake on lan (wol) footloose Linux - Software 2 05-30-2007 07:48 PM
Help with WOL Wake on LAN Knight Templar Linux - Networking 3 07-19-2006 09:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration