BigJeffIE
Posts: 26
Joined: Fri May 11, 2012 7:55 pm

Raspberry Pi always on

Tue May 29, 2012 12:26 pm

Hi folks,

As the Raspberry Pi is such a passive machine compared to a PC I'd like to be able to send Wake On Lan packets from it to the other PC's on my network. I see on the forums plenty of people wanting to have the Pi wake up from a request but nothing about the Pi sending out requests to other networked machines.

I hate leaving pc's running at home for environmental/cost reasons but when I need to switch one on remotely I have to txt my wife and ask her to switch one on. My time is running out as she's getting more fed up with every request that goes her way :)

So I'd like to leave my Pi on all the time and have one of it's functions to WOL my other networked pc's when I need them. Thus saving the planet and my marriage from unnecessary stress!

At the moment I use logmein which is great but there's no Linux client available. I tried installing their beta Hamachi but it doesn't seem to be the same thing as the normal logmein website gui.

I'm a little confused by VNC. If I had it set up on the Pi and the Pi was powered up, can I get to it across the internet if I don't have a fixed IP address?

Ideally I'd like my android phone to be able to do the remote clienting, as I'd be at work most of the time and wouldn't be able to install software on my work PC unless it was just through a website.

If anyone knows of a website detailing how it can be done or someone can give me a few pointers that'd be great. My linux skills aren't great so go easy on me :)

Thanks and I hope you're all having a great time with your Pi's...

bredman
Posts: 1415
Joined: Tue Jan 17, 2012 2:38 pm

Re: Raspberry Pi always on

Tue May 29, 2012 12:37 pm

There are several problems, but they can all be dealt with...

1. How to reach your house? I assume that you are assigned a dynamic IP address. This means that you cannot just use an IP address to reach your house. You can use a free service such as no-ip.com to reach your house without needing the IP address.

2. How to reach your RPi? Once you can reach your house, you cannot just contact your RPi. Your router probably uses NAT (Network Address Translation) to hide all of your devices behind a single IP address. You need to open the configuration tool for your router to forward a port such as port 80 to the RPi.

3. How to get past the router security? You router will probably try to stop the outside world reaching the RPi. You need to open the configuration tool for your router to allow HTTP(80) to the RPi.

4. Which IP address for the RPi? To configure the router, you need to know the IP address of the RPi. You can set a static DHCP address in the router configuration tool.

5. How to execute something on the RPi? You need to have something listening to port 80 on the RPi. I suggest a lightweight web server such as lighthttpd, or anything else you prefer. You then need a CGI BIN web page to actually execute sending the wakeup signal.

Easy, wasn't it?

User avatar
rpdom
Posts: 17164
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Raspberry Pi always on

Tue May 29, 2012 12:48 pm

I use "wakeonlan" (available as a Debian package, probably for the other Linuxes too).

sudo apt-get install wakeonlan
wakeonlam AA:BB:CC:DD:EE:FF

(Where AA:BB:CC:DD:EE:FF is the MAC address of the network adaptor on the PC).

The wakonlan man page will tell you more about setting it up, but I just did those two steps and it worked first time with a PC that was WOL set.

I can access my network remotely from my ancient WinMobile phone, using PocketPuTTY to conect via ssh. My router is set to allow incoming on port 22 and direct it to a specific machine. I've got otpw (One Time PassWord) installed on that machine and a list of randomly generated passwords that it can ask me for, plus a fixed prefix code that I don't write down.
Unreadable squiggle

tech_monkey
Posts: 130
Joined: Fri Mar 09, 2012 6:12 pm

Re: Raspberry Pi always on

Tue May 29, 2012 2:31 pm

another way to switch a pc on remotely is to use a network connected relay.
As long as you can access to relay box via the internet you can then login to it, point to the relay you want on and it does the rest.
AVIOSYS make some interesting products that might be what you are after. http://www.aviosys.com/ippower.html
The other way is a GSM operated relay. So you just text it and it switches on. There are GSM gate openers which you could use with a suitable relay as well.
http://www.casatech.eu

User avatar
depicus
Posts: 2
Joined: Tue May 29, 2012 7:43 pm
Contact: Website

Re: Raspberry Pi always on

Tue May 29, 2012 10:18 pm

Just put this in a thread but http://blog.depicus.com/index.php/2012/ ... forwarder/ should help :D

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: Raspberry Pi always on

Wed May 30, 2012 5:40 pm

I had exactly the same thought so I've written a small C program to act as a Wake On Lan Relay. It uses a config file to hold a number of MAC addresses which it is authorised to send a WOL packet to. All you have to do then is set up port forwarding on the router to forward the WOL packet to the PI and it will waken the requested PC.

I've tested it on a Pi that I've just recently received and it works well.

I intend to modify it slightly, when I get time, to document it and write a small init.d script to start it.
However if you would like the source in the meantime just PM me and I'll send you a copy.

Roughnecks
Posts: 22
Joined: Sun Jun 03, 2012 11:47 am

