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:$ grep -l IFCAP_WOL /usr/src/sys/dev/*/*.c
/usr/src/sys/dev/ae/if_ae.c
/usr/src/sys/dev/age/if_age.c
/usr/src/sys/dev/alc/if_alc.c
/usr/src/sys/dev/ale/if_ale.c
/usr/src/sys/dev/e1000/if_em.c
/usr/src/sys/dev/e1000/if_lem.c
/usr/src/sys/dev/fxp/if_fxp.c
/usr/src/sys/dev/jme/if_jme.c
/usr/src/sys/dev/nfe/if_nfe.c
/usr/src/sys/dev/nge/if_nge.c
/usr/src/sys/dev/re/if_re.c
/usr/src/sys/dev/sis/if_sis.c
/usr/src/sys/dev/ste/if_ste.c
/usr/src/sys/dev/stge/if_stge.c
/usr/src/sys/dev/txp/if_txp.c
/usr/src/sys/dev/vge/if_vge.c
/usr/src/sys/dev/vr/if_vr.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
options=389b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_UCAST,WOL_MCAST,WOL_MAGIC>
capabilities=4399b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,WOL_UCAST,WOL_MCAST,WOL_MAGIC,VLAN_HWTSO>
ether 00:aa:11:bb:22:cc
inet 192.168.1.3 netmask 0xffffff00 broadcast 192.168.1.255
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 127.0.0.1 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.$ 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:# cd /usr/ports/net/wakeonlan
# make install clean
# rehash
# wakeonlan -i 192.168.1.255 00:aa:11:bb:22:cc
Replace 192.168.1.255 with the broadcast from your network. 192.168.1.255 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 http://wakeonlan.me, 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:
Thank you for this post. One of the more comprehesive ones on this topic.
Keep up the good work!
Post a Comment