Suggestion: General Blocking "wildcard" Blocking in DNS blocklists

Issue
Currently Mikrotik supports only hostfile based blocking. That is OK but not idea, because spammer use also many dyanamic subdomains, that arent blocked automatically.

For example

0.0.0.0 example.com

This would not block www.example.com or www2.example.com. A regex based blocking system would be much better.

||example.com^

Currently (I tested it), Mikrotik would load regex based blocking systems, but dont use it for blocking. Regex’es like | or ^ are interpreted as hostname additions, which of example.com^ doesnt exist.

Solution
Loading a DNS Spamlist, in the UI you should be able to select host file based or regex based and then router os can interpret it correct. Regex based spamlist are way more efficient, and would also save memory from the DNS Cache, because many entries can be minimized to one “wildcard” regex entry.

For Questions, I am here to answer them. This is a serious request. Please no trolling or toxic posts.

Already done here —> https://itexpertoncall.com/promotional/moab.html

If you’re interested in changing DNS responses, you can already do that:

/ip dns static
add name=example.com address=127.0.0.1 match-subdomain=yes

Regexp works too:

/ip dns static
add regexp="^(.*\\.)\?example\\.com\$" address=127.0.0.1

Edit: Or if you mean the new adlist, I didn’t play with that yet. It seems that it’s probably exact match only. Optionally matching subdomain could make sense. Regexp could be too heavy.

I’m using

 regexp="(^|\\.)example(\$|\\.)"

to match: example, example.com test.example.com but not sure if correct.

on WinBox

(^|.)example.com$

on terminal

regexp=“(^|\.)example\.com$”

“example” only is not a valid dns

for any example.* (valid!!!, is valid also www.example.asdf but asdf actually do not exist…)
also catch *.example.XN–VERMGENSBERATUNG-PWB ( www.example.vermögensberatung )

regexp=“(^|\.)example\.[a-zA-Z][a-zA-Z0-9-]{0,28}[a-zA-Z]$”


So, for blocking :laughing: :laughing: :laughing: :laughing: :laughing: ....................facebook.* just…

regexp=“(^|\.)facebook\.[a-zA-Z][a-zA-Z0-9-]{0,28}[a-zA-Z]$”

Hahaha greek to me, but what I do know, Germany, Greece and Italy, are NOT in the EuroCup Final ;-PPPP

Neither Canada @ Wimbledon… except Dabrowski on double…

Sir @rextended, regexp=“(^|\.)mydevice($|\.)” was ment to match “mydevice”, “mydevice.local”, “test.mydevice.net” due to macOS not matching mydevice from Finder or Terminal.
If you have a better suggestion, your contribution is always appreciated :slight_smile:

you regex can match also something.mydevice.something.another.com

(
regexp="(^|\.)example\.com$"
or
regexp="^example$"
)

regexp="((^|\\.)example\\.com\$|^example\$)"

Okay, so you distract with silly hitting a ball over the net game........... :wink:
Let see who gets a medal, Jacobs in the 100m or DeGrasse in the 200m.

In general it can be said that “wildcard” matching of DNS requests is usually used for what would better be accomplished with subdomain matching (the example shown in this topic is another case of that).
You do not want regexp matching in your resolver with a long list, because for each and every DNS request ALL the regexps have to be evaluated to see if they match, and that is often an expensive operation.
Instead, subdomain match only has to look at the DNS labels (remember a name like www.example.com is already sent as [www][example][com] in a DNS request (I mean it is sent as 3 separate fields), so that is much more efficient.)

The only thing you really need to request is some way to set the “match-subdomain=yes” flag for DNS entries read from some adlist you configure (which supposedly contains domains for which you want to allow subdomains as well).

I am aware of the regex when I point static dns entries into nirvana. This is not my intention. I want to use blocklists.

And when I add one like this, they dont work.

https://raw.githubusercontent.com/RPiList/specials/master/Blocklisten/spam.mails

But they are common syntax for pihole or adguard.

Then use pihole or adguard…



All your assumptions are wrong at the begin,
this is not a valid RegEx

||0-01x-merchandise.554217.xyz^

it may be some custom syntax, but it has nothing to do with a POSIX RegEx.

since “^” is the start of something, and is at the end, probably the syntax must be read on the contrary, but RouterOS cannot interpret it as it is.

also || is not a valid part of a RegEx that say “something or nothing after one dot”.

In conclusion, they are not RegEx and you certainly cannot expect RouterOS to interpret them as such.

I think what you need to suggest (to MikroTik, in a ticket in the support system, posting suggestions in the forum is useless!) is to extend the adlist mechanism so those lines with ||example.com^ are recognized where the ^ is just removed, and the || as well but it also serves as an indicator that an entry should be put in DNS with match-subdomains=yes flag.
Maybe some more special characters from that syntax can be supported.

But I think that it should not be implemented as regexp match. That is inefficient and normally not necessary.