Linux – How to get ethtool wake-on-lan setting to “stick”

debianethtoollinuxwake-on-lan

I have a couple of machines in my server room normally powered off which it's useful to be able to power up remotely.

One of them is an old dual-P3 IBM serverWorks Intel STL2 machine on which wake-on-LAN has performed flawlessly for years. I hit its MAC address with etherwake, and hey-presto there it is a minute or so later (unless it decided it was due an fsck).

The new system I'm having problems with is built on an Asus P5E3. In the BIOS' Power/APM settings wake is enabled for modem/PCI/PCIe devices. That alone doesn't let me wake it using etherwake, but if I use ethtool -s eth0 wol g to enable magic-packet waking, then I can… once. Following any boot (whether via WOL or power-on) the state seems to always revert back to 'd' (disabled). How can I get the state set by ethtool to "stick" indefinitely ?

All systems involved are Debian Lenny, 2.6.26 kernel. Motherboard network interfaces being used, no add-in cards involved.

Thanks for any help

Best Answer

You could use /etc/rc.local or some system boot scripts, but this wouldn't be the best way to do it. On startup your network interfaces are configured, sure, but there are other times when your network interfaces may be brought up or down and you will need this executed during those times.

You want to edit /etc/network/interfaces:

You should have a line like:

iface eth0 inet static

Underneath that, indented further, you want to create a post-up and post-down commands e.g.

iface eth0 inet static
    post-up /usr/sbin/ethtool -s eth0 wol g
    post-down /usr/sbin/ethtool -s eth0 wol g

Obviously, replace eth0 with the relevant interface if different.

See interfaces(5) for more information on post-up and post-down commands

man 5 interfaces