Set up Wake On LAN (WOL) on CentOS 7

Setting up Wake on LAN on a CentOS 7 server.

Installation

Install the ethtool utility:

# yum install -y ethtool

Configuration

Make sure that the BIOS is configured to use Wake-on LAN.

Check what type of WOL the Ethernet card supports (we use net.ifnames=0):

# ethtool eth0 | grep Wake-on
	Supports Wake-on: g
	Wake-on: d

The Ethernet card supports Wake-on: g. From the man page:

wol p|u|m|b|a|g|s|d...
 Sets Wake-on-LAN options. Not all devices support this. The
 argument to this option is a string of characters specifying
 which options to enable.
p Wake on PHY activity
u Wake on unicast messages
m Wake on multicast messages
b Wake on broadcast messages
a Wake on ARP
g Wake on MagicPacket™
s Enable SecureOn™ password for MagicPacket™
d Disable (wake on nothing). This option clears all previous options.

Our card supports the MagicPacket. Configure the NIC to wake on MagicPacket:

# ethtool -s eth0 wol g

Verify:

# ethtool eth0 | grep Wake-on
	Supports Wake-on: g
	Wake-on: g

Make the change persistent by adding the line below to the file /etc/sysconfig/network-scripts/ifcfg-eth0:

ETHTOOL_OPTS="-s ${DEVICE} wol g"

Suspend the Server to RAM

Grab the MAC address of the NIC, it will be required to send the MagicPacket:

# cat /sys/class/net/eth0/address

Suspend the system to RAM via systemd:

# systemctl start systemd-suspend.service

Send a MagicPacket

On another server, install the wakeonlan package and send a MagicPacket to the MAC address of the CentOS server, for example:

$ wakeonlan 00:11:22:00:00:00

Ensure that firewall allows broadcast traffic to leave.

3 thoughts on “Set up Wake On LAN (WOL) on CentOS 7

Leave a Reply

Your email address will not be published. Required fields are marked *