In this post I'll describe how to setup a CentOS destination computer so that it can be turned on from another computer. This procedure is also applicable to RHEL and its clones such as Scientific Linux and Oracle Unbreakable Linux.
For sake of simplicity I've broken down the procedure into a few steps:
1) Enable WOL in BIOS
2) Collect network interface information
3) Enable WOL for the next shutdown
4) Make WOL always enabled
5) Wake up the computer from local network
6) Wake up the computer from internet
7) Troubleshooting
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) Collect network interface information
Start by checking if the destination computer network card support Wake-on-LAN with ethtool:$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:11:AA:22:BB:22
inet addr:192.168.1.5 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fc70::151:8daa:fbab:f14a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:563668 errors:0 dropped:0 overruns:0 frame:0
TX packets:317604 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:813741621 (776.0 MiB) TX bytes:68592900 (65.4 MiB)
Interrupt:22 Base address:0xa000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:480 (480.0 b) TX bytes:480 (480.0 b)$ su
# ethtool eth0
Settings for eth0:
Supported ports: [ MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 1
Transceiver: external
Auto-negotiation: on
Supports Wake-on: g
Wake-on: d
Link detected: yes
The "Supports Wake-on: g" string means that the NIC does in fact support Wake-on-LAN while "Wake-on: d" is a sign that the feature is not turned activated in the operating system.
Do notice that the target of ethtool was eth0 which is my destination computer's network interface name.
To use Wake-on-LAN we need to identify the NIC MAC address to which end ifconfig can be used:
# ifconfig | grep HWaddr
eth0 Link encap:Ethernet HWaddr 00:11:AA:22:BB:22
3) Enable WOL for the next shutdown
To command the operating system to enable WOL for the eth0 network interface run:# ethtool -s eth0 wol g
Issuing ethtool again now returns "Wake-on: g" so now we have WOL enabled:
# ethtool eth0
Settings for eth0:
Supported ports: [ MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 1
Transceiver: external
Auto-negotiation: on
Supports Wake-on: g
Wake-on: g
Link detected: yes
4) Make WOL always enabled
To have WOL always enabled the operating system needs to be told that eth0 (this is my NIC's interface name, don't forget to change according to your own system) WOL is supposed to be active.There are 2 methods to achieve this, one employs adding ethtool -s eth0 wol g command to /etc/rc.d/rc.local while the other consists in creating a network script and enabling the network service.
Choose one of the methods, personally I'd go for the /etc/rc.d/rc.local method as it requires less typing ;)
Method A
#echo '/usr/sbin/ethtool -s eth0 wol g' >> /etc/rc.d/rc.local
Method B
# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=EThernetONBOOT=yes
ETHTOOL_OPTS="wol g"
# chkconfig network on
5) Wake up the computer from local network
From the computer that will be used to send the magic WOL packet, install and run wakelan:# yum install wakelan
# rehash
# wakelan 00:11:AA:22:BB:22
6) Wake up the 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.
7) Troubleshooting
While troubleshooting Wake-on-LAN I've noticed that if you use GRUB without timeout set and poweroff the computer while on the operating system selection menu, the next time you try to use Wake-on-LAN it won't work. So make sure you have GRUB with a timeout set (which is the case will all default installation of GRUB).If the computer is disconnected from the power supply you'll need to boot the computer and turn off again so that the NIC assumes the WOL definitions.
3 comments:
Wow very nice this post. But i have a problem equal to step 7.
I already set timeout of grub for timeout=0, but won't work.
What i need to do now?
Tanks
Hi Lenilson,
For what I recall you need to specify a timeout, so I don't think timeout=0 works as that is the same as disabling it altogether. Try something like timeout=3.
Do notice that step 7 serves merely for troubleshooting.
Best regards.
I am building a render farm with 3 muli-GPU servers and a file server. This information was key in getting it to work.
I just wish Wake On Lan wasn't so flaky. I changed the router and half the nodes stopped responding. Time to reconfigure...
Post a Comment