[SOLVED] Route UDP wake-up "magic packet" from Internet ➜ broadcast over LAN

I'm trying to route an UDP packet, from WAN port 9, to be broadcast over the whole LAN (same port).

In other terms, trying to wake-up my Linux workstation from Internet, using the famous UDP "magic packet" that embeds the MAC address of the PC to be woken-up.

   Remote Server ➜ Internet ➜ LEDE ➜ LAN ➜ target PC

Remote server does wakeonlan -i LEDE-WAN-IP PC-MAC-ADDRESS

What about adding this to firewall

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

and adding the IP to ethers along with the PC MAC address?
Would that work?

[ tbh tried with Chaos Calmer:

  • the packet reaches the PC (tcpdump) when the PC is ON
  • but when the PC is Off the packet doesn't reach the PC NIC, despite the ethers entry
  • ssh to openwrt, arp showed 00:00:...:00 as MAC for that IP
  • Wake-up via magic packet works on PC when sent from another PC on the LAN (ie not via openwrt) ]


Take a look at the following packages...



Thanks but etherwake is a command to wake up hosts. I'd like to route a magic packet coming from the WAN (and I'm not using Luci).

Is it doable modifying the /etc/config files?

I think you are missing to set a static MAC address.

Source: http://mtamsky.blogspot.dk/2011/11/openwrt-and-wake-on-lan-wol-how-to-make.html?m=1

This command statically sets the ARP address for an IP. (Replace 00:de:ad:be:ef:00 with your hosts's ethernet MAC address.)

ip neigh add lladdr 00:de:ad:be:ef:00 nud permanent dev br-lan

I added the above 'ip neigh add' command line to my router's /etc/rc.local file.

If the 'ip' command is not installed, you should be able to install it with 'opkg update; opkg install ip'.

BTW I think the IP address can be a dummy IP not used in your DHCP range (or by any host using a static IP). The MAC just have to be known by the router.

Thanks, will try that later this weekend.

But isn't that the role of /etc/ethers, to provide a static MAC address for an IP?


OK...I think you misunderstand the Magic Packet...

This will never work, as the Magic Packet is a Broadcast Packet, not a Unicast Packet.

This definitely won't work, as the packet would have a destination MAC of FF:FF:FF:FF:FF:FF (BROADCAST).

Lastly, since it's Broadcast, it's a crafted Layer 2 frame, not a real Layer 3 datagram...meaning, it cannot be forwarded over the Internet without advanced configurations (like an WOL Internet proxy).

  • If you are in fact using the Magic Packet technology, simply making a firewall rule will not work
  • Confirm what Wake-On-LAN technology you're actually using

See: https://en.wikipedia.org/wiki/Wake-on-LAN#Wake_on_Internet


This said "magic packet" is just an UDP packet that needs to reach its destination: the NIC of the powered-off PC.

To send an UDP packet to a LAN IP address (ie not broadcast to all NICs), LEDE needs to know the MAC address linked to that IP.
So it does an ARP query "Who has" and gets its MAC.
However the PC is down, so no answer will be provided. And this is the problem.

But, if LEDE knows that information (MAC linked to IP) even though the PC is down, it doesn't have to do the ARP query... LEDE just throws the UDP packet on the LAN directed to that MAC (indeed layer 2) and that's it, the PC is woken up...

And that removes the need to broadcast the packet on the LAN, which is the purpose of that thread!

(which @hammer understood, but I must admit after re-reading the top post that based on the original title, that's not obvious -- couldn't broadcast so tried this solution ; of course if broadcast is possible, I'll take that as well)

How does it work? FYI:

  • Having this exact configuration from first post (redirect)
  • Shutting down the target PC after doing some exchanges with LEDE (ensure ARP cache is fresh)
  • Within one minute (ARP cache expiration) do the wakeonlan from Internet (send magic packet) while the PC is down
  • and the PC on the LAN wakes up! (just tried with LEDE)

So, to summarize

  • LEDE will wake up the PC if it knows to which MAC it has to send the packet
  • if /etc/ethers or @hammer's trick works, and teaches the MAC linked to that IP to LEDE, it will work!

I'll try that probably tomorrow (@hammer's post)

1 Like

Aaah...I understand...

Does the command:

arp -i <interface_name> -s <MAC_address>


@hammer thanks the command works! (had to install the 'ip-full' package)

1 Like

I worked out a little program which can trigger a Wake-on-LAN packet based on firewall rules. I created an OpenWrt package feed for it. It might be of interest to people passing by here:


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.