We need to wake-up some computers on our internal LAN, from the Internet.
We have a somewhat closed router, with very few ways to configure it.
I'd like to use netfilter (iptables) to do this because it doesn't involve a daemon or similar, but other solutions are okay.
What I have in mind:
- the external computer issues a WOL (Wake-On-LAN) packet to the public IP address (with the correct MAC inside)
- the correct port is open on the router (say 1234), redirecting the data to a Linux box
- the Linux box transforms the UDP unicast packet into a broadcast packet (exact same content, only destination address is modified to 255.255.255.255 or 192.168.0.255)
- the multicast packet comes to every NIC, and the desired computer is now awake
For that, a very simple netfilter rule is:
iptables --table nat --append PREROUTING --in-interface eth+ --protocol udp --destination-port 1234 --jump DNAT --to-destination 192.168.0.255
Alas netfilter seems to ignore transformation to broadcast. 192.168.0.255 and 255.255.255.255 gives nothing. Also tested with 192.168.0.0 and 0.0.0.0
I used tcpdump to see what happens:
tcpdump -n dst port 1234
13:54:28.583556 IP www.xxx.yyy.zzz.43852 > 192.168.0.100.1234: UDP, length 102
and nothing else. I should have a second line like:
13:54:28.xxxxxx IP www.xxx.yyy.zzz.43852 > 192.168.0.255.1234: UDP, length 102
If I redirect to a non-multicast address, everything is okay. I have the 2 expected lines. But obviously this don't work for WOL.
Is there a way to tell netfilter to issue broadcast packets?
Other methods I think about:
- use iptables to match the desired packets, log them, and use a daemon to monitor the log file and fire the broadcast packet
- use iptables to redirect the desired packets to a local daemon, which fires the broadcast packet (simpler)
- use socat (how?)