Community discussions

MikroTik App
 
Kaloschke
just joined
Topic Author
Posts: 3
Joined: Mon Mar 11, 2024 10:05 pm

Is it possible to respond to a specific ping

Mon Mar 11, 2024 10:20 pm

Hallo,
I have a server behind a router that is on a different network B and is often in sleep mode. A ping or a WoL in this network would wake him up. However, this does not happen from network A.
My idea now is to detect a ping from network A to this server and then send a command that wakes up the server:
/tool wol mac=xx:xx:xx:xx:xx:xx interface=ether1
Is something like this possible?

Greetings
 
tangent
Forum Guru
Forum Guru
Posts: 1406
Joined: Thu Jul 01, 2021 3:15 pm
Contact:

Re: Is it possible to respond to a specific ping

Mon Mar 11, 2024 10:44 pm

You might think that WoL is a unicast protocol given the MAC address, but it's not; it's based on a subnet-directed broadcast packet. It has to work that way because it can't rely on ARP mappings, the FDB, etc. That much is true inside network B, but even more so in network A, where it couldn't see network B's ARP table or its FDB even if it wanted to. We speak of "broadcast domains" for this very sort of reason.

I'm not aware of any "run a script on ping packet" functionality in RouterOS, and if there were such a thing, I would consider it a massive layering violation, tying one of the OS's lowest layers (packet filtering) to one of its highest layers (scripting). Yuck.

Why not simply issue that "wol" call over SSH?

ssh myrouter /tool/wol mac=aa:bb:cc:dd:ee:ff interface=ether1

Wrap that call into a local shell script or batch file, and you can call it as "wake-server" for short.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3509
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: Is it possible to respond to a specific ping

Mon Mar 11, 2024 10:52 pm

I 100% agree with @tangent.

But one possibility is to have a firewall filter rule that matches the desired ping, and then does action=log. A schedule script could then search logs for that message, and run the desired script.
 
Kaloschke
just joined
Topic Author
Posts: 3
Joined: Mon Mar 11, 2024 10:05 pm

Re: Is it possible to respond to a specific ping

Mon Mar 11, 2024 11:24 pm

Thank you very much for your answers. My background is that I operate a 24/7 media server in the home network, which should be as energy-saving as possible but also "convenient". The clients in the network should be able to access shares and media without having to explicitly wake up the server every time. In addition, it is supposed to go back into energy-saving mode after a relatively short time when idle.
I have therefore disabled "Only WoL can wake up device" in the network settings. This, of course, then leads to the fact that any network activity prevents sleeping. That's why I came up with the idea with the router, because these activities are not routed for the time being. On the other hand, a targeted request to the server should be able to wake it up from hibernation. But from the looks of it, that doesn't seem possible. What a pity.
 
tangent
Forum Guru
Forum Guru
Posts: 1406
Joined: Thu Jul 01, 2021 3:15 pm
Contact:

Re: Is it possible to respond to a specific ping

Mon Mar 11, 2024 11:29 pm

Okay, new solution: use Home Assistant to react to a TV "power-on" event and send the WoL packet/SSH call from there.

How exactly you go about that depends on the type(s) of displays involved, what type of set-back boxes you've got running, whether there's an active CEC link you can tap into, etc.

Worst case, buy one of those hackable $9 power plugs like the Sonoff S31, reflash it with ESPHome, and detect power-on by the jump in current draw. Wake the server, and by the time the user gets around to drilling down into Plex or whatever, the server is awake and ready to respond.

This is getting us rather off-topic, though.
 
Kaloschke
just joined
Topic Author
Posts: 3
Joined: Mon Mar 11, 2024 10:05 pm

Re: Is it possible to respond to a specific ping

Mon Mar 11, 2024 11:43 pm

@tangent
Yes, this should be possible for the scenario described. However, the server is mainly used by clients in the Windows network.
But it's a nice idea for my raspberry with kodi :-)
 
tangent
Forum Guru
Forum Guru
Posts: 1406
Joined: Thu Jul 01, 2021 3:15 pm
Contact:

Re: Is it possible to respond to a specific ping

Tue Mar 12, 2024 1:02 am

So wrap the call to the Windows player GUI in a script that sends the SSH "wake" call to the router first.

If you're worried about handing out SSH logins to allow this, you can put the call into a *.rsc file and set the dont-require-permissions flag on it, so read-only users can call it.

Microsoft has been shipping a native port of OpenSSH since 2015, officially released in 2017.

Who is online

Users browsing this forum: lurumoney and 3 guests