0

Is there a way to script an OpenWRT router to catch TCP packets addressed to a server on the network? I'd like to send a WOL packet to that server and wait for waking up from hibernation before sending the actual message.

Note: I am a beginner with networking. Some people claim what I described is not possible, while others the exact opposite. I'd like to know whether this is possible and if so how (without losing significant bandwidth)?

inf3rno
  • 408
  • 2
  • 5
  • 17

1 Answers1

2

It is hard to say what the right approach is, and giving a more direct answer without more information.

If you want to "catch" a package sent to the server from the client, than you can do this with almost any Linux / Unix system.

If you have a firewall (or in this case OpenWRT router) in between server and client you can parse the logs of the firewall, tcpdump or what OpenWRT offers.

When a package is received by the firewall with destination of the 'sleeping'-server with WoL UDP package pattern from the client, you know that the server has received it. You can than wait for any amount of time before you than send your payload.

Best approach If you have a monitoring service you can send the WoL UDP package, and than wait for your monitoring service such as Zabbix to indicate that the server is now fully 'awake'. Than execute your payload.

Some people claim what I described is not possible

It is highly possible.

without losing significant bandwidth

Their is no reason you should lose any throughput over this.

  • I run some webservices, samba and ssh on that server. Afaik. all of them use TCP only. The new router will be most probably a Linksys WRT1200AC. I'd like the server to wake up automatically when I try to reach it's local IP with one of my computers. The ideal would be if it would wake up within client timeout period, so it could respond to the client. Any other details you need to know? – inf3rno Jun 12 '17 at 13:43
  • What operating system are you using for the server and client? For example if you use Debian / Ubuntu for both you can use etherwake – Cristian Matthias Ambæk Jun 12 '17 at 13:59
  • The server is Ubuntu. There are multiple clients, Windows 7, 8.1, 10 currently. After Windows 7 support ends maybe I'll use Ubuntu instead of that. I don't want it to be client dependent, the client should not know about this feature beyond the increased timeout settings or retry by error behavior. I am not the only user, but I'll use the server most of the time. – inf3rno Jun 12 '17 at 14:23
  • Try using etherwake for your server to take requests in and wolcmd for windows to sending requests out. – Cristian Matthias Ambæk Jun 12 '17 at 15:00
  • I think you are missing the point. I want to send ONLY! regular HTTP, SMB, SSH, etc. messages from the client. That's why I want to capture them on the router and send the WOL packet from the router to the server automatically when the server sleeps... – inf3rno Jun 12 '17 at 17:01
  • I am not sure, maybe did not read your answer properly. I did some research and it is possible to capture TCP with tcpdump. I found a simple nodejs repo, which does the same, so in theory it is possible to do this with a nodejs daemon, which would be fine, since I really hate bash scripts... All I need to figure out what happens on the router when it cannot find a responding server. Thanks for the answer! – inf3rno Jun 16 '17 at 01:28