Community discussions

MikroTik App
 
zylantha
just joined
Topic Author
Posts: 11
Joined: Sat Oct 30, 2010 3:06 pm

DNS regexp entries not being recognised as regexp?

Sat Oct 30, 2010 3:41 pm

I'm brand new to RouterOS, and I'm trying to set up an x86 install in a VM to replicate my existing (ClearOS) router functionality before I commit to buying an RB1100.

I've got up to the point where I'm carrying over my internal host names into the static DNS entries, however RouterOS seems to be both more limiting but more powerful - and definitely more frustrating here.

I need two entries for each single IP address, simple "hosts" file functionality equivalent to:
192.168.1.1 router.mydomain.com router

(this is what ClearOS and any ordinary "hosts" file would use, and would resolve both "router" and "router.mydomain.com" to the correct IP address).

Now, without entering in two entries per host (I have a lot of hosts so this is not feasible - and no I'm not setting up a separate DNS server) I understand that under RouterOS I need to use a regular expression to do this. I would think that the following would be correct:
/ip dns static> add address=192.168.1.1 name="router(\\.mydomain\\.com)\?"

but when I add this, it's not recognised as a regular expression:
[admin@router2] /ip dns static> add address=192.168.1.1 name="router(\\.mydomain\\.com)\?"                                                                          
[admin@router2] /ip dns static> print
Flags: D - dynamic, X - disabled, R - regexp 
 #     NAME                                                    ADDRESS                                                                                   TTL         
 0     router(\.mydomain\.com)?                                192.168.1.1                                                                               1d       
(It should have an "R" next to it to show it recognised as a regexp).

If I use the example provided on the documentation page http://wiki.mikrotik.com/wiki/Manual:IP ... NS_Entries it seems to at least recognise that entry as a regexp:
[admin@router2] /ip dns static> add address=192.168.1.1 name=".*\\.example\\.com"
[admin@router2] /ip dns static> print
Flags: D - dynamic, X - disabled, R - regexp 
 #     NAME                                                    ADDRESS                                                                                   TTL         
 0     router(\.mydomain\.com)?                                192.168.1.1                                                                               1d          
 1   R .*\.example\.com                                        192.168.1.1                                                                               1d
According to the documentation "In case an entry does not conform with DNS naming standards, it is considered a regular expression and marked with ‘R’ flag." but what is it that determines whether
RouterOS agrees that it is a regular expression rather than a regular host name?

Incidentally, lookup against the non-regexp-recognised entries does not work:
[admin@router2] /ip dns static> /ping router
HOST                                    SIZE  TTL TIME  STATUS                                                                                                       
67.215.65.132                           56    49  181ms
67.215.65.132                           56    49  180ms
    sent=2 received=2 packet-loss=0% min-rtt=180ms avg-rtt=180ms max-rtt=181ms 

[admin@router2] /ip dns static> print
Flags: D - dynamic, X - disabled, R - regexp 
 #     NAME                                                    ADDRESS                                                                                   TTL         
 0     router(\.mydomain\.com)?                                192.168.1.1                                                                               1d          
 1   R .*\.example\.com                                        192.168.1.1                                                                               1d          
 2     router|router\.mydomain\.com                            192.168.1.1                                                                               1d     
Also, it seems that RouterOS strangely believes that a regexp needs to begin with a "." to recognise it as one -
[admin@router2] /ip dns static> add address=192.168.1.1 name=".router(\\.mydomain\\.com)\?"   
[admin@router2] /ip dns static> print
Flags: D - dynamic, X - disabled, R - regexp 
 #     NAME                                                    ADDRESS                                                                                   TTL         
 0   R .router(\.mydomain\.com)?                               192.168.1.1                                                                               1d          
[admin@router2] /ip dns static> /ping router
HOST                                    SIZE  TTL TIME  STATUS                                                                                                       
67.215.65.132                           56    49  180ms
67.215.65.132                           56    49  180ms
    sent=2 received=2 packet-loss=0% min-rtt=180ms avg-rtt=180ms max-rtt=180ms 
... but this still doesn't give you a simple working host entry.

Am I missing something, or is this functionality not quite right?
 
timjosten
just joined
Posts: 1
Joined: Thu Oct 29, 2015 9:40 pm

Re: DNS regexp entries not being recognised as regexp?

Thu Oct 29, 2015 9:51 pm

I am struggling with these strange regular expressions too. I confirm, that the string has to begin with a dot to be considered as a regex. This is strange, because in other places it has to begin with a colon. Also, RouterOS uses basic regular expressions for this particular place, it is a very limited version of regular expressions back from the old Unix days and GREP utility (circa 1980). It has another syntax, not common, where most of reserved characters need to be escaped.

So, for your task this should be working, however it has some limitations:
.*router\(\.mydomain\.com\)*$

it matches "router", "router.mydomain.com", "rrrrrouter". The problem is that we cannot use a starting position character, because we are forced to start a regex with a dot character...

Who is online

Users browsing this forum: NetworqAndy, rmuhammadali, stef70, tigro11, VladimirG, xrlls and 77 guests