Community discussions

MikroTik App
 
CPromper
just joined
Topic Author
Posts: 24
Joined: Wed Aug 05, 2009 8:34 am

Trigger event on port access (e.g. send wol packet)

Fri Nov 18, 2011 12:29 pm

Hello everybody,

is it possible, to trigger an event, e.g. wol packet, when accessing a port on a specific IP address through the Mikrotik router?

Following situation:

I have a server that is offline most the time. On this server there's a software installed (SubSonic Music Server Software) that listens on port 4040.
I connect with my iPhone to my home network via VPN and start the app iSub to connec to port 4040 of my server.

This port access to the ip of the server should trigger, that the Mikrotik sends a wol packet to the MAC address and wake him up.
I hope I have described my problem accurately!

Is this possible ?
 
User avatar
sadeghrafie
Long time Member
Long time Member
Posts: 514
Joined: Sat Nov 14, 2009 11:28 am
Location: Bushehr, IRAN

Re: Trigger event on port access (e.g. send wol packet)

Fri Nov 18, 2011 12:53 pm

I can't understand you exactly, But I hope this is useful to you:

http://wiki.mikrotik.com/wiki/Manual:Tools/Wake_on_lan

If it's OK, Then you can schedule this on event when ever your phone connect to MT via VPN
 
CPromper
just joined
Topic Author
Posts: 24
Joined: Wed Aug 05, 2009 8:34 am

Re: Trigger event on port access (e.g. send wol packet)

Fri Nov 18, 2011 1:13 pm

Hi sadeghrafie,

I know how wol works. Thanks.

Okay I will explain it another way.

I connect to my network via VPN through Mikrotik router. This shouldn't trigger the wol.
Only when I start an app on my iphone that connects to an LAN-IP (my server, it's offline at this moment) on port 4040 (LAN is connected to Mikrotik) then the wol packet should be send to the specific MAC.

I hope this clears things up for you

Kind regards

Carsten
 
User avatar
sadeghrafie
Long time Member
Long time Member
Posts: 514
Joined: Sat Nov 14, 2009 11:28 am
Location: Bushehr, IRAN

Re: Trigger event on port access (e.g. send wol packet)

Fri Nov 18, 2011 1:28 pm

OK, I got it now. It's all refer to scripting I think or maybe there is some other ways. But I have no idea at this moment!
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Trigger event on port access (e.g. send wol packet)

Sun Nov 20, 2011 5:57 pm

you can create firewall rule for those packets, and in script, periodically check whether packet count is non-zero. if it's not - send WoL and reset packet counter
 
User avatar
sadeghrafie
Long time Member
Long time Member
Posts: 514
Joined: Sat Nov 14, 2009 11:28 am
Location: Bushehr, IRAN

Re: Trigger event on port access (e.g. send wol packet)

Sun Nov 20, 2011 10:32 pm

you can create firewall rule for those packets, and in script, periodically check whether packet count is non-zero. if it's not - send WoL and reset packet counter
Thanks Chupaka. Nice tip. I hope it works

First add this rule
ip firewall filter add chain=forward src-address="iPhone IP" protocol=tcp dst-port=4040 action=passthrough
then
in system scheduler
:local i;
:set i [/ip firewall filter get value-name=packets  number="the firewall rule(above) number"];
:delay delay-time=10000ms ;
:local j;
:set j [/ip firewall filter get value-name=packets  number="the firewall rule(above)number"];
:if (j>i) do={tool wol mac=xx:xx:xx:xx:xx:xx }
Set this code to run every x min/sec/hour (what you want).
 
CPromper
just joined
Topic Author
Posts: 24
Joined: Wed Aug 05, 2009 8:34 am

Re: Trigger event on port access (e.g. send wol packet)

Fri Dec 09, 2011 9:14 am

Thanks Chupaka and sadeghrafie,

how can I check in the script if host is online and then exit the script directly without sending wol packet ??

After the host is waked up, the packet count will always increase, because I access my application on port 4040.
(The Mikrotik sends wol packets though the host is up and running)

Kind regards
Carsten
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Trigger event on port access (e.g. send wol packet)

Mon Dec 12, 2011 5:11 pm

:if ([/ping HOST count=3] = 0) do={ WOL CODE HERE };
 
huatken
just joined
Posts: 1
Joined: Mon Sep 06, 2021 9:30 am

Re: Trigger event on port access (e.g. send wol packet)

Mon Sep 06, 2021 9:37 am

Hello,

Reviving this old thread to ask a follow-on question. While the firewall rule works fine for WAN traffic. Is there a way to trigger the script for LAN connected devices traffic?

Thank you in advance,

Ken
Last edited by huatken on Mon Sep 06, 2021 9:39 am, edited 1 time in total.

Who is online

Users browsing this forum: ameliask, Bing [Bot] and 80 guests