It would be very nice if the built-in DNS server could selectively forward domains to servers. In dnsmasq this is done with the syntax:
server=/lan/10.1.2.3
This will send all requests ending in .lan to 10.1.2.3.
This is especially useful when e.g. the Active Directory servers are behind a VPN connection. If the VPN connection breaks, it is still possible to reach the rest of the Internet. Without this feature, all DNS requests have to go to the Active Directory servers.
I’m using mikrotik router at home, with RB150 constantly handling connection to provider (PPPoE) and to my office (VPN over internet).
However since router is using provider’s DNS, it is not possible to work with shared folders or perform any other domain tasks (while office IPs are readily accessible). Anything using active directory will fail, since any computer in home won’t be able to resolve domain controllers.
How to fix this:
added layer7 matcher for \x06\x5Fmsdcs\x08mydomain\x03com
(you need to replace mydomain.com with your domain address).
each domain part preceded with \x and number of characters in hex, \x5F is _ symbol.
whenever computer tries to find active directory servers it requests for multiple DNS records all ending with _msdcs.yourdomain.com.
I had similar problem, not with Active directory, but I also had need to have internal DNS resolving.
I solved it bu setting everything to used my internal DNS server which responds to all requests. If requests for internal domain, it proper information as he knows it, but if request is for regular internet domains, it would then ask ISP DNS about it and then pass on the response.
Nice to know, but that’s not it. In fact, there are three different things here:
this last regular expression
It will return an A record pointing at 10.1.2.3 for any A record query with hostname ending with “.somedomain”
clever hack above
It will forward any query with hostname ending with “.somedomain” do different dns server. Then different domains can resolve correctly e.g. mail.somedomain to 10.1.2.3, www.somedomain to 192.168.1.2, etc.. as long as the given server controls all of them, including subdomains.
fully working implementation
I’d tell RoS that domain “.somedomain” is controlled by dns server 10.1.2.3. Then client sends question for “www.subdomain.somedomain”. RoS asks 10.1.2.3 for it and 10.1.2.3 replies “I don’t know, whole subdomain.somedomain is controlled by 10.20.30.40”. RoS sends original query to 10.20.30.40 and gets reply that www.subdomain.somedomain has ip address 192.168.44.11.
There is no way how to do this in current RoS and the only solution is recursive resolver, not just forwarding as the current one.
Ahh I see. Sorry for my misunderstanding of the original post.
Personally, I use Bind DNS server and it handles DNS very well (as it’s a DNS server). If you have a RouterBoard that supports MetaRouter, or x86 using KVM, you could install OpenWRT and use Bind on top of RouterOS.
I second Wakko, that would be a great functionality for remote sites that uses VPN to access servers… They would not loose dns resolution when the VPN fail.
We currently use the brainsucker’ workaround for small sites but it is somewhat hard to maintain.
Erm, do you really think this was worth digging up a thread after six years? And how exactly is this info supposed to close it?
It’s still the same old and ugly (even though it’s pretty smart, no doubt about that part) L7 hack, which does bypass router’s DNS cache, doesn’t work with tcp, can’t be used with IPv6, and it’s just not admin-friendly at all. And as a bonus, your regexp is wildly inaccurate, it matches office.local, but also notoffice.local, office-local.com, …
Your only excuse is that any exposure for this missing feature is a good thing.
1.) Is there any chance to make it work for TCP? I guess the reason is that the actual content is in the packets after SYN, SYN-ACK, ACK so that the first three packages of the connection cannot be marked?
No, because when you get match for your L7 filter, connection is already established and can’t be redirected elsewhere. Luckily, clients don’t seem to use TCP (but it can happen).
It should be proper regexp, sure. But DNS packets do not contain dots. Instead, they have single bytes containing length of next name part. For your individual domains it’s:
To help with false positives, you can also add this to the end:
.\x01
where “.” matches record type (with exception of some non-common ones with code > 255) and \x01 is query class, which is always 1 (for normal use). It’s not too important with complex enough domains like yours. Without it, you’d get false positive for e.g. intra.mydomain.net.someotherdomain.com, but it’s unlikely to ever have query for such name.
Sob, you just made my day, i was having issues with CNAMES that had my domain name as part of it, like domain.com.s3.amazonaws.com… your tip of .\x01 fixed it!