How to set up Wake On LAN on ubuntu home server

I am thinking about setting up a home server, which could be used as file, print, web and whatsoever server, I was playing around for some time with a NAS device. The problem was, that it didn’t really satisfy my needs. One reason was that it was too loud. Another reason was, that the hardware had not enough power to do the things I wanted.

I took some old hardware, which was much more powerful than the NAS device to try if that could eventually fullfill my requirements. But as that hardware consumes more energy and home servers are often idle most of the day (at least in my case), the first feature I want the box to be capable of, is to support Wake On LAN. So it would be possible for me to put the box somewhere where I don’t need to have physical access to and just start it when I really need it and shut it down afterwards. That would be better for the environment and for my wallet, too.

Here’s how I managed it:

  1. Check if the hardware supports WOL. If yes, enable it in the BIOS.
  2. Install ethtool. You can do this by entering

    sudo apt-get install ethtool

    in a konsole window.

  3. To check the settings, use the command ethtool {interface} where {interface} is the according interface. In my case the command is

    sudo ethtool eth0

    and the output looks like this:

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

    Important here are the lines starting with Supports Wake-on and Wake-on. The first tells us, which Wake-On-LAN modes the network interface supports and the second if/which mode is enabled. The man page of ethtool 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.
    ...
    

    My interface supports modes p and g but at the moment, it is disabled (Wake-on: d).

  4. Enable WOL using sudo ethtool -s eth0 wol g. Now sudo ethtool eth0 shows Wake-on: g.
  5. Test if it works. To do this, you need another computer with a tool which supports to send the MagicPacket(tm). You could e.g. install wakeonlan with a sudo apt-get install wakeonlan on the computer which wants to wake the server. Additionally, you need the MAC address of your server’s network interface. You can get that with a ifconfig eth0 on your server. That will result in something like this:
    eth0      Link encap:Ethernet  Hardware Adresse XX:XX:XX:XX:XX:XX
              inet6-Adresse: XXX::XXX:XXXX:XXXX:XXXX/64 Gültigkeitsbereich:Verbindung
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metrik:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
              Kollisionen:0 Sendewarteschlangenlänge:1000
              RX bytes:0 (0.0 B)  TX bytes:3204 (3.2 KB)
              Interrupt:16
    

    To test, if it works, shutdown the server. Then try a wakeonlan XX:XX:XX:XX:XX:XX where XX:XX:XX:XX:XX:XX is the address in line one of the output of ifconfig-command above. If it worked, the first step is done.

I don’t know, if it is necessary to do the following steps on every computer which wants to be woken up, but in my case, the setting of the ethtool command was not permanent(you could check this by a anew sudo ethtool eth0 or just try to wake a second time). If it is not permanent:

  1. add the line

    ethtool -s eth0 wol g

    to the file /etc/rc.local.

  2. reboot
  3. try again if it works (for me it does)
Advertisements

13 Responses to How to set up Wake On LAN on ubuntu home server

  1. Woah! I’m really enjoying the template/theme of this site.
    It’s simple, yet effective. A lot of times it’s tough to get that “perfect balance” between usability
    and visual appearance. I must say you have done a fantastic job with
    this. Also, the blog loads extremely quick for me on Safari.
    Exceptional Blog!

  2. Pingback: Automated SCP Copy Script (with Wake-On-LAN) | Prasys' Blog

  3. Pingback: Turn on Ubuntu web server remotely | Code Chewing

  4. Pingback: Useful Website Articles & Tutorials | Code Chewing

  5. Kris says:

    I found some really good post about Wake On Lan oin ubuntu
    http://lukasz-lademann.blogspot.com/2013/01/how-set-up-wol-wake-on-lan-on-thin.html

  6. Reblogged this on Joaquín Huesca.

  7. Sandra says:

    It was permanent for me without having to go through that last step. But I bookmarked this page. Thanks a lot!! 😀

  8. Pingback: Using wake on lan to conserve power | Energy Monitor Blog

  9. Pingback: Set up Wake On LAN on ubuntu home server | TurboLinux Blog

  10. Slappy says:

    I did not know about the /etc/rc.local file. It is like a batch file that is put in the startup in Windoze. I was looking for a way to make WOL permanent on my Debian server. I think I just found it. Thanks!

  11. sumudu says:

    Hi thanks for help any thing need help pls contact my mail

  12. Steve says:

    Works great on my system too. I like handling this in the rc.local file as well. Thanks for posting this solution.

  13. Leo says:

    Thanks. It works.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: