Community discussions

MikroTik App
 
iantull
just joined
Topic Author
Posts: 5
Joined: Wed Mar 01, 2023 12:32 am

Help routing 1 internal IP address to a different dns server

Tue Feb 27, 2024 11:08 am

I am using the DHCP Server function to allocate my IP range on connected devices, but I also have some Static IP allocations that are dependant on the MAC address of the connected device. On one device I require it to point to an internal DNS Server, rather than the external DNS Server that the rest are using. I am unable to set this within the device itself so I need to do this somehow externally.
I have a DNS Server configured in the DHCP Server in my Mikrotik that points to say 1.1.1.1 so all my connections would use that, how can I configure one only IP, say 192.168.3.24 to use my internal DNS Server at 192.168.3.2

Any help would be appreciated.

Ian
 
erlinden
Forum Guru
Forum Guru
Posts: 2010
Joined: Wed Jun 12, 2013 1:59 pm
Location: Netherlands

Re: Help routing 1 internal IP address to a different dns server

Tue Feb 27, 2024 11:26 am

You might be able to route all DNS requests of this device to your specific DNS server:
add action=dst-nat chain=dstnat dst-port=53 src-address=[Device IP] protocol=udp to-addresses=[DNS IP] to-ports=53
add action=dst-nat chain=dstnat dst-port=53 src-address=[Device IP]  protocol=tcp to-addresses=[DNS IP] to-ports=53
 
User avatar
baragoon
Member
Member
Posts: 315
Joined: Thu Jan 05, 2017 10:38 am
Location: Kyiv, UA
Contact:

Re: Help routing 1 internal IP address to a different dns server

Tue Feb 27, 2024 11:28 am

I think that better option is dhcp-option 6
 
rplant
Member
Member
Posts: 337
Joined: Fri Sep 29, 2017 11:42 am

Re: Help routing 1 internal IP address to a different dns server

Tue Feb 27, 2024 12:51 pm

You can make a dhcp server network entry for the specific static ip address,
with required dns server, etc.
 
User avatar
baragoon
Member
Member
Posts: 315
Joined: Thu Jan 05, 2017 10:38 am
Location: Kyiv, UA
Contact:

Re: Help routing 1 internal IP address to a different dns server

Tue Feb 27, 2024 12:55 pm

Why to complicate the things? Create dhcp-option with desired DNS server and attach it to the static lease.
 
iantull
just joined
Topic Author
Posts: 5
Joined: Wed Mar 01, 2023 12:32 am

Re: Help routing 1 internal IP address to a different dns server

Wed Feb 28, 2024 6:27 am

Thanks for the suggestions, I'd like to try the dhcp-option @baragoon but I'm not really familiar with how this works. I can see from some online info that I need to convert to hex for the value entry, but I'm not sure what I would need to enter into this ? Also what code would I be using ??

Ian
 
User avatar
baragoon
Member
Member
Posts: 315
Joined: Thu Jan 05, 2017 10:38 am
Location: Kyiv, UA
Contact:

Re: Help routing 1 internal IP address to a different dns server

Wed Feb 28, 2024 7:43 am

/ip dhcp-server option
add code=6 name=my_dns value="'IP.ADD.RE.SS'"
/ip dhcp-server lease
set dhcp-option=my_dns numbers=X
 
iantull
just joined
Topic Author
Posts: 5
Joined: Wed Mar 01, 2023 12:32 am

Re: Help routing 1 internal IP address to a different dns server

Wed Feb 28, 2024 11:00 pm

Thanks @baragoon, that worked, I didn't realise about double and single quotes in the entry for the IP address. Good to know and glad to learn that.

Ian
 
jaclaz
Forum Veteran
Forum Veteran
Posts: 733
Joined: Tue Oct 03, 2023 4:21 pm

Re: Help routing 1 internal IP address to a different dns server

Wed Feb 28, 2024 11:14 pm

May I ask what Is the meaning of
numbers=X
I tried but could not find references to that in the manual page:
https://help.mikrotik.com/docs/display/ROS/DHCP
 
User avatar
baragoon
Member
Member
Posts: 315
Joined: Thu Jan 05, 2017 10:38 am
Location: Kyiv, UA
Contact:

Re: Help routing 1 internal IP address to a different dns server

Thu Feb 29, 2024 8:00 am

May I ask what Is the meaning of
numbers=X
I tried but could not find references to that in the manual page:
https://help.mikrotik.com/docs/display/ROS/DHCP
When you print something (not dhcp only) you will see a numbers on the left, every unique number corresponds a line. If you want to change specific line it easy to use this number.
 
jaclaz
Forum Veteran
Forum Veteran
Posts: 733
Joined: Tue Oct 03, 2023 4:21 pm

Re: Help routing 1 internal IP address to a different dns server

Thu Feb 29, 2024 10:44 am

Thanks, so like just (say) routes or IP addresses, I didn't know it could be used this way, I only used sometimes the other way, like:
set <number(s)> <parameter>=<value>
I couldn't find reference to this alternate syntax on the console help page, good to know. :)

Who is online

Users browsing this forum: ariux, deuser, muhammadh and 28 guests