Will WOL support be added to the companion app?

Discuss My Media Center for Windows 8, Windows RT, iOS, Android, and WP, and ask Ceton for support.
Forum rules
Ceton no longer participate in this forum. There is no official support mechanism for My Media Center.
foxwood

Posts: 1761
Joined: Fri Sep 07, 2012 3:43 pm
Location:

HTPC Specs: Show details

#21

Post by foxwood » Wed Dec 05, 2012 6:18 pm

barnabas1969 wrote:
foxwood wrote:And WoL will only work on the LAN - if you're connecting from outside, you'll have to trigger something on your LAN to send the WoL packet anyway - that's where DD-WRT comes in.
That's not correct. .... If your router has a setting to allow broadcast packets, then you can use that (though it's not recommended). In DD-WRT, you can setup an internal IP address that doesn't really belong to any devices on the network. I used 192.168.1.254. Then, you simply define that pseudo machine with a MAC address of FF:FF:FF:FF:FF:FF. Finally, you open a port, and direct it to the fake IP address. This will cause any traffic that is directed to that particular WAN port to be broadcast on your LAN.
In other words, you are triggering something on your LAN (your router is on your LAN) to send the WoL packet.

barnabas1969

Posts: 5738
Joined: Tue Jun 21, 2011 7:23 pm
Location: Titusville, Florida, USA

HTPC Specs: Show details

#22

Post by barnabas1969 » Wed Dec 05, 2012 6:46 pm

foxwood wrote:
barnabas1969 wrote:
foxwood wrote:And WoL will only work on the LAN - if you're connecting from outside, you'll have to trigger something on your LAN to send the WoL packet anyway - that's where DD-WRT comes in.
That's not correct. .... If your router has a setting to allow broadcast packets, then you can use that (though it's not recommended). In DD-WRT, you can setup an internal IP address that doesn't really belong to any devices on the network. I used 192.168.1.254. Then, you simply define that pseudo machine with a MAC address of FF:FF:FF:FF:FF:FF. Finally, you open a port, and direct it to the fake IP address. This will cause any traffic that is directed to that particular WAN port to be broadcast on your LAN.
In other words, you are triggering something on your LAN (your router is on your LAN) to send the WoL packet.
No, my router is forwarding a packet that comes in from an external port. Let's say I'm forwarding external port 12345. When the router receives something on WAN port 12345, it forwards it to LAN IP address 192.168.1.254, which the router believes has a MAC address of FF:FF:FF:FF:FF:FF. When a packet gets sent on the LAN using this MAC address (the broadcast address) it gets sent to EVERY device on the network (because FF:FF:FF:FF:FF:FF is in the packet header). When this packet is a "magic packet", then the packet contains the MAC address of the machine to be awakened (in the packet data, in a very specific location, with a very specific format... this is what makes it a "magic" packet)... and that machine will wake from sleep.
Last edited by barnabas1969 on Wed Dec 05, 2012 8:04 pm, edited 6 times in total.

barnabas1969

Posts: 5738
Joined: Tue Jun 21, 2011 7:23 pm
Location: Titusville, Florida, USA

HTPC Specs: Show details

#23

Post by barnabas1969 » Wed Dec 05, 2012 6:55 pm

Here's how to setup WOL from the WAN, using DD-WRT on your router...

First, put the following commands into the "Startup" window on the Administration -> Commands tab:

Code: Select all

