Community discussions

MikroTik App
 
RyperX
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 72
Joined: Thu May 21, 2015 11:14 am

DHCP Server use different DNS on specified IPs

Sun Mar 25, 2018 11:37 pm

Hello guys,

i need your help. I have a DHCP running in my network and set to use the mikrotik router as DNS Server.
On the same network are also 3 Devices that should use a different DNS Server.

Is it possible after reserving an IP Adress to set an different DNS Server only for the specified adress?
As i understand the DNS Setting can only set in the DHCP Server - Networks Setting, in which i set the full /24 network (in which are the 3 hosts)

Or do you have an simplier idea todo this? (I could set it by static but would prefer over dhcp)

Thanks and best regards
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 2879
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: DHCP Server use different DNS on specified IPs

Sun Mar 25, 2018 11:57 pm

Do redirect DNS queries for particular IPs with dst-nat rules
 
RyperX
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 72
Joined: Thu May 21, 2015 11:14 am

Re: DHCP Server use different DNS on specified IPs

Mon Mar 26, 2018 12:18 am

Was my first idea but it is not working because the DNS Server is on the same subnet as the clients.
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 2879
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: DHCP Server use different DNS on specified IPs

Mon Mar 26, 2018 12:25 am

You need to implement Harpin procedure.
make dst-nat rule to redirect queries to new DNS server and src-nat to make packets look like coming from router.
 
User avatar
nickshore
Long time Member
Long time Member
Posts: 521
Joined: Thu Mar 03, 2005 4:14 pm
Location: Suffolk, UK.
Contact:

Re: DHCP Server use different DNS on specified IPs  [SOLVED]

Mon Mar 26, 2018 12:28 am

You can add /32s into the DHCP network settings so that you can override settings for individual IPs
 
RyperX
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 72
Joined: Thu May 21, 2015 11:14 am

Re: DHCP Server use different DNS on specified IPs

Mon Mar 26, 2018 12:34 am

Mmh i exactly understand how hairpin-nat is helping, maybe i dont understand it correct^^

My network:
address-pool=dhcp-local authoritative=after-2sec-delay disabled=no interface=bridge1 lease-time=1d name=dhcp-local
address=192.168.1.0/24 dns-server=192.168.1.2,192.168.1.3 gateway=192.168.1.1 netmask=24

Clients 192.168.1.121-139 should recieve the DNS Server from another network 192.168.2.1 for example.

The problem why the dst-nat rule is not working for the moment is because the dns request doesnt get through the router the DNS Servers 192.168.1.2 and 192.168.1.3 will contacted directly.
Or did you mean something else?

Edit:
@nickshore
I will try thanks
Is this correct?
address=192.168.1.121/32 dns-server=192.168.2.1 gateway=192.168.1.1 netmask=24 ntp-server=192.168.1.1

Edit2:
Thanks it is working :)
 
Datanav
just joined
Posts: 22
Joined: Mon Jul 15, 2019 8:06 pm
Location: Nairobi, Kenya
Contact:

Re: DHCP Server use different DNS on specified IPs

Sat Jul 27, 2019 4:20 pm

Mmh i exactly understand how hairpin-nat is helping, maybe i dont understand it correct^^

My network:
address-pool=dhcp-local authoritative=after-2sec-delay disabled=no interface=bridge1 lease-time=1d name=dhcp-local
address=192.168.1.0/24 dns-server=192.168.1.2,192.168.1.3 gateway=192.168.1.1 netmask=24

Clients 192.168.1.121-139 should recieve the DNS Server from another network 192.168.2.1 for example.

The problem why the dst-nat rule is not working for the moment is because the dns request doesnt get through the router the DNS Servers 192.168.1.2 and 192.168.1.3 will contacted directly.
Or did you mean something else?

Edi
@nickshore
I will try thanks
Is this correct?
address=192.168.1.121/32 dns-server=192.168.2.1 gateway=192.168.1.1 netmask=24 ntp-server=192.168.1.1

Edit2:
Thanks it is working :)
How were able to implement this? can you lay down the steps for me?

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 37 guests