搭建Linux下的自动唤醒功能(原创)

一般办公室的网关都是24小时开着的,有时候需要远程启动办公室的机器获取些资料,使用这个功能就比较方便了。
首先设置个人机器网卡可以网络唤醒(在BIOS里设置,现在的机器一般都支持这个功能)
网关服务器设置:
#wget ftp://ftp.scyld.com/pub/diag/ether-wake.c
#gcc -O -Wall -o ether-wake ether-wake.c
这步估计会提示些错误信息,先不管它,看看目录下是否生成ether-wake文件了
ok,我这里生成了

#./ether-wake -u

usage: ether-wake [-i <ifname>] [-p aa:bb:cc:dd[:ee:ff]] 00:11:22:33:44:55

        This program generates and transmits a Wake-On-LAN (WOL)
        "Magic Packet", used for restarting machines that have been
        soft-powered-down (ACPI D3-warm state).
        It currently generates the standard AMD Magic Packet format, with
        an optional password appended.

        The single required parameter is the Ethernet MAC (station) address
        of the machine to wake or a host ID with known NSS 'ethers' entry.
        The MAC address may be found with the 'arp' program while the target
        machine is awake.

        Options:
                -b      Send wake-up packet to the broadcast address.
                -D      Increase the debug level.
                -i ifname       Use interface IFNAME instead of the default 'eth0'.
                -p <pw>         Append the four or six byte password PW to the packet.
                                        A password is only required for a few adapter types.
                                        The password may be specified in ethernet hex format
                                        or dotted decimal (Internet address)
                -p 00:22:44:66:88:aa
                -p 192.168.1.1

将需要的ip mac对应列表保存在网关服务器上,需要的时候,远程登陆到网关服务器执行
#./ether-wake  -i eth0 -p 需要启动机器的MAC         (eth0是内网网卡)
过一会,机器就启动了。

当然了,如果想远程控制办公室机器,还要在个人机器上装远程控制软件,网关服务器上开通相关策略,由于这些内容不属于本文讨论范围,就略过了。

评论: 0 | 引用: 0 | 阅读: 7477