#! /bin/sh
#
# Sets permanent route for WOL:
ip neigh change 192.168.1.254 lladdr ff:ff:ff:ff:ff:ff nud permanent dev br0
ip neigh add 192.168.1.254 lladdr ff:ff:ff:ff:ff:ff nud permanent dev br0
Next, forward a WAN port of your choice, to LAN port 7. You do this on the "NAT/QOS" -> "Port Forwarding" tab.
  • In the "Application" column, enter a description that makes sense to you, like "WOL".
  • In the "Port From" column, enter your chosen external port number.
  • In the "Protocol" column, choose TCP
  • In the "IP address" column, enter 192.168.1.254 (the same one that is used in the "ip neigh" commands above)
  • In the "Port to" column, enter 7 (This is typically what is used for WOL, though if your NIC's manufacturer followed the standards, the port number doesn't matter. But you definitely don't want to use a port number that might expose one of your internal devices to attack. Port 7 should be pretty safe.)
  • Check the box in the "Enable" column
  • Click "Save"
  • Click "Apply settings"
  • Reboot your router
This will allow anyone on the Internet to wake any PC on your network, provided that they know the MAC address of the PC... and they send a "magic packet" to your chosen external port number.

EDIT: And you'll also need to reboot your router!
Last edited by barnabas1969 on Wed Dec 05, 2012 7:18 pm, edited 4 times in total.

barnabas1969

Posts: 5738
Joined: Tue Jun 21, 2011 7:23 pm
Location: Titusville, Florida, USA

HTPC Specs: Show details

#24

Post by barnabas1969 » Wed Dec 05, 2012 7:11 pm

Now, if you want to take it a step further, and allow your Companion app to wake your PC from anywhere, do the following (this works only with DD-WRT):

First, setup your companion app's "Internal" and "External" IP addresses and port numbers to be the same. Use the external port of your choice. It could be the same port number as your internal port number (5832 by default), or you can choose something at random. (This is the "from port" in your router's port forward settings).

Next, setup your router to forward your chosen port to your Media Center PC. It's best to set your Media Center PC to a static IP address, or to set a static lease in the router's DHCP server. (set the "to port" to whatever port you chose when you setup the Companion Services on your PC).

Finally, add the following script to the "Startup" window in the Administration -> Commands tab (you can append this to the WOL stuff I mentioned earlier if you like):

Code: Select all

#! /bin/sh
#

# External port for MCPC1:
MCPC1_XPORT=54321
# Internal port for MCPC1:
MCPC1_IPORT=5832
# Internal IP address for MCPC1: 
# Make sure to put a back-slash before each period, and surround this string with single quotes!
MCPC1_IPA='192\.168\.1\.123'
# MAC address for MCPC1:
# Make sure to surround this with single quotes!
MCPC1_MAC='AA:BB:CC:DD:EE:FF'

while sleep 5 ; do  #Wait 4 seconds, then loop.
  if [ `egrep -c tcp.+SYN_SENT.+dport=$MCPC1_XPORT.+UNREPLIED.+src=$MCPC1_IPA.+sport=$MCPC1_IPORT /proc/net/ip_conntrack` -gt 0 ] ; then
    /usr/sbin/wol -i 192.168.1.255 -p 7 $MCPC1_MAC  #Send WOL to the MCE machine.
    cat /proc/net/ip_conntrack_flush >/dev/null  #Flush the ip_conntrack table.
  fi
  #Finish the loop with a redirect to throw away output and put this in the background.
done >/dev/null &
Click Save.
Click Apply.
Reboot your router.

Obviously, you'll need to change the values for the variables at the beginning of the script.

This will work if you have a single Media Center PC. My next post will describe the settings that will be needed for multiple Media Center PC's.
Last edited by barnabas1969 on Wed Dec 05, 2012 8:10 pm, edited 2 times in total.

barnabas1969

Posts: 5738
Joined: Tue Jun 21, 2011 7:23 pm
Location: Titusville, Florida, USA

HTPC Specs: Show details

#25

Post by barnabas1969 » Wed Dec 05, 2012 7:45 pm

OK, so what if you have more than one Media Center PC that you want to be able to wake with your Companion app from the Internet (aka WAN, e.g. outside your house)?

Here goes...

Setup your companion app's internal/external IP addresses as described above for each of your Media Center PC's (MCPC). I recommend using a free DNS service like no-ip.org, but you could use your external IP address... just be aware that it may change from time to time.

Then, when it comes to external port numbers, you'll need to choose a different external port number for each of your Media Center PC's. Let's say you chose 51001 for your first MCPC. You could then choose 51002 for the 2nd MCPC, 51003 for the 3rd, and so-on.

You'll need to forward each of those external port numbers to a different PC. For example, you could forward...

51001 to 192.168.1.201
51002 to 192.168.1.202
51003 to 192.168.1.203
and so-on.

Now, in case this wasn't clear in my preceding post, the actual internal port number that your Ceton Companion Services is listening on could still be set to 5832 on ALL of your MCPC's. You'll simply forward the EXTERNAL port number (each must be different) to the INTERNAL port number ((these can all be the same 5832 or different (51001,51002,etc), it's your choice)). But the Companion app on your phone needs to point to the EXTERNAL IP address AND port number for each of your MCPC's. OK?

