实现远程开机的条件,要满足以下两条:首先,这个被远程开机的机器必需是在局域网内,并且你知道这台机器的Mac地址;其次,你的网卡支持网络唤醒功能,当然,现在大部分网卡都是支持网络唤醒的功能。检查你的网卡是否支持网络唤醒功能,只要在被远程开机的机器上执行 ethtool 命令,查看该机器网卡是否支持网络唤醒功能。
# ethtool eth0Settings for eth0:Supported ports: [ TP MII ]Supported link modes: 10baseT/Half 10baseT/Full100baseT/Half 100baseT/FullSupports auto-negotiation: YesAdvertised link modes: 10baseT/Half 10baseT/Full100baseT/Half 100baseT/FullAdvertised auto-negotiation: YesSpeed: 100Mb/sDuplex: FullPort: MIIPHYAD: 1Transceiver: internalAuto-negotiation: onSupports Wake-on: pumbgWake-on: g [ 提示: g 表示已启动. d 表示禁用 ]Current message level: 0×00000001 (1)Link detected: yes
提示:以上命令,需要拥有root权限,否则会有以下错误:
$$ /sbin/ethtool eth0Settings for eth0:Cannot get device settings: Operation not permittedCannot get wake-on-lan settings: Operation not permittedCurrent message level: 0×000000ff (255)Cannot get link status: Operation not permitted
如果网络唤醒功能被禁用,则需要用下面的命令启动网络唤醒功能:
# ethtool -s eth0 wol g
安装网络唤醒软件:
# apt-get install wakeonlan
获取远程机器网卡的物理地址:
# ifconfigeth0 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.0inet6 addr: fe80::216:17ff:fe6b:289/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:3179855 errors:0 dropped:0 overruns:0 frame:0TX packets:2170162 errors:0 dropped:0 overruns:0 carrIEr:0collisions:0 txqueuelen:1000RX bytes:3832534893 (3.5 GB) TX bytes:390304845 (372.2 MB)Interrupt:17
通过以下命令,实现远程开机:
# wakeonlan 00:16:k5:64:A9:68