Showing posts with label Wake-on-LAN. Show all posts
Showing posts with label Wake-on-LAN. Show all posts

Monday, July 9, 2012

HowTo: Enable Wake-on-LAN on CentOS / SL 6.3

Wake-on-LAN also know as WOL is the ability to switch on a computer that is connected to a network (local or not) by means of a special network message called a magic packet. This magic packet contains the MAC address of the destination computer. If the destination computer has a network interface card that support WOL then the system wakes up.

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:
  1. $ 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)
  2. $ su
  3. # 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:
  1. # ifconfig | grep HWaddreth0 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:
  1. # ethtool -s eth0 wol g

Issuing ethtool again now returns "Wake-on: g" so now we have WOL enabled:
  1. # 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

  1. #echo '/usr/sbin/ethtool -s eth0 wol g' >> /etc/rc.d/rc.local

Method B
  1. # vim /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    TYPE=EThernet 
    ONBOOT=yesETHTOOL_OPTS="wol g"
  2. # 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:

  1. # yum install wakelan
  2. # rehash
  3. # 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.

Wednesday, June 20, 2012

HowTo: Enable Wake-on-LAN on Gentoo

Wake-on-LAN also know as WOL is the ability to switch on a computer that is connected to a network (local or not) by means of a special network message called a magic packet. This magic packet contains the MAC address of the destination computer. If the destination computer has a network interface card that support WOL then the system wakes up.

In this post I'll describe how to setup a Gentoo destination computer so that it can be turned on from another computer.

For sake of simplicity I've broken down the procedure into a few steps:
1) Enable WOL in BIOS
2) Install ethtool
3) Collect network interface information
4) Enable WOL for the next shutdown
5) Make WOL always enabled
6) Wake up the computer from local network
7) Wake up the computer from internet
8) 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) Install ethtool

Take emerge for a spin and install sys-apps/ethtool. ethtool is an utility for examining and tuning ethernet-based network interfaces.
  1. # emerge ethtool
  2. # rehash

3) Collect network interface information

To use Wake-on-LAN we need to identify the NIC MAC address. For example, in my computer the MAC address is 00:aa:11:bb:22:cc.
  1. # ifconfigeth0      Link encap:Ethernet  HWaddr 00:aa:11:bb:22:cc 
              inet addr:192.168.1.3  Bcast:192.168.1.255  Mask:255.255.255.0
              inet6 addr: fa10::120:1aef:ffeb:b78a/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:129199 errors:0 dropped:0 overruns:0 frame:0
              TX packets:165680 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:58680158 (55.9 MiB)  TX bytes:26252276 (25.0 MiB)
              Interrupt:10 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:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Check if the NIC does support the Wake-on-LAN feature:
  1. # ethtool eth0Settings for eth0:
    Supported ports: [ MII ]
    Supported link modes: 10baseT/Half 10baseT/Full
    100baseT/Half 100baseT/Full
    Supported pause frame use: No
    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 isn't active.

4) Enable WOL for the next shutdown

To command the operating system to enable WOL for the eth0 network interface run:

  1. # ethtool -s eth0 wol g

Issuing ethtool again now returns "Wake-on: g" so now we have WOL enabled:

  1. # ethtool eth0
    Settings for eth0:
    Supported ports: [ MII ]
    Supported link modes: 10baseT/Half 10baseT/Full
    100baseT/Half 100baseT/Full
    Supported pause frame use: No
    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

5) Make WOL always enabled

To have WOL always enabled Gentoo needs to be told that eth0 WOL is supposed to be active.

Assuming your're using OpenRC (which you should) add ethtool -s eth0 wol g to /etc/local.d/wol.start:
  1. # echo "ethtool -s eth0 wol g" > /etc/local.d/wol.start
  2. # chmod +x /etc/local.d/wol.start

The /etc/local.d/ directory contains scripts which are to be run when local service is started or stopped, so by adding a script with an executable script with a .start extension, it will be run when the local service is started at boot.

6) Wake up the computer from local network

From the computer that will be used to send the magic WOL packet, install and run net-misc/wakeonlan:

  1. # emerge wakeonlan
  2. # rehash
  3. # wakeonlan -i 192.168.1.255 00:50:8d:eb:a7:8a

Replace 192.168.1.255 with the broadcast from your network. 192.168.1.255 is the broadcast address for a 192.168.1.x subnet which is the case of my local network.

7) 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.

8) 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.

HowTo: Enable Wake-on-LAN on FreeBSD

