Community discussions

MikroTik App
 
bennhana
just joined
Topic Author
Posts: 17
Joined: Tue Jul 07, 2015 11:51 am

Router losing time settings

Thu Sep 07, 2017 11:31 am

I don't know where to post this so I just chose the Genera post. I have a client who is running RB2011UiAS-2HnD. This router is giving problems. It keeps losing clock settings which I setup for time-based firewall filters. Every time I try to log into the router it kicks me out after 2 minutes. I have checked if they are consuming bandwidth but no. It happened before I reset it to factory default and reconfigured it. Now its started again. It is running OS v6.39.2. I wanted to upgrade but I am failing because it keeps kicking me out. Is this an OS problem or is the hardware dying? Has anyone ever come across this? I need help, please.

Thanks in advance.
 
tholderbaum
newbie
Posts: 38
Joined: Thu Jan 23, 2014 3:34 am
Location: Tampa, Florida
Contact:

Re: Router losing time settings

Thu Sep 14, 2017 7:27 pm

I don't know where to post this so I just chose the Genera post. I have a client who is running RB2011UiAS-2HnD. This router is giving problems. It keeps losing clock settings which I setup for time-based firewall filters. Every time I try to log into the router it kicks me out after 2 minutes. I have checked if they are consuming bandwidth but no. It happened before I reset it to factory default and reconfigured it. Now its started again. It is running OS v6.39.2. I wanted to upgrade but I am failing because it keeps kicking me out. Is this an OS problem or is the hardware dying? Has anyone ever come across this? I need help, please.

Thanks in advance.
Mikrotiks do not have an internal clock. The mikrotik is supposed to get it's time from an NTP server. The problem being that sometimes NTP servers move or are no longer available. Here is what I do on all my firewalls: /system clock
set time-zone-autodetect=no time-zone-name=America/New_York
/system ntp client
set enabled=yes primary-ntp=184.105.182.7 secondary-ntp=198.58.105.63
/system ntp server
set enabled=yes multicast=yes
[/code]

This is the base setup. Now I run an NTP Update Script to update the NTP entries as needed:
add name=GlobalVars owner=admin policy=\
    ftp,reboot,read,write,policy,test,password,sniff,sensitive source="# Syste\
    m configuration script - \"GlobalVars\"\r\
    \n\r\
    \n:put \"Setting system globals\";\r\
    \n\r\
    \n# System name\r\
    \n:global SYSname [/system identity get name];\r\
    \n\r\
    \n# NTP pools to use (check www.pool.ntp.org)\r\
    \n:global SYSntpa \"0.pool.ntp.org\";\r\
    \n:global SYSntpb \"1.pool.ntp.org\";"
    
add name=setntppool owner=admin policy=\
    ftp,reboot,read,write,policy,test,password,sniff,sensitive source="# Check\
    \_and set NTP servers - \"setntppool\"\r\
    \n\r\
    \n# We need to use the following globals which must be defined here even\r\
    \n# though they are also defined in the script we call to set them.\r\
    \n:global SYSname;\r\
    \n:global SYSsendemail;\r\
    \n:global SYSmyemail;\r\
    \n:global SYSmyname;\r\
    \n:global SYSemailserver;\r\
    \n:global SYSntpa;\r\
    \n:global SYSntpb;\r\
    \n\r\
    \n# Load the global variables with the system defaults\r\
    \n/system script run GlobalVars\r\
    \n\r\
    \n# Resolve the two ntp pool hostnames\r\
    \n:local ntpipa [:resolve \$SYSntpa];\r\
    \n:local ntpipb [:resolve \$SYSntpb];\r\
    \n\r\
    \n# Get the current settings\r\
    \n:local ntpcura [/system ntp client get primary-ntp];\r\
    \n:local ntpcurb [/system ntp client get secondary-ntp];\r\
    \n\r\
    \n# Define a variable so we know if anything's changed.\r\
    \n:local changea 0;\r\
    \n:local changeb 0;\r\
    \n\r\
    \n# Debug output\r\
    \n:put (\"Old: \" . \$ntpcura . \" New: \" . \$ntpipa);\r\
    \n:put (\"Old: \" . \$ntpcurb . \" New: \" . \$ntpipb);\r\
    \n\r\
    \n# Change primary if required\r\
    \n:if (\$ntpipa != \$ntpcura) do={\r\
    \n    :put \"Changing primary NTP\";\r\
    \n    /system ntp client set primary-ntp=\"\$ntpipa\";\r\
    \n    :set changea 1;\r\
    \n    }\r\
    \n\r\
    \n# Change secondary if required\r\
    \n:if (\$ntpipb != \$ntpcurb) do={\r\
    \n    :put \"Changing secondary NTP\";\r\
    \n    /system ntp client set secondary-ntp=\"\$ntpipb\";\r\
    \n    :set changeb 1;\r\
    \n    }\r\
    \n\r\
    \n"   
Then you just schedule the setntppool script to run as often as you need it too. This puts the mikrotik into polling mode and keeps them up to date. Since I put this in place, I do not have time issues.