Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I have setup wake on lan service on my server. Everything works fine on local area network:

root@server$: poweroff
user@local$ wakeonlan AA:BB:CC:DD:EE:FF

and the server wakes up.

AA:BB:CC:DD:EE:FF is a MAC address of my server, which has IP and hostname: It is connected to the router, which has IP (public:

When the server is up, I can ping:


or login via ssh:


So far, so good. Now I'm able to wake the server up from local area, but how to wake the server from the remote location?

I tried: user@local$ wakeonlan -i AA:BB:CC:DD:EE:FF, but it does not work (nothing happens;).

Do I have to configure my router somehow to forward magic packets? How?

The solution

After Ragnar's answer the solution looked very easy.

But actually, it was a bit tricky.

My router is Linksys WAG200g, which does not support Wake on LAN by default. Furthermore, it does not allow to forward to triplets above 254 (my broadcast address was

The solution was to forward UDP port 7 to the address of the server, which was, then call:

wakeonlan -i -p 7 AA:BB:CC:DD:EE:FF

Also I installed new firmware:

which is a great router options upgrade (e.g. adds Wake on LAN option).

I also changed my netmask from to, so my broadcast is now and passes the router validation rules.

Here is the script I use to connect to the machine, and wake it up if needed:

## This sends magic packets to Wake on Lan
## please note, you must formard port 7 to the target machine on your router

## host to wake up
## mac address of the machive to wake up
## user to login

echo "Looking for $host..."
wget -q --tries=2 --wait=1 --waitretry=5 http://$host/
if [ $? -ne 0 ];
    echo "$host is not available."
    echo "Waking up $host."
    wakeonlan -p 7 -i $host $mac
    echo "$host is booting up.  Please wait..."
    sleep 30
    wget -q --waitretry=5 --wait=5 http://$host/
    echo ^G
    echo $host is up! Lucky you!
ssh "$user@$host"

Don't forget to install: wakeonlan

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You need to forward UDP port 9 to the broadcast address in your network (, or alike).

share|improve this answer
Additionally, some routers have a WOL function built into them, so if you connect to your router, you can issue the WOL that way. –  Scaine Jan 1 '11 at 18:03
Thanks. And welcome aboard! –  takeshin Jan 2 '11 at 12:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.