Does it matter what UDP port a WOL signal is sent to?
@Spiff is correct that it doesn't matter as far as the Wake-on-LAN functionality of the intended recipient goes. However, UDP is recommended because it can be generated without raw sockets which come with security restrictions, and port 9 is recommended because it maps to the old well-known discard protocol whereas port 7 maps to the echo protocol.
This means that if there are hosts on your network that support these old simple standard services you will get unnecessary backscatter traffic when using port 7 but none when using port 9. And since Wake-on-LAN is normally broadcasted, you could get backscatter from many hosts.
Further, if you are troubleshooting WoL with a network sniffer such as Wireshark, it will decode WoL packets properly only if they are UDP packets on port 9.
Nope, it doesn't matter. It doesn't even have to be a UDP or an IP packet at all. The NIC is just looking for the magic pattern (six bytes of 0xff, then its own MAC address 16 times) in all the frames it sees.
When I woke my computer using port 9 it would restart instead of coming out of sleep. For the life of me I couldn't figure out what I did wrong. I tried using port 7 and instead of restarting it woke up normally. It doesn't seem to matter most of the time which you use, but for my hardware I need to use port 7.