Using the examples above, you would configure the Companion app on your phone as follows:

MCPC1:
IP: <your_WAN_IP>, PORT: 51001 (do this for both the Internal and External fields in the settings of the Companion app)

MCPC2:
IP: <your_WAN_IP>, PORT: 51002 (same deal)

etc...

Now, add the following script to the "Startup" window in the Administration -> Commands tab (you can append this to the WOL stuff I mentioned in post #23 above if you like, and this replaces post #24 above that only has ONE MCPC):

Code: Select all

#! /bin/sh
#

# External port for MCPC1:
MCPC1_XPORT=51001
# Internal port for MCPC1:
MCPC1_IPORT=5832
# Internal IP address for MCPC1: 
# Make sure to put a back-slash before each period, and surround this string with single quotes!
MCPC1_IPA='192\.168\.1\.201'
# MAC address for MCPC1:
# Make sure to surround this with single quotes!
MCPC1_MAC='AA:BB:CC:DD:EE:01'

# External port for MCPC2:
MCPC2_XPORT=51002
# Internal port for MCPC2:
MCPC2_IPORT=5832
# Internal IP address for MCPC2: 
# Make sure to put a back-slash before each period, and surround this string with single quotes!
MCPC2_IPA='192\.168\.1\.202'
# MAC address for MCPC2:
# Make sure to surround this with single quotes!
MCPC2_MAC='AA:BB:CC:DD:EE:02'

# External port for MCPC3:
MCPC3_XPORT=51003
# Internal port for MCPC3:
MCPC3_IPORT=5832
# Internal IP address for MCPC3: 
# Make sure to put a back-slash before each period, and surround this string with single quotes!
MCPC3_IPA='192\.168\.1\.203'
# MAC address for MCPC3:
# Make sure to surround this with single quotes!
MCPC3_MAC='AA:BB:CC:DD:EE:03'

###  Duplicate each block of variables above for each additional MCPC.
###  Or, remove the 3rd one if you only have two!

while sleep 5 ; do  #Wait 4 seconds, then loop.
  # Begin the if statement.  Remember, it needs to begin with "if",
  # end with "fi", and can have any number of "elif" statements in the middle!
  # MCPC1:
  if [ `egrep -c tcp.+SYN_SENT.+dport=$MCPC1_XPORT.+UNREPLIED.+src=$MCPC1_IPA.+sport=$MCPC1_IPORT /proc/net/ip_conntrack` -gt 0 ] ; then
    /usr/sbin/wol -i 192.168.1.255 -p 7 $MCPC1_MAC  #Send WOL to the MCE machine.
    cat /proc/net/ip_conntrack_flush >/dev/null  #Flush the ip_conntrack table.
  # MCPC2:
  elif [ `egrep -c tcp.+SYN_SENT.+dport=$MCPC2_XPORT.+UNREPLIED.+src=$MCPC2_IPA.+sport=$MCPC2_IPORT /proc/net/ip_conntrack` -gt 0 ] ; then
    /usr/sbin/wol -i 192.168.1.255 -p 7 $MCPC2_MAC  #Send WOL to the MCE machine.
    cat /proc/net/ip_conntrack_flush >/dev/null  #Flush the ip_conntrack table.
  # MCPC3:
  elif [ `egrep -c tcp.+SYN_SENT.+dport=$MCPC3_XPORT.+UNREPLIED.+src=$MCPC3_IPA.+sport=$MCPC3_IPORT /proc/net/ip_conntrack` -gt 0 ] ; then
    /usr/sbin/wol -i 192.168.1.255 -p 7 $MCPC3_MAC  #Send WOL to the MCE machine.
    cat /proc/net/ip_conntrack_flush >/dev/null  #Flush the ip_conntrack table.
  fi
  # Add (or remove) "elif" sections above, depending on how many MCPC's you have.
  #
  #Finish the loop with a redirect to throw away output and put this in the background.
done >/dev/null &
Click Save.
Click Apply.
Reboot your router.

Obviously, you'll need to change the values for the variables at the beginning of the script.

This will work if you have three Media Center PC's. You can modify it to match the number of Media Center PC's you desire.

Have fun!

barnabas1969

Posts: 5738
Joined: Tue Jun 21, 2011 7:23 pm
Location: Titusville, Florida, USA

HTPC Specs: Show details

#26

Post by barnabas1969 » Wed Dec 05, 2012 8:31 pm

I made a few corrections to my posts above.

black88mx6

Posts: 11
Joined: Wed Nov 28, 2012 6:05 pm
Location:

HTPC Specs: Show details

#27

Post by black88mx6 » Thu Dec 06, 2012 8:46 pm

In my case, I am not trying to use WOL from outside my network. If I need to do that I have a VPN setup. I need it to work correctly from my local LAN.

I would like the companion app request to "trigger" the WOL of the media center. Since this is not built into the app yet, we would need another device to do this for us. Some are using DD-WRT for doing this from an external connection, and this looks to work well. If I was to use DD-WRT do to this, I would need to to listed to a IP/port request from the LAN, and then the DD-WRT would send the WOL packet on to the media center. In essence the DD-WRT would work as a WOL "proxy". I have not seen this done before, as I am not sure that DD-WRT is inspecting local LAN traffic in a way that it could do this. Admittedly I have not done much research, so it may be easy. Why not just use another app to wake up the server... sure, but WAF factor here makes this cumbersome.

barnabas1969

Posts: 5738
Joined: Tue Jun 21, 2011 7:23 pm
Location: Titusville, Florida, USA

HTPC Specs: Show details

#28

Post by barnabas1969 » Thu Dec 06, 2012 9:13 pm

black88mx6 wrote:In my case, I am not trying to use WOL from outside my network. If I need to do that I have a VPN setup. I need it to work correctly from my local LAN.

I would like the companion app request to "trigger" the WOL of the media center. Since this is not built into the app yet, we would need another device to do this for us. Some are using DD-WRT for doing this from an external connection, and this looks to work well. If I was to use DD-WRT do to this, I would need to to listed to a IP/port request from the LAN, and then the DD-WRT would send the WOL packet on to the media center. In essence the DD-WRT would work as a WOL "proxy". I have not seen this done before, as I am not sure that DD-WRT is inspecting local LAN traffic in a way that it could do this. Admittedly I have not done much research, so it may be easy. Why not just use another app to wake up the server... sure, but WAF factor here makes this cumbersome.
Over VPN is an entirely different animal. You need to make sure that your VPN software will support it, in addition to any firewalls between your VPN and the Media Center PC... and routing tables can affect it too.

You need to describe your VPN setup in more detail before anyone can help you. What VPN software are you using? Is someone else (besides you) in control of what can be passed through the VPN software? Does the VPN pass through multiple networks? If so, please describe. Any firewalls in those networks? Please describe. What about routers in those networks?

barnabas1969

Posts: 5738
Joined: Tue Jun 21, 2011 7:23 pm
Location: Titusville, Florida, USA

HTPC Specs: Show details

#29

Post by barnabas1969 » Fri Dec 07, 2012 1:34 pm

@black88mx6: I guess I didn't read your post very well. The setup I described above will work from inside AND outside your LAN. It works for me. That's the reason for setting the internal/external addresses in the Companion app's settings so that BOTH are pointing to the external IP address of your router. Even when you're inside your LAN, you can still connect to the router's WAN port. This causes the script I wrote above to detect the connection and send the WOL.

milli260876

Posts: 726
Joined: Wed Jun 08, 2011 2:56 pm
Location: Barnsley Sth Yorks

HTPC Specs: Show details

#30

Post by milli260876 » Sat Dec 08, 2012 9:35 pm

@barnabas U ought to develop a wake your pc "app" for w8....
I'm waiting for open wrt to work on my hacked bt home hub!
Lee

barnabas1969

Posts: 5738
Joined: Tue Jun 21, 2011 7:23 pm
Location: Titusville, Florida, USA

HTPC Specs: Show details

#31

Post by barnabas1969 » Sat Dec 08, 2012 9:48 pm

milli260876 wrote:@barnabas U ought to develop a wake your pc "app" for w8....
I'm waiting for open wrt to work on my hacked bt home hub!
Something like that would require an always-on PC on your network... and it's already been done (at least for WinXP). You can't make an app run on a sleeping PC... it's asleep! Your router is basically an always-on computer. If it is compatible with DD-WRT, you can take my instructions and use them as-is. If you're using Tomato on your router, there are probably ways to do it on Tomato too, but the procedure and/or commands will probably be slightly different.

If your BT Home Hub is already hacked, what software is it running?

milli260876

Posts: 726
Joined: Wed Jun 08, 2011 2:56 pm
Location: Barnsley Sth Yorks

HTPC Specs: Show details

#32

Post by milli260876 » Sat Dec 08, 2012 10:26 pm

Its a firmware hack to allow use with other networks. Open wrt is in development for the by home hub at psidoc but it seems to be VERY slow moving....
Lee

milli260876

Posts: 726
Joined: Wed Jun 08, 2011 2:56 pm
Location: Barnsley Sth Yorks

HTPC Specs: Show details

#33

Post by milli260876 » Sat Dec 08, 2012 10:29 pm

Could you use a low power (raspberry pi) as the always on to trigger wake on lan?
Lee

barnabas1969

Posts: 5738
Joined: Tue Jun 21, 2011 7:23 pm
Location: Titusville, Florida, USA

HTPC Specs: Show details

#34

Post by barnabas1969 » Sun Dec 09, 2012 4:18 pm

milli260876 wrote:Could you use a low power (raspberry pi) as the always on to trigger wake on lan?
As long as the device (the Raspberry Pi, in this case) is located somewhere on the network so that it will detect the network connection between your smart phone and the HTPC, then yes.

The problem then becomes how do you get the network traffic to the Pi. If you have a managed switch, or an old fashioned network hub, you could direct all traffic to the port where the Pi is connected.

foxwood

Posts: 1761
Joined: Fri Sep 07, 2012 3:43 pm
Location:

HTPC Specs: Show details

#35

Post by foxwood » Sun Dec 09, 2012 8:17 pm

Maplin currently has the TP-Link TL-WR740N for £24.99 with free UK delivery.

According to the DD-WRT wiki, it's a supported device (even though it's not listed in the DD-WRT Router database, which seems to be patchy, at best).

