First, your network card supports the network wake-up function. Of course, most network cards now support the Network wake-up function. Check whether your network card supports the wake-up function. You only need to execute the ethtool command on the machine that is remotely started, run the following command to check whether the machine Nic supports the wake-up function: $ sudoetht
First, your network card supports the network wake-up function. Of course, most network cards now support the Network wake-up function. Check whether your network card supports the network wake-up function. You only need to execute ethtool on the machine that is remotely started.CommandTo check whether the machine Nic supports the wake-up function, run the following command (the following operation is performed on the remote host ):
$SuDo ethtool eth0
Settings for eth0:
SupportEdPorts: [tp mii]
Supported link modes: 10 baseT/Half 10 baseT/Full
100 baseT/Half 100 baseT/Full
Supports auto-negotiation: Yes
AdvertiSedLink modes: 10 baseT/Half 10 baseT/Full
100 baseT/Half 100 baseT/Full
Advertised auto-negotiation: Yes
Speed: 100 Mb/s
DuplEx: Full
Port: MII
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: g [prompt: g indicates it has been started. d indicates it is disabled]
Current message level: 0x00000001 (1)
Link detected: yes
If the wake-up function is disabled, run the following command to activate the wake-up function:
$ Sudo ethtool-s eth0 wol g
Obtain the physical address of the remote machine NIC:
$Ifconfig
Eth0 Link eNcAp: Ethernet HWaDdR 00: 16: k5: 64: A9: 68 [Mac address]
Inet addr: 192.168.6.56 Bcast: 192.168.6.255 Mask: 255.255.255.0
54com.cn
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
Write down the MAC address of the NIC.
Install the wake-up software on the local host:
$ Sudo apt-get install wakeonlan
Run the following command to enable remote boot:
$ Wakeonlan 00: 16: k5: 64: A9: 68
Note: The experiment shows that once the host to be remotely started is disabled, the wol setting of the NIC will be restored to d, so how can we activate the wol settings of the NIC when the host is shut down? In Ubuntu, I implement the following methods:
First, write a small script and enter the command:
$ Sudo nano sd
Enter the following content in the text file:
/Usr/sbin/ethtool-s eth0 wol g
Shutdown-h now
Next, press CTRL + O, and then press CTRL + X to save.
Run the following command to perform file operations:
$Chmod755 sd
Then, copy it to the/sbin folder.
$ SudoMvSd/sbin
In this way, you can directly enter sudo sd in the command line to shut down the device. If you are pursuing perfection like me, you can use the following command to change the sd file to the root Name:
$ SudoChownRoot: root/sbin/sd
To remotely start a remote server on a local host, enter the following command: wakeonlan 00: 16: k5: 64: A9: 68, you can perform the following operations on the local host: (the following operations are performed on the local host)
Create a new text file named wakeupcomputer In the desktop environment
Enter the following content in the text:
Wakeonlan 00: 16: k5: 64: A9: 68
Save and exit.
Perform file-executable operations:
$ Chmod 755 wakeupcomputer
Move it to the/usr/local/bin folder.
$ Sudo mv wakeupcomputer/usr/local/bin
(If you are happy, you can also use the following command to change the wakeupcomputer file to the root Name:
$ Sudo chown root: root/usr/local/bin/wakeupcomputer
)
Now, if the remote host is not started, enter the following command in the local host command line:
$ Wakeupcomputer
To automatically remotely start the remote host.