Hoping someone with a bit more knowledge on networking can help me here, I’m not quite sure how to start approaching this problem.
I’m interested in listening on my local network for any communication that goes to a specific local IP on a specific port, and triggering an action/calling a local web service when the first packet after, say, ten minutes of silence occurs. The destination device is port forwarded on my router on that specific port and is on a wired connection to the router. The device will not be connected to the router when the first packet is sent to the destination device (it will be powered off).
Specifically My Use-Case:
I have RDP enabled on my desktop pc with my router port forwarded to that machine, and have wake on LAN set up on that PC and another server (a raspberry pi running Home Assistant OS) that can turn on the PC. I would like to be able to sniff for any connection my router is trying to make to my desktop on that specific port, and trigger the Wake-on-LAN so that the remote connection can will succeed without the need to log on to a local server and manually trigger the Wake-on-LAN (so that I don’t have to leave my desktop on all the time).
What I Have Tried/Looked Into:
I’ve been able to connect the desktop to WiFi and use WireShark to detect the packets sent for the destination PC, but am not sure how to go about doing this for a wired connection. Also note that I don’t need any information about what is in the packet or to attempt to decrypt it, just that the connection attempt was made. Would it make sense to set up a fake DNS server to do the sniffing, kind of like how a PI Hole works?
Any other workaround such as port forwarding that specific port to a different device, having that device trigger the Wake-On-LAN function, and then somehow routing the client from there to my desktop would also be perfect — however, not enough of a networking Guru to know how to do that, especially since the communication is UDP-based and HTTP redirects aren’t a thing at that level. I’m also curious if there would be a way to use port triggering to accomplish this, where a separate device initiates a connection on that port repeatedly, all inbound traffic on that port gets routed to this device at first, and it turns on the PC and somehow the PC initiates a connection on that port to change the rule to forward to the PC. A router-level solution that doesn’t require sniffing of all packets on the network would be ideal.
I only ask this here since I feel like this would be very useful for anyone who uses RDP to their PC at home.
I don’t always post on stack exchange when I need help with side projects.. but when I do, I’m very grateful for any response. Thanks!