I run a network over vpns and I am routing across the vpn multiple networks. I want to keep a central MK (say 10.0.11.254) with static DNS entries for machines across the network, so I am wondering how can each remote router perform a DNS request to this router (10.0.11.254) only when resolving hostnames that end with .local
Sure it is. Something like this should do the work. Requests comes in on ‘ether1’ aimed for the router and all requests for *.local will be redirected to 1.1.1.1
Well you are right that you can false positive matches, but not with something like www.localtaxi.com, only with something like local.com or www.local.com (the \x05 part makes sure of that). I have tried a few ways to enhance it, and this filter even them out:
the L7 regex matcher filter out all \x00, so you can’t match on them, but you can match on what it left
This only work for UDP DNS requests, TCP connections will already have been established before the data packet arrives, so it will be to late to redirect. So no need for TCP matching, on the other hand, if the DNS requests should be TCP based, then there is no way for RouterOS to redirect them, that would require a true DNS forwarder capability (hint hint nudge nudge MikroTik).
The masquerade NAT rule is needed, so replies comes back to the router, so it can be properly NATed back to the client, or they will be sent directly to the client form an unexpected host.
I will admit, I don’t know anything about REGEX expressions.
Could you please tell me how to form the REGEX expression if I wanted a specific domain DNS redirected? Using your example above, it would be domain.com instead of domain.local. What does the /05x mean?
The trailing \x01\x01, to filter out false positives (as suggested by psamsig), looks like a good idea, but the first \x01 is actually query type, so it will match A record queries only. To match all record types, this should work (but I can’t test it now):