• MikroTik.com
  • RouterBOARD
  • User Meeting
  • Training
  • User Manual
  • Support
  • Downloads
  • Videos
Register |   * Login | HOME

View unanswered posts | View active topics

Conditional DNS forwarding  Page 1 of 1
 [ 7 posts ]  Post new topic Reply to topic
  Print view Previous topic | Next topic 
Author Message
marcodor
 Post subject: Conditional DNS forwarding
PostPosted: Tue Jan 25, 2011 9:05 pm 
Offline
just joined

Joined: Tue Jan 25, 2011 8:44 pm
Posts: 3
Karma: 0
Hello,

We deployed routerboards in our regional branches.
All our remote computers belongs to ms active directory domain, domain controllers are located in central office.
Dns servers for remote computers are set to domain controllers, for a proper AD work.
Now, I want to setup routerboard to act as DNS server for remote computers, and forward DNS queries in a smart way:
if NAME ends with my zone to forward queries to my domain controllers, else forward them to local internet provider.
This will improve response speed, and network performance.

Something like bind has:

zone "mydomain.com" {
type forward;
forward only;
forwarders { 22.22.22.22; };
};

PLEASE include it in TODO list for v5, i think it's not hard to implement it, as you already have forwarders. :)
Just define "Dns Zones" as entities and linked forwarders to that zone.

Thanks in advice!


Top
 Profile  
 
mindlesstux
 Post subject: Re: Conditional DNS forwarding
PostPosted: Thu Jan 27, 2011 3:59 pm 
Offline
just joined

Joined: Tue Mar 17, 2009 3:20 pm
Posts: 11
Karma: 1

Location: Charlotte, NC, USA
I have not tested this, yet, but it should be possible to create a layer7 protocol that digs into the DNS packet and matches the domain. If the domain is matched then just silently redirect the packet to the proper dns server.


I will post again once I find time to craft and test this.


Top
 Profile  
 
janisk
 Post subject: Re: Conditional DNS forwarding
PostPosted: Thu Jan 27, 2011 4:25 pm 
Offline
MikroTik Support
MikroTik Support
User avatar

Joined: Tue Feb 14, 2006 9:46 am
Posts: 4811
Karma: 37

Location: Riga, Latvia
just be sure that packet that come from that other DNS resolver are with correct src address in reply, other way packet will be rejected by host, how initiated the process.


Top
 Profile  
 
mindlesstux
 Post subject: Re: Conditional DNS forwarding
PostPosted: Thu Jan 27, 2011 5:02 pm 
Offline
just joined

Joined: Tue Mar 17, 2009 3:20 pm
Posts: 11
Karma: 1

Location: Charlotte, NC, USA
Here is a little run down on how to do this, the only thing left to do is to check what janisk says but im pretty sure this handles it decently enough.
Code:
/ip firewall layer7-protocol
add name=testdns regexp=lantest.mindlesstux.com

/ip firewall nat
add action=dst-nat chain=dstnat disabled=no dst-address=4.2.2.2 dst-port=53 layer7-protocol=testdns protocol=udp to-addresses=8.8.8.8 to-ports=53
add action=dst-nat chain=dstnat disabled=no dst-address=4.2.2.2 dst-port=53 layer7-protocol=testdns protocol=tcp to-addresses=8.8.8.8 to-ports=53

1. Change the regex to match your domain.
2. Change 4.2.2.2 to be your RB DNS server
3. Change 8.8.8.8 to be your AD DNS server

*edit*
/me applies this little craft for his work domain on his home RB


Top
 Profile  
 
fewi
 Post subject: Re: Conditional DNS forwarding
PostPosted: Thu Jan 27, 2011 5:26 pm 
Offline
Forum Guru
Forum Guru

Joined: Tue Aug 11, 2009 2:19 am
Posts: 7737
Karma: 327
To make sure this works on all networks regardless of hops and directly connected servers and clients, you could run the test for the regex in prerouting and just mark the packet, and then do both source and destination NAT on the packet so that it's forced back to the router, enabling it to send it back to the client in a format the client expects:
Code:
/ip firewall layer7-protocol
add name=testdns regexp=lantest.mindlesstux.com

/ip firewall mangle
add chain=prerouting dst-address=4.2.2.2 protocol=udp dst-port=53 layer7-protocol=testdns action=mark-connection new-connection-mark=forwarded-dns
add chain=prerouting dst-address=4.2.2.2 protocol=tcp dst-port=53 layer7-protocol=testdns action=mark-connection new-connection-mark=forwarded-dns

/ip firewall nat
add action=dst-nat chain=dstnat connection-mark=forwarded-dns to-addresses=8.8.8.8
add action=masquerade chain=srcnat connection-mark=forwarded-dns


Or something like that.

_________________
Specific answers require specific questions. When in doubt, post the output of "/ip address print detail", "/ip route print detail", "/interface print detail", "/ip firewall export", and an accurate network diagram.


Top
 Profile  
 
mindlesstux
 Post subject: Re: Conditional DNS forwarding
PostPosted: Thu Jan 27, 2011 6:12 pm 
Offline
just joined

Joined: Tue Mar 17, 2009 3:20 pm
Posts: 11
Karma: 1

Location: Charlotte, NC, USA
wow, did not even think of that... that seems like that should be a better solution.


Also should this thread not be moved to a different forum due to its not really a beta issue anymore?


Top
 Profile  
 
marcodor
 Post subject: Re: Conditional DNS forwarding
PostPosted: Fri Jan 28, 2011 3:52 pm 
Offline
just joined

Joined: Tue Jan 25, 2011 8:44 pm
Posts: 3
Karma: 0
Hello,

Big thanks to all experts for suggestiong solutions for this task.
I'll try to apply it, but it is a bit complicated for me, layer7, mangle, prerouting ... a lot of rules, a lot of router cpu usage.
I'd like to have it in DNS area of winbox, and with 2 clicks done it.

Anyway, to developers, take it in account,

I suppose dns zone forwarders, masters are a part of DNS standart, if BIND implemented it.

Thanks in advice!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  Page 1 of 1
 [ 7 posts ] 

Board index » RouterOS » RouterOS BETA

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Karma functions powered by Karma MOD © 2007, 2009 m157y