Community discussions

MikroTik App
 
soulassassino
just joined
Topic Author
Posts: 21
Joined: Thu Aug 04, 2022 3:34 pm

DHCP Option dns failover

Thu Aug 04, 2022 3:47 pm

Hello!

Guys, I have an Adguard instance in my lan, and some of my static leases use it via dhcp option. Any chance to make some failover when Adguard instance in offline?

For example:

1. if 192.168.0.20 (it's Adguard ip) in offline for 1 minute, remove dhcp option field from list of specified leases;
2. if Adguard instance is back online, then set dhcp option to 'adguard' for list of specified leases;

It's possible?
 
soulassassino
just joined
Topic Author
Posts: 21
Joined: Thu Aug 04, 2022 3:34 pm

Re: DHCP Option dns failover

Thu Aug 04, 2022 4:44 pm

I just understand, that I can add second 'option 6' to dhcp options, for example my adguard 192.168.0.20 and second cloudflare 1.1.1.1, and add second option to my specified ips, if my adguard will be offline, second option can be working at this moment, as I underdstand. Need to test it, maybe my question about script can small blood is resolved.
 
gotsprings
Forum Guru
Forum Guru
Posts: 2087
Joined: Mon May 14, 2012 9:30 pm

Re: DHCP Option dns failover

Thu Aug 04, 2022 9:16 pm

I did this with a NAT rule...
I set a rule for 8.8.8.8 and 8.8.4.4 to be redirected to the pihole.

I setup a netwatch to watch the pihole.
Pihole went down... disable redirect in the NAT.
 
soulassassino
just joined
Topic Author
Posts: 21
Joined: Thu Aug 04, 2022 3:34 pm

Re: DHCP Option dns failover

Fri Aug 05, 2022 11:27 am

I did this with a NAT rule...
I set a rule for 8.8.8.8 and 8.8.4.4 to be redirected to the pihole.

I setup a netwatch to watch the pihole.
Pihole went down... disable redirect in the NAT.
Wow, interesting, I didn't think in this direction, can u please explain more about your rule? As I understood, your NAT rule is simple redirected from 8.8.8.8 (for specified leases also) to your pi-hole instance right? Can u share your rule?
 
gotsprings
Forum Guru
Forum Guru
Posts: 2087
Joined: Mon May 14, 2012 9:30 pm

Re: DHCP Option dns failover

Fri Aug 05, 2022 12:28 pm

The router hands 8.8.8.8,8.8.4.4 from the DHCP server. So all clients are trying to send DNS requests to Google.

As I stated... The redirect looks for any thing as dst-address 8.8.8.8 and lands it at the local PI 192.168.1.15.

The netwatch pings the PI. Then enables or disables the NAT rule.
 
soulassassino
just joined
Topic Author
Posts: 21
Joined: Thu Aug 04, 2022 3:34 pm

Re: DHCP Option dns failover

Fri Aug 05, 2022 3:57 pm

Could u please share your netwatch command?

So, your all clients routed to Google or Pi-Hole right? Interesting if in my case I provide ony for some leases my Adguard, I think they need to add to some ip list, and in NAT rule I need to redirected only for this ip addresses list route from my adguard address if it is offline to for example Google or Cloudflare.
 
User avatar
Znevna
Forum Guru
Forum Guru
Posts: 1347
Joined: Mon Sep 23, 2019 1:04 pm

Re: DHCP Option dns failover

Mon Aug 08, 2022 5:52 pm

There are scripts around the forum, do a search for them.
BUT, if you only want to change the DNS IP served to clients via DHCP that might not be ideal, because you can't have such short lease times and not cause wierd problems with some clients.
You could keep adguard on another subnet so the clients have to pass through the router in order to reach it and if it's for some reason down, hijack it's traffic and send it via a failover.
 
soulassassino
just joined
Topic Author
Posts: 21
Joined: Thu Aug 04, 2022 3:34 pm

Re: DHCP Option dns failover

Wed Aug 10, 2022 12:58 pm

Right now, I testing two dns entries in my leases, first it's my adguard, second it's cloudflare dns.

Who is online

Users browsing this forum: eldoncito2019, Ellaham and 16 guests