OpenWrt Forum Archive

Topic: wake-on-lan port forwarding?

The content of this topic has been archived on 16 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I'd like to wake-on-lan from wan, but can't seem to get it working. It works from lan, ie. from my laptop, where I've set MAC to the mac address of the sleeping computer, I can do

$ wol $MAC

and it starts up. It also starts up with the broadcast IP specified, like so:

$ wol -i 192.168.1.255 $MAC

I've tried translating the DD-WRT tutorial at http://www.dd-wrt.com/wiki/index.php/WO … Forwarding into OpenWRT terms. I added the following firewall redirects in luci:

 UDP wan:0.0.0.0/0:* Device:0.0.0.0/0:9 lan:192.168.1.254:9 DNAT 
 UDP wan:0.0.0.0/0:* Device:0.0.0.0/0:7 lan:192.168.1.254:7 DNAT

and used the following /etc/rc.local:

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

ip neigh change 192.168.1.254 lladdr ff:ff:ff:ff:ff:ff nud permanent dev br-lan
ip neigh add 192.168.1.254 lladdr ff:ff:ff:ff:ff:ff nud permanent dev br-lan

exit 0

After installing the ip package so those commands would work, and rebooting, the command "arp" shows a new entry

192.168.1.254    0x1         0x6         ff:ff:ff:ff:ff:ff     *        br-lan

so it seems the ip commands did work. But still wake-on-lan does not.

Anyone have a clue how to fix/debug this?

Running  Backfire (10.03.1-RC5, r27608) on a Netgear WNDR3700v2, if it matters.

(Last edited by unhammer on 11 Dec 2011, 15:10)

WOL works on local subnet only. You might want to try the package udp-broadcast-relay, I use it to to relay WOL packets from one subnet to another and it works very well.

Sadly, packets to 255.255.255.255 are not being routed through the internet ;-) So they do not arrive at your OpenWrt box.

But you could remote login per ssh and then send the WOL-Packet from the OpenWrt box.

Orca wrote:

Sadly, packets to 255.255.255.255 are not being routed through the internet ;-) So they do not arrive at your OpenWrt box.

But I'm not sending to 255.255.255.255. Perhaps I should've mentioned, the command I use is

wol -i $IP $MAC

where IP is my br-wan inet addr (81.191.something.something)


Orca wrote:

But you could remote login per ssh and then send the WOL-Packet from the OpenWrt box.

Yes, this is what I do currently, it works smile

(Last edited by unhammer on 4 Jan 2012, 09:27)

You need to direct your wol Ip to port 7 or 9, when doing it from the WAN:

wol -i $IP -p 7  $MAC

Your firewall commands will cause all UDP packets from all adresses: port 7 or 9 to be redirected to 192.168.1.254.
192.168.1.254 is listed with an all ff macadress, causing the packet to be broadcasted on the local lan.

(Last edited by pfugl on 5 Jan 2012, 14:52)

i have a TPlink wr941nd and i have put gargoyle v 1.4.7. i'am conected with a static ip to internet. everything works ok except i have 2 problems:

first i tried wol from internet and it didn't work even if:
i put

ip neigh change 192.168.0.109 lladdr ff:ff:ff:ff:ff:ff nud permanent dev br-lan
ip neigh add 192.168.0.109 lladdr ff:ff:ff:ff:ff:ff nud permanent dev br-lan

in rc.local and forwarded port 9 from firewall - nothing happens except everytime i do wol i can see in gargouyle web interface status-connection list that my packet has arrived in router.
if i use arp command i can see this line added (first in list)

IP address       HW type     Flags       HW address            Mask     Device
192.168.0.109    0x1         0x6         ff:ff:ff:ff:ff:ff     *        br-lan

i have tried many combinations port/ip in firewall then add arp rule with ipneigh (also tried them in ddwrt and latest gargoyle v1.5.8).i have tried also a tutorial in which when adding arp rule u need to change HW address with pc u want to wake up and still no result.
everytime i have made a modification i rebooted router. i want to mention that wol works with a dlink router which broadcasts udp packets from firewall rule (just set destination to 192.168.0.255).

second problem i cannot connect putty with 192.168.0.1 but works very well from wan.

can someone point me in a good direction? what am i missing here?

ok, this has been bugging me for a while since i thought i had it all figured out with just forwarding the right port to the right ip address...not so much. but finally got it working flawlessly, thanks mainly to this thread.

here's a summary of how i got my setup to work since it's a bit different than what unhammer had to do and this thread kinda died without a conclusion:

1. set up your firewall forwarding
forward UDP port 9 (or 7) from the any wan ip to the lan ip 192.168.1.254 (modify this to be a permanently unused ip in your local subnet but not the standard broadcast ip ending .255)
2. define your new broadcast ip in the iptables
add to your startup script (before "exit 0" and after comments) the following:

ip neigh add 192.168.1.254 lladdr ff:ff:ff:ff:ff:ff nud permanent dev br-lan

NOTE: this command needs to be used verbatim and it uses the ip package which wasn't installed initially in the 12.09-rc1 build i am running. use the system>software tab to install the package named simply "ip" (nothing more, nothing less).
3. Reboot and enjoy

These 3 (possibly 4) steps simply define a new ip address for your router to forward packets that i intended for network-wide broadcast, this is done to circumvent a the standard limitation of not forwarding packets to the standard broadcast address. The ff-filled mac address is the special identifier for ALL hardware, that's why it is used in the ip command. (this is how i understand it, someone please correct me if i'm wrong.)

hope this helps the next person to find this thread.
thanks guys.

deadpixel wrote:

hope this helps the next person to find this thread.

This greatly helped me, thanks smile

I believe this trick should be set by default to enable WOL from internet, from the very start (maybe with a switch to enable/disable it).

The discussion might have continued from here.