Server Administration & Management

How to startup server using ether-wake

Wake-on-LAN is a useful feature on most network cards that allows you to remotely boot up a computer. The ethtool utility (found in the ethtool RPM) can tell you if your network card supports Wake-on-LAN:

# ethtool eth0
Settings for eth0:
    Supported ports: [ TP ]
    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 auto-negotiation: Yes
    Speed: 100Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 0
    Transceiver: internal
    Auto-negotiation: on
    Supports Wake-on: umbg
    Wake-on: d
    Current message level: 0x00000007 (7)
    Link detected: yes

Look for the “Supports Wake-on” line. It should list one or more letters, including “g” (WoL using Magic Packet). In the example above, Wake-on-LAN is currently disabled (“d”). The Wake-on-LAN setting does not persist. It needs to be configured every time the machine boots. On RHEL, this is usually done from /etc/init.d. Create a script called /etc/init.d/wol with the following content:

# wol Wake-on-LAN configuration script
# chkconfig: – 99 01
# description: Wake-on-LAN allows a machine to be started using a WoL network packet.
# This script configured WoL on interfaces listed in $NIC.
# processname: –
# config: –
# pidfile: –

# Source function library.
. /etc/rc.d/init.d/functions
# List of NICs to configure for WoL.
# Note: on Xen hosts, use peth0 instead of eth0.

if [ “$1” != “start” ]; then
exit 0

echo -n “Enabling Wake-on-LAN for:”
for nic in ${NIC};
echo -n ” ${nic}”
[ -x /sbin/ethtool ] && /sbin/ethtool -s ${nic} wol g >/dev/null 2>&1

# Note: no error checking – ethtool does not return a useful exit code


Add the script to the start-up sequence:

# chkconfig –add wol

# chkconfig wol on

The script will now be run on every reboot. You can check the result using ethtool eth0; it should now display “Wake-on: g“.

You should now be able to shutdown your computer, and wake it by sending a “WoL Magic Packet” from another computer. On Linux, use ether-wake (from the net-tools RPM) or wol (from the wol RPM) to send the Magic Packet:

# /sbin/ether-wake -i eth0 00:04:23:C0:FF:EE

January 31, 2012 Posted by | Tips & Tricks, Unix/Linux | , , , , | Leave a comment

How to startup server using wakeonlan

Here is complete process turn on servers remotely without physical access. Wakeonlan (wol) enables you to switch ON remote servers without physically accessing it. Wakeonlan sends magic packets to wake-on-LAN enabled ethernet adapters and motherboards to switch on remote computers.

By mistake, when you shutdown a system instead of rebooting, you can use Wakeonlan to power on the server remotely. Also, If you have a server that don’t need to be up and running 24×7, you can turn off and turn on the server remotely anytime you want. This article gives a brief overview of Wake-On-LAN and instructions to set up Wakeonlan feature.

Overview of Wake-On-LAN

You can use Wakeonlan when a machine is connected to LAN, and you know the MAC address of that machine.
Your NIC should support wakeonlan feature, and it should be enabled before the shut down. In most cases, by default wakeonlan is enabled on the NIC. When the system crashes because of power failure, for the first time you cannot switch on your machine using this facility. But after the first first boot you can use wakeonlan to turn it on, if the server gets shutdown for some reason. WakeonLan is also referred as wol.

Check whether wol is supported on the NIC, Execute the following ethtool command in the server which you want to switch ON from a remote place.

# ethtool eth0

Settings for eth0:
        Supported ports: [ TP 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 auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: pumbg  [ Note: check whether flag g is present ]
        Wake-on: g [ Note: g mean enabled. d means disabled ]
        Current message level: 0x00000001 (1)
        Link detected: yes

If  Supports Wake-on is g, then the support for wol feature is enabled on the NIC card. Enabling wol option on the Ethernet Card. By default the Wake-on will be set to g in most of the machines. If not, use ethtool to set the g flag to the wol option of the NIC card as shown below.

# ethtool -s eth0 wol g

Note: You should execute ethtool as root, else you may get following error message.

#/sbin/ethtool eth0

Settings for eth0:
Cannot get device settings: Operation not permitted
Cannot get wake-on-lan settings: Operation not permitted
Current message level: 0x000000ff (255)
Cannot get link status: Operation not permitted

Install the wakeonlan package in the machine from where you need to send the magic packet to switch on your server.

# wget http://gsd.di.uminho.pt/jpo/software/wakeonlan/downloads/wakeonlan-0.41-0.fdr.1.noarch.rpm

# rpm -ivh wakeonlan-0.41-0.fdr.1.noarch.rpm

Note down the MAC address of the server that you wish to switch on remotely.

# ifconfig

eth0     Link encap:Ethernet  HWaddr 00:16:k5:64:A9:68  [ Mac address ]
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::216:17ff:fe6b:289/64 Scope:Link
          RX packets:3179855 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2170162 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3832534893 (3.5 GB)  TX bytes:390304845 (372.2 MB)

Finally, Switch ON the machine remotely without physical access. When the server is not up, execute the following command from another machine which is connected to the same LAN. Once the magic packet is sent, the remote system will start to boot.

# wakeonlan 00:16:k5:64:A9:68

January 29, 2012 Posted by | Tips & Tricks, Unix/Linux | , , , | Leave a comment