Page 1 of 1

DHCP Server use different DNS on specified IPs

Posted: Sun Mar 25, 2018 11:37 pm
by RyperX
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

Re: DHCP Server use different DNS on specified IPs

Posted: Sun Mar 25, 2018 11:57 pm
by BartoszP
Do redirect DNS queries for particular IPs with dst-nat rules

Re: DHCP Server use different DNS on specified IPs

Posted: Mon Mar 26, 2018 12:18 am
by RyperX
Was my first idea but it is not working because the DNS Server is on the same subnet as the clients.

Re: DHCP Server use different DNS on specified IPs

Posted: Mon Mar 26, 2018 12:25 am
by BartoszP
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.

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

Posted: Mon Mar 26, 2018 12:28 am
by nickshore
You can add /32s into the DHCP network settings so that you can override settings for individual IPs

Re: DHCP Server use different DNS on specified IPs

Posted: Mon Mar 26, 2018 12:34 am
by RyperX
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 :)

Re: DHCP Server use different DNS on specified IPs

Posted: Sat Jul 27, 2019 4:20 pm
by Datanav
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?