LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 04-17-2014, 03:20 PM   #1
lazardo
Member
 
Registered: Feb 2010
Location: SD Bay Area
Posts: 270

Rep: Reputation: Disabled
dd-wrt port forward triggered WOL


dd-wrt script to trigger a LAN WOL event based on a WAN port forward event.

roku/roksbox -> dd-wrt -> WAN -> dd-wrt -> wake media server

If you enter this in the GUI as a startup script, remember to escape
all dollar \$ and quote \" characters.

Code:
#!/bin/sh
# Triggers WOL by watching /proc/net/ip_conntrack for an
# established port forward, WAN source -> LAN target event
# runs on local dd-wrt

# Developed and tested on
# DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
# Release: 12/24/10 (SVN revision: 15962)
# local forward_spec=roksbox:on:both:80>media_server_IP:80<remote_router_IP
# remote forward_spec=roksbox:on:both:80>local_router_IP:80<roku_IP

# event-specific quick match keys
KEY1=6
KEY2=SYN_SENT

# port forward IPs, order is important (see POC)
SOURCE=remote_router_IP
TARGET=media_server_IP

# WOL target
WOL=192.168.1.255\ 00:11:22:33:ab:cd

while [ 1 ]; do
  if ping -c1 -w1 $TARGET > /dev/null; then
    exit
  else
    # too long == miss trigger event, too short == unnecessary load
    sleep 4
  fi

  if egrep "${KEY1}.*${KEY2}.*${SOURCE}.*${TARGET}" /proc/net/ip_conntrack; then
    /usr/sbin/wol -i $WOL
    exit
  fi
done

# PoC
#root@dd-wrt:/tmp# KEY1=6; KEY2=EST; SOURCE=192.168.1.32; TARGET=76.123.123.76
#root@dd-wrt:/tmp# if egrep "${KEY1}.*${KEY2}.*${SOURCE}.*${TARGET}" /proc/net/ip_conntrack; then echo "test match"; fi
#tcp      6 124 ESTABLISHED src=192.168.1.32 dst=18.28.16.50 sport=36450 dport=80 src=18.28.16.50 dst=76.123.123.76 sport=80 dport=36450 [ASSURED] use=1 rate=11360 mark=0 
#test match
Cheers,
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Iptables can't port forward (PAT Port address translation) sfrederiksen Linux - Networking 7 12-20-2011 10:47 AM
[SOLVED] wol on a different port along with ssh ziplark Linux - Networking 3 09-10-2010 07:50 PM
Bad WAN port performance on WRT54GL when used as a switch. (DD-WRT) Synt4x_3rr0r Linux - Networking 0 08-23-2010 11:44 AM
Linksys WRT54G v.5 - DD-WRT --- Server in DMZ -- How to forward ports to my desktop? mitchell7man Linux - Networking 1 04-03-2010 02:07 PM
port forwarding in router for wol??? p03p Linux - Networking 6 03-04-2009 03:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 11:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration