Community discussions

MikroTik App
 
nbctcp
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 59
Joined: Tue Sep 16, 2014 7:32 pm

Check DHCP Server Status

Fri Oct 16, 2020 9:17 am

Hi,

I have 2x DHCP Server in each Mikrotik
Let say DHCP1 and DHCP2
DHCP1 will always up and serving full subnet, DHCP2 always down or vice versa

GOAL:
-I want DHCP2 script will detect if DHCP1 service is down and vice versa
If down then bring up DHCP2, disable DHCP1 service someting like"# /etc/init.d/dhcp stop"

QUESTIONS:
1. how DHCP2 detect status of DHCP1 because I can't use netwatch.
netwatch only check host is up but not dhcp
2. if no script to check DHCP1 down from DHCP2 then any possibility for DHCP2 to check status of itself

tq

UPDATE1:
to enable/disable local dhcp are these
/ip dhcp-server enable 0
/ip dhcp-server disable 0

UPDATE2
using ssh-exec could disable dhcp1 remotely
https://wiki.mikrotik.com/wiki/Manual:S ... ertificate

Only check dhcp server status remotely left
 
sindy
Forum Guru
Forum Guru
Posts: 5918
Joined: Mon Dec 04, 2017 9:19 pm

Re: Check DHCP Server Status  [SOLVED]

Fri Oct 16, 2020 11:03 am

Check this. For your purpose, it is sufficient to just revert the usage logic. Instead of taking an action when the "rogue" (=other) DHCP server is detected, take an action (activate the local dhcp server) when the other one disappears from the unknown-server list (i.e. when the list becomes empty). To do that, you need to schedule a test script every minute or so to check for the contents of the list, and if it is empty, activate your own server.

The rest of the setup depends on whether you prefer the last server active to stay up or whether you prefer that one of the two would be active whenever it is fit.

But DHCP server settings allow to set one of them a secondary one which only offers/assigns addresses if the primary one doesn't, so you should not need the above DIY setup.
Instead of writing novels, post /export hide-sensitive. Use find&replace in your favourite text editor to systematically replace all occurrences of each public IP address potentially identifying you by a distinctive pattern such as my.public.ip.1.
 
nbctcp
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 59
Joined: Tue Sep 16, 2014 7:32 pm

Re: Check DHCP Server Status

Fri Oct 16, 2020 11:24 am

I got your point
OPTION1
no need script to enable local dhcp if remote dhcp down by using primary/secondary dhcp server
I think this what you mean
https://www.youtube.com/watch?v=Cpu_76WidAo
Need to test again whether same subnet 2x DHCP Server with delay threshold will causing ip conflict or not

OPTION2:
viewtopic.php?t=68738
make each DHCP1 and DHCP2 subnet large enough to handle my host
pros, I can make both DHCP active/active
cons, do you think too much broadcast for /23?
Check this. For your purpose, it is sufficient to just revert the usage logic. Instead of taking an action when the "rogue" (=other) DHCP server is detected, take an action (activate the local dhcp server) when the other one disappears from the unknown-server list (i.e. when the list becomes empty). To do that, you need to schedule a test script every minute or so to check for the contents of the list, and if it is empty, activate your own server.

The rest of the setup depends on whether you prefer the last server active to stay up or whether you prefer that one of the two would be active whenever it is fit.

But DHCP server settings allow to set one of them a secondary one which only offers/assigns addresses if the primary one doesn't, so you should not need the above DIY setup.

Who is online

Users browsing this forum: Bing [Bot], RogerWilco, vecernik87, vlarsen and 110 guests