6

I have a Ubuntu server (16.10) at home and was wondering if there is a way to turn it on remotely when I am away from home?

I set up Wake-On-LAN but that only seems to work when I'm using another computer connected to the same network as my Ubuntu server.

Any ideas on getting WOL working remotely?

  • Does your home router have a WOL proxy? – Stephen Kitt Apr 4 '17 at 7:35
10

First, the fact that your computer is running Ubuntu when powered on is unrelated to Wake-on-LAN (WOL) functionality.

Second, WOL uses Ethernet frames with a particular format.

Third, Ethernet frames are not routed outside of the local network segment. In the case of the Internet, intermediate networks might not even use Ethernet at all.

The consequence of the second and third points is that, in order to send a WOL request to a computer on a network, you need to do so from another system on the local network segment. It is not possible to directly issue WOL requests over the Internet.

Of course, you can do something like what CyberFonic suggests and have a small, low-power system on the local network segment that you can use to issue a WOL request. But in that case, the WOL request is really issued by another system on the local network segment; you just happen to access that system over the Internet.

  • 2
    Some home routers have WOL functionality, either by adding a WOL if a request is done to a specific machine, or with some other way (API or web-interface to router, note: independent to admin interface) – Giacomo Catenazzi Apr 4 '17 at 12:54
  • Can a router have WOL? that would be ideal as thats always on and low powered – jonneymendoza Apr 4 '17 at 13:17
  • 1
    @jonneymendoza: yes. Whether the capability is present on a stock off-the-shelf router is another question, but usually you can flash a third-party image and go back to stock without issues. Did it all the time with my WRT-54GLs and my current E4200, running DD-WRT, a third-party firmware for Linksys and other routers. Here, for example, is the DD-WRT walkthrough for WOL: dd-wrt.com/wiki/index.php/WOL – flith Apr 4 '17 at 13:21
  • "home routers [with] WOL functionality" is a subset of "another system on the local network segment with WOL functionality". – a CVn Apr 4 '17 at 13:24
  • the use of Ubuntu is important. Under Windows that feature of my networking card was turned off by default. – Ciprian Tomoiagă Apr 4 '17 at 13:47
8

I'm in a similar situation to you. Using Ubuntu 16.04 LTS as a web server.

The server and a Raspberry Pi are both connected to the router via ethernet cable.

The RPi is running continuously. I have installed and configured fail2ban for extra security. The router is configured to allow SSH access from the internet to the RPi. When I want to start my power hungry IBM server. I SSH connect (mosh actually) to the RPi and run the following Python program:

""" Send a WoL packet to the specified MAC address
    NB: Won't work on OS/X.  The AF_PACKET is specific to Linux.
        Needs to be run with sudo.
"""
import socket

PREAMBLE = bytearray((0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF))

# Need to configure the following for the correct MAC of the target
MAC = bytearray((0x00, 0x14, 0x85, 0xa1, 0x43, 0xde))

pkt = PREAMBLE + 16*MAC
sock = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)

# Configure the correct interface name
sock.bind(('enp2s1', 0))

sock.sendall(pkt)
sock.close()

If you don't have a static IP address, then you probably need to configure dynDNS or something similar and your domain addresses.

  • 3
    Also apt-get install wakeonlan – roaima Apr 4 '17 at 9:47
  • I think i will go with this route and buy myself a raspberry pi. which one do you have as they have a standard version and a Zero version? – jonneymendoza Apr 5 '17 at 8:42
  • I used a first gen. Model B. You need eNet - so the Zero wouldn't be suitable. – CyberFonic Apr 5 '17 at 10:35
  • which OS did u use? – jonneymendoza Apr 9 '17 at 13:42
  • Just standard Raspbian. I prefer Debian based OS since I'm comfortable using APT. But you could use any OS that supports CPython and Unix style AF_PACKET. Check the Python docs for more details on socket module. – CyberFonic Apr 11 '17 at 4:46
-1

For WOL you could use port forwarding to another device on your network, various media players have this feature as a web accessible option.

You can also try wake on ring, or an IP powerboard after rigging bios to boot when AC power is applied. There are a number of Android/iOS apps that drive proprietary power points for this.

If it is a major brand server, there may be an out of band option (extra Ethernet port and daughterboard) you can purchase and fit. Higher end KVM over IP may support remote boot. There are a few options.

To clarify this, for a number of years I have been using an IP-Power 9258 powerboards, and these are useful, although I have not always been happy. They can be controlled with curl(1) (from script or a PHP dashboard). To get to it you are going to have to RDP/VNC in to an always-on workstation (lattepanda, say), run a low spec box webserver(Pi) on port 8081 say, or connect via VPN client. If you go this way, you need to be able to deal with or suppress grub hanging (waiting for keyboard) after an "incident". But it has the advantage of being able to cycle the power if everything else has failed. It is very common to go behind NAT to get things done.

  • 1
    Can you port-forward WOL packets? – roaima Apr 4 '17 at 8:46
  • 2
    @roaima No, because WOL frames are not TCP or UDP so have no concept of ports. – a CVn Apr 4 '17 at 9:25
  • @MichaelKjörling that's what I'd thought, but the first part of this answer threw me. – roaima Apr 4 '17 at 9:33
  • You are not port forwarding the WOL packets, you are port forwarding to the server on the device that will send the WOL packets. You need that device to be always on. – mckenzm Apr 5 '17 at 5:35
  • If you read the specs, any UDP or TCP packet could be used as long as it has the critical WoL payload, see en.wikipedia.org/wiki/Wake-on-LAN. So if your router can be configured to port-forward to a specific MAC then it should (in theory) work. – CyberFonic Apr 11 '17 at 4:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.