We have a dhcp server installed on a main linux router, a centos 6.3 with squid 3.1, ntp server and also freeradius along with mysql server installed on it. As a router for client and a hotspot server we have a Mikrotik 5.12 os installed on RB1200 power pc. Our daily problem is the electrical power source which down frequently for up to 2 hours nearly everyday.
As the power source resumed, mikrotik hotspot boot up and ready after a few seconds while the main router still showing up the bios screen. So, our hotspot was running without a valid ip address since the dhcp server wasn’t ready at that moment. But even tough the dhcp server up, mikrotik dhcp client didn’t request for a new address anymore and will keep using the default address for hours until renew or release requested manually, reducing leases time on server somehow didn’t resolve the problem.
Instead of manually clicking renew or release on mikrotik dhcp client when the server up, we created a simple scheduler which run a script every 5 minutes to check the network address and keep request new address every 5 minutes if the network address is not the address supposed to given to the mikrotik dhcp client until new address provided. The following are details steps.
Create a simple script
Go to System -> Scripts, add a new script. Add the following script;
Where 10.10.8.0 is your network address. It will check for your address, if the current network address doesn’t match with the network address provided within the script then the script will run a request for a new address on mikrotik dhcp client.
Create a schedule task
Assume you are managing mikrotik using winbox, go to System -> Scheduler. Add new schedule task, set start time to “startup” and set interval to “00:05:00” (5 minutes). On the “On Event” box put a command to run the network address checker script (our previous script).
Rrun script number 1 from the script list every 5 minutes (script list start from number zero “0”).
UPDATE:
I got an information from friend telling me that sometime his mikrotik didn’t renew the address even though the script was executed by scheduler. But he also made a solution by changing the script from renew to release. The script will be :
Hope this update helpful, thanks to my friend for informing the problem also providing the solution.