Community discussions

MikroTik App
 
Lilarcor
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 54
Joined: Sun Oct 08, 2017 3:16 am

match long domain name

Thu Mar 18, 2021 5:15 am

I want to set up static dns in ros for matching any long (over 5 characters) subdomains
eg. I want to match any domain like xyzxyz.example.com or abcabcabc.example.com, but don't want to match xyz.example.com or abcab.example.com.


I was using ^.*\{6,\}\.example.com, but what I got in static record is unknown record, ip is 0.0.0.0
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: match long domain name

Thu Mar 18, 2021 7:55 am

Why do you like to do that? An what to do if it match?

This is exactly one of the reason I would like DoH welcome. Noen of the ISP on the route to main DNS owner can not see nor alter my DNS request.
 
Lilarcor
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 54
Joined: Sun Oct 08, 2017 3:16 am

Re: match long domain name

Thu Mar 18, 2021 10:14 am

The reason I want to use it is for my NAS (unraid), which releases a new function in new version and needs DNS rebind to match a record for xxxxxx(radom ID, over 40 bit long).unraid.net, so I want have the match in my DNS static.
 
elico
Member Candidate
Member Candidate
Posts: 143
Joined: Mon Nov 07, 2016 3:23 am

Re: match long domain name

Tue Mar 23, 2021 9:58 pm

I want to set up static dns in ros for matching any long (over 5 characters) subdomains
eg. I want to match any domain like xyzxyz.example.com or abcabcabc.example.com, but don't want to match xyz.example.com or abcab.example.com.


I was using ^.*\{6,\}\.example.com, but what I got in static record is unknown record, ip is 0.0.0.0
The next works:
^([a-z0-9]|[a-z0-9][a-z0-9]|[a-z0-9][a-z0-9][a-z0-9]|[a-z0-9][a-z0-9][a-z0-9][a-z0-9]|[a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9]).example.com
However I would have expected it to work with a {1,2,3,4,5}
 
msatter
Forum Guru
Forum Guru
Posts: 2897
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: match long domain name

Wed Mar 24, 2021 1:32 pm

Try this this one:
^[a-z0-9]{6,}\\.example\\.com\$
:put ("xyz.example.com" ~ "^[a-z0-9]{6,}\\.example\\.com\$") = false
:put ("xyzxyz.example.com" ~ "^[a-z0-9]{6,}\\.example\\.com\$") = true

You need extra "\" when you are inside a string/text in RouterOS.
:put "$variable \$ 100.00 for hundred dollars"
local variable 99; :put "$variable \$ 100.00 for hundred dollars"
 
elico
Member Candidate
Member Candidate
Posts: 143
Joined: Mon Nov 07, 2016 3:23 am

Re: match long domain name

Wed Mar 24, 2021 2:47 pm

Try this this one:
^[a-z0-9]{6,}\\.example\\.com\$
:put ("xyz.example.com" ~ "^[a-z0-9]{6,}\\.example\\.com\$") = false
:put ("xyzxyz.example.com" ~ "^[a-z0-9]{6,}\\.example\\.com\$") = true

You need extra "\" when you are inside a string/text in RouterOS.
:put "$variable \$ 100.00 for hundred dollars"
local variable 99; :put "$variable \$ 100.00 for hundred dollars"
It works only for scripts not for a static DNS regex.
 
msatter
Forum Guru
Forum Guru
Posts: 2897
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: match long domain name

Thu Mar 25, 2021 12:21 am

Bummer, really limited.

Quick and dirty and matching any character number or sign
......\.example\.com$
 
Lilarcor
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 54
Joined: Sun Oct 08, 2017 3:16 am

Re: match long domain name

Thu Mar 25, 2021 7:20 am

I want to set up static dns in ros for matching any long (over 5 characters) subdomains
eg. I want to match any domain like xyzxyz.example.com or abcabcabc.example.com, but don't want to match xyz.example.com or abcab.example.com.


I was using ^.*\{6,\}\.example.com, but what I got in static record is unknown record, ip is 0.0.0.0
The next works:
^([a-z0-9]|[a-z0-9][a-z0-9]|[a-z0-9][a-z0-9][a-z0-9]|[a-z0-9][a-z0-9][a-z0-9][a-z0-9]|[a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9]).example.com
However I would have expected it to work with a {1,2,3,4,5}
Yours will match any subdomains with 1-6 characters. What I want is to match longer than 6 characters, like abcdefghijk.example.com
 
Lilarcor
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 54
Joined: Sun Oct 08, 2017 3:16 am

Re: match long domain name

Thu Mar 25, 2021 7:28 am

Bummer, really limited.

Quick and dirty and matching any character number or sign
......\.example\.com$
(........)+.unraid.net
Above works, thank you
 
msatter
Forum Guru
Forum Guru
Posts: 2897
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: match long domain name  [SOLVED]

Thu Mar 25, 2021 5:11 pm

You have use th "\" because yous wiil also match
abcdefrunraid.net
Then using the "()" with the plussign will only match only multiples of the group.

So not abdcefg.unraid.net but it will match abcdefabcdef.unraid.net

Correct is:
.*......\.unraid\.net$
 
Lilarcor
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 54
Joined: Sun Oct 08, 2017 3:16 am

Re: match long domain name

Fri Mar 26, 2021 3:49 am

You have use th "\" because yous wiil also match
abcdefrunraid.net
Then using the "()" with the plussign will only match only multiples of the group.

So not abdcefg.unraid.net but it will match abcdefabcdef.unraid.net

Correct is:
.*......\.unraid\.net$

Thanks for your answer

Who is online

Users browsing this forum: UkRainUa and 16 guests