Re: Raspberry Pi always on

Sun Jun 03, 2012 1:23 pm

Hi,

I use cherrypy to offer a webservice and use my pi to wake my NAS-Box from the internet, too :)
Here's the quick&dirty python script that i use:

Code: Select all

#!/usr/bin/env python
# encoding: utf-8

import sys
import os
import cherrypy
from cherrypy import expose

class SecureServer:
    @expose
    def index(self):
	pingStr = "ping 192.168.1.55 -c 1"
	s = os.popen(pingStr).read()
	return "Hi from Pi! " + str("1 received" in s) + " [use /wol to wake]"
    @expose
    def wol(self):
	os.system('wakeonlan 00:25:22:f7:18:54')
	return "magic packet sent"

if __name__ == '__main__':
    users = {"username": "password"}
    conf = {'/': {'tools.digest_auth.on': True,
            'tools.digest_auth.realm': 'Some site',
            'tools.digest_auth.users': users}}
    cherrypy.config.update({
        'server.socket_port': 80,
        'server.socket_host': '0.0.0.0'})
    cherrypy.config.update({'engine.autoreload_on':False})
    cherrypy.quickstart( SecureServer(), '/', config=conf)
    

A few quick notes:
connect to your pi on port 80: "http://[ip of rpi]/"
You will see True or False depending wether the ping to your computer was answered or not.
You can change the IP address of the computer to check in the "pingStr" variable.
if you connect to your pi on port 80 with "http://[ip of rpi]/wol" the wakeonlan programm will be used to send a magic packet to the computer you want to start. you have to change MAC address accordingly, of course.
if you get an error that port 80 cannot be used, try a higher port (above 1024) or start the script with sudo.

You need to install cherrypy and wakeonlan via apt:

Code: Select all

 sudo apt-get install python-cherrypy3 wakeonlan
Greetings,
- Ben

adlambert

Re: Raspberry Pi always on

Mon Jun 04, 2012 7:44 am

I find the dynamic IP address is not a problem, I had the same ip address for several years on cable broadband, and it only changed when my cable modem was upgraded to a Docsis3 one.

If you set up port forwarding for port 22 on your router (and remove the default username, create a new one with a stronger password) then you can get an ssh client for Android and have your PI command line. Then you could just ping the pc you want on?

BigJeffIE
Posts: 26
Joined: Fri May 11, 2012 7:55 pm

Re: Raspberry Pi always on

Tue Jun 05, 2012 8:09 am

Thanks for all the info :)

I'll have a play around and see what I can get working.

broo0ose
Posts: 318
Joined: Wed Dec 14, 2011 3:59 pm
Location: Wirral, UK

Re: Raspberry Pi always on

Tue Jun 05, 2012 9:13 pm

Taking a different approach, I'm thinking you could get your RaspberryPi to monitor a service like twitter. When it reads a certain command it sends out a WoL on your local network.

Or maybe you could use a service like ifttt.com or pushingbox.com

Using this approach gets round all the security/IP address issues.

User avatar
SN
Posts: 1014
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
Contact: Website

Re: Raspberry Pi always on

Tue Jun 05, 2012 9:22 pm

This is exactly how HP's eprint service works
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?

broo0ose
Posts: 318
Joined: Wed Dec 14, 2011 3:59 pm
Location: Wirral, UK

Re: Raspberry Pi always on

Tue Jun 05, 2012 9:31 pm

SN wrote:This is exactly how HP's eprint service works
Damn they were quick, I did not get a change to patent it.

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: Raspberry Pi always on

Wed Jun 06, 2012 7:15 am

I've just posted details of a Wake on LAN Relay daemon that I've written for the Pi. Details can be found here:

http://www.raspberrypi.org/phpBB3/viewt ... =36&t=7613

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Raspberry Pi always on

Wed Jun 06, 2012 7:39 am

broo0ose wrote:
SN wrote:This is exactly how HP's eprint service works
Damn they were quick, I did not get a change to patent it.
No. But they probably did ;-)

broo0ose
Posts: 318
Joined: Wed Dec 14, 2011 3:59 pm
Location: Wirral, UK

Re: Raspberry Pi always on

Wed Jun 06, 2012 9:30 am

rurwin wrote:
broo0ose wrote:
SN wrote:This is exactly how HP's eprint service works
Damn they were quick, I did not get a change to patent it.
No. But they probably did ;-)
It is also the way most bot infected zombie PCs phone home. So it is a robust model. ;)

alexjj
Posts: 15
Joined: Sun Feb 05, 2012 11:42 am
Contact: Website

Re: Raspberry Pi always on

Wed Jun 06, 2012 9:39 am

I have used this script from xbmc wiki site. I use the debian image so this all works fine.

I have dyndns setup and port forwarding on my router and I ssh using putty to pi from work. I type "wake-on-lan PC" then switch to logmein to control my windows computer at home.

It's great! Requires your motherboard to support WOL but I think all fairly modern ones do.

Return to “Networking and servers”