Knowledge Base
Searching in : Article
ID: AR11R01101
Applies to: NoMachine Software
Added on: 2020-11-26
Last Update: 2024-04-05
Print this article

Using NoMachine's Wake-On-Lan functionality

From version 7 NoMachine software supports Wake-On-Lan (WOL). This means that it is possible to wake up powered-off NoMachine server hosts when the connecting client supports WOL and is on the same local network. (Note that WOL for multi-node environments is planned for a later release.)
 
Wake On Lan works by sending so called “Magic Packets”. A magic packet is a packet sent in the second layer of the ISO/OSI, therefore it is encapsulated only in the Ethernet frame. WOL on its own does not use the IP address of the destination host, it uses its MAC address. NoMachine translates the IP address to the MAC address based on the routing table. The destination of a magic packet is always a broadcast. Inside of the Ethernet frame there are 6 bytes of 255 (0xFF) values, followed by sixteen repetition of the MAC address that you want to wake.
 
To be able to take advantage of NoMachine's WOL feature, certain criteria must be met on the destination computer:

1. the BIOS of the computer or server you want to wake up must support WOL and it must be enabled.
2. The destination computer's operating system must be configured to allow the network interface card to start the computer.
3. If you're using a WiFi, verify that the device/router/network support wireless WOL
 
 
How to set up WOL in your LAN
What follows is an example for NoMachine server on Ubuntu 23.04. Note that instructions can change depending on BIOS, Operating System and OS version.

1. Provide the NoMachine server host with a static IP.
Configure the DHCP Address Reservation in your router for that. In this way the router will always assign the same IP to that device, each time it connects to the network.

2. Use “MAC Binding” in your router to statically associate your server’s internal IP with its MAC Address. This is necessary to ensure that a WOL packet forwarded from the Internet reaches the sleeping server host even after the router reboots, for example because of power interruption.

3. Reboot the router and the NoMachine server host.

4. Enable WOL in the NoMachine server’s host.
Install ethtool (a command line interface to manage network interface devices), if you don't have it already installed. Run in a terminal:

sudo apt-get install ethtool

Then run the following command to list all ip addresses associated on all network interfaces:

ip a

and find the interface, e.g. eth0. Modern Linux distros have a NIC like “enp0s31f6” .

Once you retrieved the interface, run:

sudo ethtool <interface> | grep Wake

e.g.
sudo ethtool eth0 | grep Wake
or
sudo ethtool enp0s31f6 | grep Wake

If output reports:
[...]
Supports Wake-on: g
Wake-on: g

it means that WOL is enabled (d, means instead disabled).

If WOL is disabled, you can enable it permanently in the system configuration.
Run:
sudo --preserve-env systemctl edit --force --full wol-enable.service

It opens an editor. Edit to have:

[Unit]
Description=Enable Wake-up on LAN

[Service]
Type=oneshot
ExecStart=/sbin/ethtool -s <interface> wol g

[Install]
WantedBy=basic.target

Then run:
sudo systemctl daemon-reload  
sudo systemctl enable wol-enable.service 

5. Shut down the NoMachine server host and remove power for some minutes to erase any state in the NIC.

6. Power on and reboot.

7. Run again:  

ethtool <interface> | grep Wake

to verify that WOL is now enabled on the interface.
 


How to test WOL by NoMachine in the same network
From a computer in the same network, edit the NoMachine connection -> Configuration and ensure that option 'Wake up the indicated server on the LAN if powered off' is selected.

Then connect by NoMachine client to the NoMachine server host by using its static IP in order to get the MAC address of the server host, this is necessary for the WOL.

Then put the NoMachine server host to sleep and connect again from the client: it should wake up the server host.


How to test WOL over the internet by using a WOL utility
At the moment, NoMachine doesn't support WOL outside the same network (like over the Internet), since it doesn't implement the magic packet allowing for that.

Install a WOL utility on your client machine to send WOL packets over the Internet to turn on the remote computer.

On the remote computer (e.g. the NoMachine server host), run in a terminal:

 sudo tcpdump -v -UlnXi <interface> udp port 9
 
Wake-On-Lan over internet uses by default UDP port 9 to send the WOL magic packet to wake up the remote host (any port number may be used by the WOL utility on the Internet provided your router forwards that port to port 9 on your LAN.)

Each time a packet is sent to port 9, command above will display the content as hexadecimal dump of the packet.
 
If that works, put your server host to sleep.

Send the magic packet by the WOL utility on your client computer and check if the server host wakes up when you send the WOL packet.

If the server host wakes up, you can now connect to it by NoMachine.

To connect by NoMachine over the internet, be sure that port forwarding is enabled in the router. You can let NoMachine doing that automatically or you can configure it in the router. See https://kb.nomachine.com/AR04S01122