That's probably cheaper and less hassle than using a Pi to get WoL working. :)

milli260876

Posts: 726
Joined: Wed Jun 08, 2011 2:56 pm
Location: Barnsley Sth Yorks

HTPC Specs: Show details

#36

Post by milli260876 » Mon Dec 10, 2012 2:20 pm

its a cable router...
Lee

foxwood

Posts: 1761
Joined: Fri Sep 07, 2012 3:43 pm
Location:

HTPC Specs: Show details

#37

Post by foxwood » Mon Dec 10, 2012 5:57 pm

milli260876 wrote:its a cable router...
So - give it a static IP address on your LAN, disable the DHCP server on it and connect one of it's LAN ports into one of the LAN ports of your DSL router. Now you have a device on your LAN that can run DD-WRT in exactly the same way as the Raspeberry Pi would (though you won't be able to use simple port-triggering for WoL if you set things up this way, as the packets won't be going from the WAN to the LAN port).

I wouldn't hold my breath waiting for a DSL modem with DD-WRT - if it is every ported to the BT Home Hub, it's likely that the Modem functionality won't be included.

barnabas1969

Posts: 5738
Joined: Tue Jun 21, 2011 7:23 pm
Location: Titusville, Florida, USA

HTPC Specs: Show details

#38

Post by barnabas1969 » Mon Dec 10, 2012 10:43 pm

Whatever device you choose, it needs to receive the network packets that go between the Companion app and the PC. That means that either A) you need to setup the router/switch to forward all of those packets to the WOL device, or B) you need to place the device in the path between the router and the PC (WAN port to router, LAN port to PC).

milli260876

Posts: 726
Joined: Wed Jun 08, 2011 2:56 pm
Location: Barnsley Sth Yorks

HTPC Specs: Show details

#39

Post by milli260876 » Tue Dec 11, 2012 5:26 am

I just built a mini itx Celeron socket 1155 for the bedroom, its great for an htpc. Think I'm going to build an ivy bridge equivalent and just leave it on... The Celeron only eats 45w with a pico psu :-)
Lee

User avatar
Motz

Posts: 2038
Joined: Sat Jan 14, 2012 10:28 pm
Location: Seattle, WA

HTPC Specs: Show details

#40

Post by Motz » Wed Dec 12, 2012 11:10 pm

Android will be added tomorrow, with others to follow
I Write, Code, and Tweet

Post Reply