With Wake-on-LAN (WoL) it can be slightly easier to manage machines in-house. You can fire up the workstation and start the day’s compile jobs (to catch up with overnight work by the KDE community, say) while drinking an espresso downstairs and doomscrolling.

Wake-on-LAN relies on three things:

  • When a workstation is off, it is “off” in name only. Many machines still draw 5W or more power when “off”, which is enough to drive an entire Pine64 board. That power allows, among other things, the network chip to monitor the LAN.
  • The LAN can carry specially-crafted “wake” frames, which fit in the Ethernet protocol.
  • The network chip and workstation BIOS cooperate to react to those special frames.

The Wikipedia article on WoL is extensive. From a practical in-house perspective, FreeBSD gives you the tools to use WoL if you have a FreeBSD machine next to (or built-in to) the espresso machine. My notes here assume a simple one-network in-home LAN.

Wake up, little server

If all the administrative bits are in place, then the simple way to wake up a machine is wake <hostname>. This requires root, since it sends specially-crafted (broadcast) Ethernet packets, which isn’t something that regular users can do.

If only some of the administrative bits are in place, then wake <mac-address> will do the trick.

The administrative bits

To wake up a machine, you need to know the MAC-address (of a network chip in that machine, that supports WoL).

  • If the machine is on, and you can login on it: ifconfig will tell you. Look for the ether line in the output, like this one, and also the WOL_MAGIC option:
    re0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
          options=82099<RXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC,LINKSTATE>
          ether 22:ff:55:66:00:cc
    

    Linuxes which don’t ship ifconfig can use ip link list in the same way.

  • If the machine is on and on the network, arp -a elsewhere in the network will tell you what is on the network and what MAC-addresses there are. Hopefully you can pick the right machine out of that.
    wakeme.example.com (10.0.1.67) at 22:ff:55:66:00:cc on re0 expires in 72 seconds [ethernet]
    
  • If the machine is on, or has been on, and does DHCP, the /var/db/dhcpd.leases file on the DHCP server contains entries for the DHCP leases, and you can look for the MAC-address and identifying host information there (some lines stripped out in the middle here).
    lease 10.0.1.67 {
          hardware ethernet 22:ff:55:66:00:cc;
          client-hostname "wakeme";
    }
    

Armed with the knowledge of the MAC-address of the machine to wake up, wake can do its thing, but if you are not into remembering MAC-addresses, then the file /etc/ethers provides a persistent database of MAC-to-hostname mappings; adding a line in that file puts all the administrative bits in place:

22:ff:55:66:00:cc wakeme

Fancy

The end-game is, clearly, to have Mycroft running on something near the espresso machine, so you can shout “hey, Mycroft, wake the workstation” and we can wake up in parallel.

Pages from the manual: wake ethers(5)