Wake-on-LAN also know as WOL is the ability to switch on a computer that is connected to a network (local or otherwise) by means of a special network message called a magic packet. This magic packet contains the MAC address of the destination computer. If the destination computer has a network interface card that supports WOL then the system wakes up.

In this post I'll describe how to Wake-on-LAN a FreeBSD destination computer so that it can be turned on from another computer.

For sake of simplicity I've broken down the procedure into a few steps:
1) Enable WOL in BIOS
2) Check for driver WOL support
3) Collect network interface information
4) Wake up computer from local network
5) Wake up computer from internet

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) Check for driver WOL support

With each FreeBSD release more and more ethernet drivers get support for Wake-on-LAN. To check the list of drivers with WOL support in your FreeBSD release (in my case 7.4-RELEASE) run:
  1. $ grep -l IFCAP_WOL /usr/src/sys/dev/*/*.c
    /usr/src/sys/dev/ae/if_ae.c
    /usr/src/sys/dev/age/if_age.c
    /usr/src/sys/dev/alc/if_alc.c
    /usr/src/sys/dev/ale/if_ale.c
    /usr/src/sys/dev/e1000/if_em.c
    /usr/src/sys/dev/e1000/if_lem.c
    /usr/src/sys/dev/fxp/if_fxp.c
    /usr/src/sys/dev/jme/if_jme.c
    /usr/src/sys/dev/nfe/if_nfe.c
    /usr/src/sys/dev/nge/if_nge.c
    /usr/src/sys/dev/re/if_re.c
    /usr/src/sys/dev/sis/if_sis.c
    /usr/src/sys/dev/ste/if_ste.c
    /usr/src/sys/dev/stge/if_stge.c
    /usr/src/sys/dev/txp/if_txp.c
    /usr/src/sys/dev/vge/if_vge.c
    /usr/src/sys/dev/vr/if_vr.c

Now compare the list of WOL supported drivers with the driver attached to your network interface:
 $ ifconfig -m   
 re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500  
     options=389b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_UCAST,WOL_MCAST,WOL_MAGIC>  
     capabilities=4399b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,WOL_UCAST,WOL_MCAST,WOL_MAGIC,VLAN_HWTSO>  
     ether 00:aa:11:bb:22:cc  
     inet 192.168.1.3 netmask 0xffffff00 broadcast 192.168.1.255  
     media: Ethernet autoselect (100baseTX <full-duplex>)  
     status: active  
     supported media:  
         media autoselect mediaopt flowcontrol  
         media autoselect  
         media 1000baseTX mediaopt full-duplex,flowcontrol,master  
         media 1000baseTX mediaopt full-duplex,flowcontrol  
         media 1000baseTX mediaopt full-duplex,master  
         media 1000baseTX mediaopt full-duplex  
         media 1000baseTX mediaopt master  
         media 1000baseTX  
         media 100baseTX mediaopt full-duplex,flowcontrol  
         media 100baseTX mediaopt full-duplex  
         media 100baseTX  
         media 10baseT/UTP mediaopt full-duplex,flowcontrol  
         media 10baseT/UTP mediaopt full-duplex  
         media 10baseT/UTP  
         media none  
 plip0: flags=108810<POINTOPOINT,SIMPLEX,MULTICAST,NEEDSGIANT> metric 0 mtu 1500  
 lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384  
     inet6 fe80::1 prefixlen 64 scopeid 0x4   
     inet6 ::1 prefixlen 128   
     inet 127.0.0.1 netmask 0xff000000   
By analysing the output of ifconfig one can notice that I have re driver attached to network card. Also the re0 card not only is capable of WOL but also it is already setup to use it.

FreeBSD is extremely well documented and as such WOL support can be confirmed in re(4) man page.

3) Collect network interface information

From the output of ifconfig -m I can write down the MAC address for re0, 00:aa:11:bb:22:cc.
  1. $ ifconfig -m | grep ether        ether 00:aa:11:bb:22:cc

4) Wake up computer from local network

With the destination computer turned off, from the computer that will be used to send the magic WOL packet, install the net/wakeonlan port and run it:
  1. # cd /usr/ports/net/wakeonlan
  2. # make install clean
  3. # rehash
  4. # wakeonlan -i 192.168.1.255 00:aa:11:bb:22:cc

Replace 192.168.1.255 with the broadcast from your network. 192.168.1.255 is the broadcast address for a 192.168.1.x subnet which is the case of my local network and 00:aa:11:bb:22:cc is MAC address of the destination computer.

It should be noted that net/wakeonlan and similar applications are available in all Unix-like operating systems.

5) Wake up 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.