Wednesday, June 20, 2012

HowTo: Enable Wake-on-LAN on FreeBSD

Wake-on-LAN also know as WOL is the ability to switch on a computer that is connected to a network (local or otherwise) by means of a special network message called a magic packet. This magic packet contains the MAC address of the destination computer. If the destination computer has a network interface card that supports WOL then the system wakes up.

In this post I'll describe how to Wake-on-LAN a FreeBSD destination computer so that it can be turned on from another computer.

For sake of simplicity I've broken down the procedure into a few steps:
1) Enable WOL in BIOS
2) Check for driver WOL support
3) Collect network interface information
4) Wake up computer from local network
5) Wake up computer from internet

1) Enable WOL in BIOS

These days pretty much all integrated or otherwise NICs support Wake-on-LAN, however more often than not you'll need to enable it in the BIOS. There are literally hundreds of BIOS around but look for the typical options: "Enable Wake-on-LAN", "Enable Wake on PCI" and "Enable Power of PCIE Devices".

2) Check for driver WOL support

With each FreeBSD release more and more ethernet drivers get support for Wake-on-LAN. To check the list of drivers with WOL support in your FreeBSD release (in my case 7.4-RELEASE) run:
  1. $ grep -l IFCAP_WOL /usr/src/sys/dev/*/*.c

Now compare the list of WOL supported drivers with the driver attached to your network interface:
 $ ifconfig -m   
 re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500  
     ether 00:aa:11:bb:22:cc  
     inet netmask 0xffffff00 broadcast  
     media: Ethernet autoselect (100baseTX <full-duplex>)  
     status: active  
     supported media:  
         media autoselect mediaopt flowcontrol  
         media autoselect  
         media 1000baseTX mediaopt full-duplex,flowcontrol,master  
         media 1000baseTX mediaopt full-duplex,flowcontrol  
         media 1000baseTX mediaopt full-duplex,master  
         media 1000baseTX mediaopt full-duplex  
         media 1000baseTX mediaopt master  
         media 1000baseTX  
         media 100baseTX mediaopt full-duplex,flowcontrol  
         media 100baseTX mediaopt full-duplex  
         media 100baseTX  
         media 10baseT/UTP mediaopt full-duplex,flowcontrol  
         media 10baseT/UTP mediaopt full-duplex  
         media 10baseT/UTP  
         media none  
 plip0: flags=108810<POINTOPOINT,SIMPLEX,MULTICAST,NEEDSGIANT> metric 0 mtu 1500  
 lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384  
     inet6 fe80::1 prefixlen 64 scopeid 0x4   
     inet6 ::1 prefixlen 128   
     inet netmask 0xff000000   
By analysing the output of ifconfig one can notice that I have re driver attached to network card. Also the re0 card not only is capable of WOL but also it is already setup to use it.

FreeBSD is extremely well documented and as such WOL support can be confirmed in re(4) man page.

3) Collect network interface information

From the output of ifconfig -m I can write down the MAC address for re0, 00:aa:11:bb:22:cc.
  1. $ ifconfig -m | grep ether        ether 00:aa:11:bb:22:cc

4) Wake up computer from local network

With the destination computer turned off, from the computer that will be used to send the magic WOL packet, install the net/wakeonlan port and run it:
  1. # cd /usr/ports/net/wakeonlan
  2. # make install clean
  3. # rehash
  4. # wakeonlan -i 00:aa:11:bb:22:cc

Replace with the broadcast from your network. is the broadcast address for a 192.168.1.x subnet which is the case of my local network and 00:aa:11:bb:22:cc is MAC address of the destination computer.

It should be noted that net/wakeonlan and similar applications are available in all Unix-like operating systems.

5) Wake up computer from internet

This involves enabling port forwarding of UDP port 9 to the destination computer in the router's administration webpage. To fully benefit from WOL you should configure a dynamic DNS service.

Afterwards to issue the wake up command you can use websites such as, Android applications (Wake on Lan) or any other Wake-on-LAN application (every Unix-like system as an alternative available). Just make sure to use your dynamic DNS provided address and the destination computer's MAC.

1 comment:

Anonymous said...

Thank you for this post. One of the more comprehesive ones on this topic.

Keep up the good work!