Senin, 19 Desember 2011

Enabling WOL di Linux

untuk mengaktifkan Wake On Lan di linux kita harus men set option sebelum shutdown linux box kita.
pertama kita lihat apakah network driver kita support untuk WOL:

budhi@budhi-PC:~$ sudo ethtool eth0
[sudo] password for budhi:
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Link partner advertised link modes: Not reported
Link partner advertised pause frame use: No
Link partner advertised auto-negotiation: No
Speed: 10Mb/s
Duplex: Half
Port: MII
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000033 (51)
Link detected: no
budhi@budhi-PC:~$

terlihat bahwa network driver kita support pumbg untuk mengetahui pumbg apa liat di man ethtool

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(tm)
s Enable SecureOn(tm) password for MagicPacket(tm)
d Disable (wake on nothing). This option clears all previous
options.

untuk menset network kita agar bisa wol dengan MagicPacket berikut perintahnya

budhi@budhi-PC:~$ sudo ethtool -s eth0 wol g

seperti biasa agar perintah di atas di jalankan setiap restart atau booting kita
tambahkan script kecil di /etc/init.d/ beri nama script tersebut wol.sh

#!/bin/bash
ethtool -s eth0 wol g

buat menjadi executable

budhi@budhi-PC:/etc/init.d$ sudo chmod +x wol.sh

terakhir buat script tersebut run di setiap run level

budhi@budhi-PC:/etc/init.d$ sudo update-rc.d -f wol.sh defaults
update-rc.d: warning: /etc/init.d/wol.sh missing LSB information
update-rc.d: see
Adding system startup for /etc/init.d/wol.sh ...
/etc/rc0.d/K20wol.sh -> ../init.d/wol.sh
/etc/rc1.d/K20wol.sh -> ../init.d/wol.sh
/etc/rc6.d/K20wol.sh -> ../init.d/wol.sh
/etc/rc2.d/S20wol.sh -> ../init.d/wol.sh
/etc/rc3.d/S20wol.sh -> ../init.d/wol.sh
/etc/rc4.d/S20wol.sh -> ../init.d/wol.sh
/etc/rc5.d/S20wol.sh -> ../init.d/wol.sh

finish sudah setting wol di linux

sekarang bagaimana caranya kita mengirim MagicPacket dari linux untuk itu
kita harus tahu mac address dari target

budhi@budhi-PC:~$ ifconfig eth0
eth0 Link encap:Ethernet HWaddr 40:61:86:e8:78:d4

perintah wakeonlan untuk mengirim MagicPacket

budhi@budhi-PC:~$ wakeonlan 40:61:86:e8:68:d4
Sending magic packet to 255.255.255.255:9 with 40:61:86:e8:68:d4

Tidak ada komentar: