實現遠程開機的條件,要滿足以下兩條:首先,這個被遠程開機的機器必需是在局域網內,並且你知道這台機器的MAC地址;其次,你的網卡支持網絡喚醒功能,當然,現在大部分網卡都是支持網絡喚醒的功能。檢查你的網卡是否支持網絡喚醒功能,只要在被遠程開機的機器上執行 ethtool 命令,查看該機器網卡是否支持網絡喚醒功能。
# 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
Wake-on: g [ 提示: g 表示已啟動. d 表示禁用 ]
Current message level: 0×00000001 (1)
Link detected: yes
提示:以上命令,需要擁有root權限,否則會有以下錯誤:
$ /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: 0×000000ff (255)
Cannot get link status: Operation not permitted
如果網絡喚醒功能被禁用,則需要用下面的命令啟動網絡喚醒功能:
# ethtool -s eth0 wol g
安裝網絡喚醒軟件:
# apt-get install wakeonlan
獲取遠程機器網卡的物理地址:
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:16:k5:64:A9:68 [ Mac地址 ]
inet addr:192.168.6.56 Bcast:192.168.6.255 Mask:255.255.255.0
inet6 addr: fe80::216:17ff:fe6b:289/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
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)
Interrupt:17
通過以下命令,實現遠程開機:
# wakeonlan 00:16:k5:64:A9:68