linux服务器远程网络开机(wake on lan)

检查服务器是否支持远程网络开机

[root@lab5101 ~]# 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: No
Supports auto-negotiation: Yes
Advertised link modes:
10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 2
Transceiver: internal
Auto-negotiation: onMDI-X: on
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000007 (7)
drv probe linkLink detected: yes

注意这两项:

Supports Wake-on: pumbg
Wake-on: g

可以通过命令设置,也可以去bios中设置
d表示禁用,g表示开启

[root@lab5101 ~]# ethtool -s eth0 wol g

拿到网卡的mac地址

[root@lab5101 ~]# ifconfig 
eth0 Link encap:Ethernet HWaddr 00:30:67:6D:3D:7C
inet addr:192.168.5.101 Bcast:192.168.255.255 Mask:255.255.0.0
inet6 addr: fe80::215:17ff:fed0:be85/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:17752 errors:0 dropped:4 overruns:0 frame:0
TX packets:1101 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1288183 (1.2 MiB) TX bytes:262525 (256.3 KiB)
Interrupt:16 Memory:b1100000-b1120000
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:65536 Metric:1
RX packets:62566 errors:0 dropped:0 overruns:0 frame:0
TX packets:62566 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:91540393 (87.2 MiB) TX bytes:91540393 (87.2 MiB)

得到:

HWaddr 00:15:17:D0:BE:85

在另外一台服务器上执行:

[root@lab901 ~]# ether-wake -i eth0 00:30:67:6d:3d:7c