机房服务器远程开关机

1.确定服务器是否支持远程开机

[root@ncapp ~]# ethtool eth0
Settings for eth0:
 Supported ports: [ TP ]
 Supported link modes:   10baseT/Half 10baseT/Full 
                         100baseT/Half 100baseT/Full 
                         1000baseT/Full 
 Supported pause frame use: Symmetric
 Supports auto-negotiation: Yes
 Advertised link modes:  10baseT/Half 10baseT/Full 
                         100baseT/Half 100baseT/Full 
                         1000baseT/Full 
 Advertised pause frame use: Symmetric
 Advertised auto-negotiation: Yes
 Speed: 1000Mb/s
 Duplex: Full
 Port: Twisted Pair
 PHYAD: 1
 Transceiver: internal
 Auto-negotiation: on
 MDI-X: Unknown
 Supports Wake-on: pumbg
 Wake-on: g
 Current message level: 0x00000007 (7)
          drv probe link
 Link detected: yes
[root@ncapp ~]#

可以看到,ethtool把网卡的信息全部列出,我们只关心其中的这两项:

Supports Wake-on: pumbg

Wake-on: d

如果 wake-on一项值为d,表示禁用wake on lan;如果值为g,表示启用wake on lan

因为此机器禁用了wake on lan,所以用下面的命令来启用它:

[root@localhost lhd]# ethtool -s eth0 wol g

再用ethtool命令进行查看,会发现:

Wake-on: g

2.得到目标主机的IP地址和MAC地址

[root@ncapp ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 6C:0B:84:70:49:18  
          inet addr:192.168.250.250  Bcast:192.168.250.255  Mask:255.255.255.0
          inet6 addr: fe80::6e0b:84ff:fe70:49f8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:343630181 errors:0 dropped:0 overruns:0 frame:0
          TX packets:419011268 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:161818083144 (150.7 GiB)  TX bytes:166360056862 (154.9 GiB)
          Memory:e6200000-e6240000 

eth1      Link encap:Ethernet  HWaddr 6C:0B:84:70:49:19  
          UP BROADCAST MULTICAST  MTU:1500  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:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Memory:e6240000-e6280000 

eth2      Link encap:Ethernet  HWaddr 6C:0B:84:70:49:1A  
          UP BROADCAST MULTICAST  MTU:1500  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:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Memory:e6280000-e62c0000 

eth3      Link encap:Ethernet  HWaddr 6C:0B:84:70:49:1B  
          UP BROADCAST MULTICAST  MTU:1500  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:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Memory:e62c0000-e6300000 

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:83604072 errors:0 dropped:0 overruns:0 frame:0
          TX packets:83604072 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:50702025521 (47.2 GiB)  TX bytes:50702025521 (47.2 GiB)

usb0      Link encap:Ethernet  HWaddr 02:E0:EC:2D:8C:73  
          inet6 addr: fe80::e0:ecff:fe2d:8c73/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1286873 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:36286166 (34.6 MiB)  TX bytes:258 (258.0 b)

virbr0    Link encap:Ethernet  HWaddr 52:54:00:C0:67:FB  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:2161 (2.1 KiB)  TX bytes:2351 (2.2 KiB)

[root@ncapp ~]#

3.准备好远程开机软件

在局域网中另一台电脑上安装远程开机软件,其下载地址为:

https://www.depicus.com/wake-on-lan/wake-on-lan-cmd

4.远程开机

如要开192.168.150.245这台机器,命令如下:

wolcmd 1c1b0d02e587 192.168.150.245 255.255.255.0 8900

5.Wake On Lan Command Line

这是上面的补充:

1)The command line tool wolcmd is run from a dos prompt. The syntax is as follows:

wolcmd [mac address] [ip address] [subnet mask] [port number]

2)you can also do a local broadcast if you are running on an internal network thus

wolcmd [macaddress] 255.255.255.255 255.255.255.255 4343

where mac address is the unique address of the network card. To find the mac address of a card you can either open the computer and read the address on the sticker on the card or much easier is, if you are using TCP/IP, ping the machine from a dos prompt (ping [machine name or ip number] i.e. ping delphi or ping 10.43.43.43) then issue an arp command (arp -a) which will list the ip number and physical address of the card.

If the port number is not specified it will default to port 7

Running from a batch file

Simply add multiple entries thus:

wolcmd 009027a324fe 195.188.159.20 255.255.255.0 8900 
wolcmd 009024a731da 212.86.64.31 255.255.255.0 8900
posted @ 2023-08-02 15:59  寻梦99  阅读(39)  评论(0)    收藏  举报