OpenWrt Forum Archive

Topic: Routing / broadcast a WoL magic packet

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

I'm trying to broadcast on the LAN a Wake On Lan "magic packet" to wake up 10.1.1.10 (router is 10.1.1.1).
The UDP packet is sent from Internet (basically to wake-up my Linux workstation).

All operations are done via ssh (luci is not installed).

Added to `firewall`

config 'redirect'                                      
        option 'name' 'wakeup'                         
        option 'src' 'wan'                             
        option 'proto' 'tcpudp'                        
        option 'src_dport' '9'                         
        option 'dest_ip' '10.1.1.10'                  
        option 'dest_port' '9'                         
        option 'target' 'DNAT'                         
        option 'dest' 'lan2'      

This works when 10.1.1.10 is switched ON, tcpdump shows the packet reaching destination.

But of course, when 10.1.1.10 is down, the usual ARP query "who is 10.1.1.10" to get its MAC address will not get an answer. And the WoL doesn't work.

So here is my problem:

- tried to add a static IP is `/etc/ethers` (and `option readethers '1'` in `config dnsmasq`) => doesn't work

then added to `dhcp` the Linux host IP and MAC

config host
        option ip       '10.1.1.10'
        option mac      'a5:31:ac:91:10:01' 
        option name     'linux'

- doesn't work either

By "doesn't work", I mean after a router reboot, `arp` shows

10.1.1.10  0x0   ... 00:00:00:00:00:00

the MAC address is still all-zeroes, and the WoL packet doesn't reach the linux PC.

[I must say that 10.1.1.10 is not part of the DHCP allocated range of IPs (.100 ~ .200)]

Questions
- Is there another way to route a WoL Packet (or broadcast it)?
- How to get a static IP + MAC stored and used?

----
Notes:
- using CHAOS CALMER (15.05.1)
- WoL works from the LAN (send the packet from another PC on the same LAN works)

(Last edited by *++p on 9 Feb 2018, 17:07)

I'd start with trying to wake it from openwrt. Install etherwake package, ssh to your router and run
etherwake -i eth1 -D a5:31:ac:91:10:01
(this is actually how I wake my systems behing openwrt - way more secure and reliable). Make sure to use correct interface, it usually does not work when you do not specify any.

Edit: I think you need to forward also port 7 and you only need udp, not tcpudp.

(Last edited by nozombian on 10 Feb 2018, 18:41)

Thanks but the wake-up is run from Internet

- cannot ssh router from Internet (and don't want to)
- how would I trigger etherwake from Internet?

Maybe would be simpler to route the WoL packet via the router?

You don't wan't to ssh, but want to make it work, right? So you'll have to. ;-) You have to make sure you can wake your device from the router, or you can play with routing magic packets all day long to finally realize, that there's something wrong and the device won't wake up for whatever reason.

Another approach might be to run script on the router, which will check some web page with your php script every minute or so, and if it finds you want to wake up, it can execute etherwake. This is what I do on LTE links, which do not have public IPs. You can also run perl or php script on your router which can launch etherwake on your command directly, if you can access your router from internet, there are many ways how you can trigger etherwake if routing of magic packets fail, but you will have to ssh first :-)

Well, that would work, no doubt. But I'd like to fix the initial problem, a matter of static IP.
And that would go along with the other similar settings via other routers (office for instance)

The simple magic packet routing should go through:

- again the UDP packet goes to the PC - when it's UP (seen using tcpdump)
  reason being that the router's ARP query gets an answer, since the PC is running

- it's a matter of the router seeing a static IP linked to a MAC address

- and, the two methods (/etc/ethers+readethers, or 'config host') make the router set a '00:00...00' MAC linked to that IP, instead of the correct MAC

I was thinking the reason to that 00:00...00 is maybe because the PC address is fixed and is not part of the DHCP IP range?

Or i'll have to go through the code again to see what's wrong (takes lots of space and download+compile time, would like to avoid that).

Offline device does not care about IP, it has only its MAC so you have to wake the mac. I never tried to route magic packets, because I do it the way you don't like ;-) But I use it daily on many sites and it works perfectly. I have to ssh to router anyway, because I use it for ssh tunneling to the remote network, so when I'm there, I run etherwake before trying to rdp or whatever to the PCs inside the remote lan.

WOL can be tricky even on local network, so that's why I'd debug the way I suggested. Have you tried to wake the pc from other device on the same lan?

(Last edited by nozombian on 11 Feb 2018, 11:18)

> Have you tried to wake the pc from other device on the same lan?

Yes, and it works.
Works also: using another router supporting the WoL broadcast (since it broadcast to all IPs on the same LAN)

> Offline device does not care about IP, it has only its MAC so you have to wake the mac

Not totally exact.
Since the router cannot broadcast the packet (at least I don't know how to), the usual IP to IP com is used.
But that wouldn't work since PC is Off.
But what we just need is the router to throw that packet on the LAN... and router wouldn't do that since the requested IP does not answer (via ARP).
But if we give the router a static IP / MAC association, it doesn't need the ARP query response and will just write that magic packet on the line.

The actual IP address is not used effectively ; the static IP link is just to make the router happy and put the packet on the Ethernet wire, would the IP be alive or not.

However, and this is the problem, the router doesn't seem to memorize that IP<>MAC association, and set the MAC to zeroes.

I see. If that's so. I don't have deep technical knowlege about how it works, so maybe it's totally stupid idea, but what about forwarding to option 'dest_ip' 'whatever_your_broadcast_IP_is'? ;-) Btw. have you both ports forwarded (7,9)?

(Last edited by nozombian on 11 Feb 2018, 14:01)

oh i see.

and why using both ports 7 & 9?? 9 works fine.

If you can wake on port 9 on local lan, maybe you don't have to forward 7. I read somewhere both are used, but as I always use wol only from openwrt to local lan, I never cared too much about how it really works. You can also try to forward to broadcast ip 224.0.0.0, but that's about all I can advice you, good luck.

Sorry to say that if you don't have the technical background to answer a post, you better let others reply to it.

The discussion might have continued from here.