Skip to content

Instantly share code, notes, and snippets.

@sebastianneubert
Last active January 21, 2024 17:40
Show Gist options
  • Save sebastianneubert/afa1be3c7aa56d8dae54effe3c7cb85a to your computer and use it in GitHub Desktop.
Save sebastianneubert/afa1be3c7aa56d8dae54effe3c7cb85a to your computer and use it in GitHub Desktop.
Enable TrueNAS Wake On Lan permanently

Enabling WoL on a TrueNAS System

Source: https://www.truenas.com/community/threads/enable-wol.95856/

As an Admin user you can use the ethtool with sudo rights to check if WoL is available on your system. The usual ethernet NIC name is "enp3s0" so I use everytime this name.

Check if WoL is available

sudo ethtool enp3s0
Supports Wake-on:
 - d available and inactive
 - g available and active
# turn on WoL once
sudo ethtool -s enp3s0 wol g

You can now check with sudo ethtool enp3s0 if now the supports WoL is turned to g, which means -> active

To proof, you can shutdown and send a magic package to your MAC address. (Use Android app or wake-on-lan tool from a different OS)

If this is working, you can be happy for a few minutes. Unfortunatelly, the step above is not permanently persisted, so you have to do it after each reboot (because after your reboot, the configuration is gone.

Make it permanently

  • switch to root user and create a script which does the step above

Create a script

  1. change to root user
sudo su root
  1. create the script
cat >> /root/wol_fix.sh <<EOF
#!/bin/bash
ethtool -s enp3s0 wol g
EOF
  1. add execution flag to that script
chmod 755 /root/wol_fix.sh

Try it! Change the WoL config back to "d" manually. ethtool -s enp3s0 wol d and execute your script as root /root/wol_fix.sh Check if the configuration changed back to "g".

Start a service on boot, which executes the script

cat >> /etc/systemd/system/wol_fix.service <<EOF
[Unit]
Description=Fix WakeOnLAN being reset to disabled on shutdown

[Service]
ExecStart=/root/wol_fix.sh
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOF
# Reload the systemd manager configuration.
systemctl daemon-reload
# start the wol_fix.service
systemctl start wol_fix
# Enable to wol_fix service script.
systemctl enable wol_fix.service

If everything works as expected, you have now permanently WoL enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment