It surprises me that there’s a lot of people out there who know about WOL (wake on lan), the ability to
Remotely turn on your pc/server via the network card. But doesnt know that you can do it from the Internet, and not just on your home network.

This howto, shortly explains how to set it up on Linux, and covers possible problems you might encounter.

Anyway, lets get going!

 

In order to wake up a computer from the Internet you need a Broadband connection with a Router connected to the Modem that keeps your connection alive (you need a Router even if you have Static IP).

 

Other articles on the net might referrer to a little cable that’s used to connect the NIC with the motherboard, for powering it on, however, on newer computers this isn’t necessary anymore as it works via PCI, and only need to be enabled in the bios (might be called something like Wake on PCI). But if you don’t have an on-board NIC, but and old sucky 10/10Mbit..then..well..good luck :)

If you use Debian as in this case, fire up apt-get, and install ethtool

apt-get install ethtool

and if you don’t. then grab it from sourceforge.net

Now, use ifconfig to check what your interface is called (most likely eth0)
And run ethtool with it like

Ethtool eth0

Which will spit out something similar to

 

Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: umbg
Wake-on: d
Current message level: 0×00000007 (7)
Link detected: yes

Notice the “Supports Wake-on” says umbg, but “Wake-on” says d (disabled)


If we take a short look on the manpage for ethtool it says.

 

wol p|u|m|b|a|g|s|d…

Sets Wake-on-LAN options. Not all devices support this. The argument to this option is a string of characters specifying which options

to enable.

p Wake on phy activity

u Wake on unicast messages

m Wake on multicast messages

b Wake on broadcast messages

a Wake on ARP

g Wake on MagicPacket(tm)

s Enable SecureOn(tm) password for MagicPacket(tm)

d Disable (wake on nothing). This option clears all previous options.

 

So we can see it supports umbg, but currently its set to d for disabled.

all good so far. so in this case, we will be using the MagicPacket method to wake it up

so fire up ethtool with the command.

ethtool –s eth0 wol g

Doing ethtool eth0 again, should now show

Wake-on: g

Horay!

 

Now you should open a port on your router. Doesnt really matter which one you pick,so for all you people with a fetish for good looking numbers, you can just choose you’re desired one.

in this example I’m using port 8000 (such a nice number isn’t it?)

so open port 8000 protocol udp, in your router, and forward it to your machine’s internal ip.

Ifconfig will show..

 

eth0 Link encap:Ethernet HWaddr 00:41:63:DD:78:60

inet addr:10.0.0.56 Bcast:10.0.0.255 Mask:255.255.255.0

inet6 addr: fe80::240:63ff:fedd:7860/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:12193206 errors:0 dropped:0 overruns:0 frame:0

TX packets:12300751 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:2652858583 (2.4 GiB) TX bytes:1613681546 (1.5 GiB)

Interrupt:11 Base address:0xe400

 

So we forward port 8000/udp to 10.0.0.56.

While we’re at it. Write down 00:41:63:DD:78:60

Since we need the mac address to wake it up from its beauty sleep.(sounds gay I know)


Now you might as well just kill it (shutdown –hP now) since we need to test.

Now, if you want to power it on from another Linux machine, go get wakeonlan

apt-get install wakeonlan

and type

#wakeonlan -i ip/dns -p port mac-adress

In my case

#wakeonlan –i annoying.dk –p 8000 00:41:63:DD:78:60

And it should say something like

 

Sending magic packet to annoying.dk:8000 with 00:41:63:DD:78:60

 

Now, hopefully, it should start powering on your machine.


Another way to do it, its from a free service at depicus.com

which lets you power it on online from their site.

Here you enter the same information, and subnetmask 255.255.255.240 or 255.255.255.255

depending on your setup.

Or just go get their program from

http://www.depicus.com/wake-on-lan/wake-on-lan-gui.aspx

If your looking for the windows way to set this up, I can recommend looking at

www.raymond.cc

which should cover it all up.

Now. If all of this doesn’t work. You should try testing in on your local network first,

If it still don’t work. And you manually booted up the machine again

Check with “ethtool eth0” to see if it set itself back to “d” instead of g.

If its still set to g, it should really work. And I’m too lazy to write possible causes, so good luck. :)

Everything works pretty much out of the box if you shut down Linux with poweroff etc. as you usually do. But if the ac power is lost while the machine is powered down waiting for wakeup, the wake up-call won’t work anymore when the power is restored. The nic’s I guess sometimes seem to reset themselves and have to be set with ethtool again.

This can however easily be done with a small startup script, or similar ways which I wont cover up this time. (I will I probably update it later on if people bitch enough)

Now. If its set itself back to d, here’s a possible solution.

Edit /etc/init.d/networking and comment out

“ifdown -a –exclude=lo”

And it should do the trick. And yes, I have no clue at this point why it should work, so just hope for the best :)

 

all suggestions are welcome.

 

Enjoy!