Help with script to send notification to telegram

hi every one…

I have mikrotik hap ax3 with 7.19.3
and i want to send message to telegram when some devise open spisific website and send message like this :

Alert: Blocked site accessed!
IP:
Device:

Site:
Time: 21:19:45

1 Like

@druvis made a video about this: https://m.youtube.com/watch?v=KLX6j3sLRIE
Mikrotik/Telegram RouterOS at main · Druvis-Timma/Mikrotik · GitHub

I personally use: routeros-scripts/doc/mod/notification-telegram.md at main · eworm-de/routeros-scripts · GitHub on an LHG LTE18 antenna to pass SMS messages received from the operator to a telegram group.

1 Like

Thanks for replay…
I try and I make a script, but just send the website name without IP address .

1 Like

So?

I did something, but it doesn’t work.
Why doesn’t that thing work?

1 Like

That does not contain any useful information

1 Like

Is it so hard to use search funcionality of forum?

For these who are too laz. not fluent in using advanced tools:

Not hard ,but i want to link this notifications with log when someone open spisific website then the message come with ip address and website he try to open

If problem is not specified then do not be suprised that tha answer does not match your expectations.

You wrote: “I want to send a message to telegram…” not “How to recognize opening website page?”
Are you sure that it’s possible if most of trafic is encrypted and tunneled?

More … it’s the topic title so you directly expressed the need for Telegram funcionality.

The message was obviously not addressed to you but to @allame.alaa

Can’t understand irony?
If a script doesn’t do something, and you don’t publish it, how the hell are we supposed to figure out what the problem is?
Think twice before you write or put a -1.

Ok im don’t know any thing …
You can help ,Send to me script can send Messages to my telegram when someone open website like (YouTube)
With ip address …or like this

Alert: Blocked site accessed!
IP:
Device:
Site:
Time:

I think the suggestion was to post what you got.

But your problem may not be telegram, or at least not only telegram.

Notifying about “blocked sites” is actually a harder problem since MikroTik does not effectively know what “sites” people are going to, beyond just IP.

I try with script and message come to me just with website without ip address ?

Once again.
That mission is impossible in 99% as encrypted https stream hides used addresses.
If user uses encrypted DNS qeyries → no chance to even know what addreses are resolved.
You need different solutions to monitor traffic for who&when&where tries to browse/contact as MT does not provide solution for that.

It’s not a problem of using Telegram (a lot of solutions on the Forum) but of filtering the traffic.

It is technically possible to get the initial DNS request logged and then search/regex that in a script.
/system logging add topics=dns,debug action=memory - one way to log DNS requests.
But note @allame.alaa that it is unlikely that somebody is going to dedicate their free time to write the implementation for you, especially with very ambiguous requirements.

  1. If you want to block ads or websites, just use Mikrotik’s Adlists support.
  2. If you really need to track people’s behavior(looks like the intent here), your device has RouterOS container support - you can install Pi-Hole on hAP ax3 through its container support and redirect DNS requests through it, which will show you the website being accessed and blocked/allowed.

There is a solution, which is to force users to pass through the router’s dns, but to no avail.

Are you sure when browsers establish direct connections to external DNS using HTTPS (DoH)?
How do you know that any page is opened if only DNS is resolved? Do you assume that asking DNS at eg. 8.8.8.8 implies opening any google’s page?

The initial request is the top of an ICEBERG. That is why Titanic sank, they thought they saw all the crucial part of it. :slight_smile:

2 Likes

Do not forget “VPN”, DoT & some new emerging “like DNS” protocols…