tenhishadow / mbkp

Mikrotik backup script | simple bash script for doing encrypted backups of mikrotik devices(Routeros) via ssh. Script will do password-protected binary and encrypted with openssl export on regular basis
MIT License
25 stars 12 forks source link

ntp servers #1

Closed lucianosds closed 6 years ago

lucianosds commented 6 years ago

Saw that the ntp servers are empty. só suggest to configure 0.pool.ntp.org and 1.pool.ntp.org. in that way if somebody forget to configure, this is already configured.

tenhishadow commented 6 years ago

Hi, 50.50. I did it especially for more stability. According to mikrotik wiki https://wiki.mikrotik.com/wiki/Manual:System/Time#SNTP_client

if both values are non-zero, then SNTP client will alternate between the two server addresses, switching to the other when request to the current server times out or when the "KoD" packet is received

So, directive primary-ntp and secondary-ntp will configure SNTP client to communicate with two servers only. Using directive server-dns-names (Comma separated domain name list default: ) we can set ntp pool which is most reliable to receive NTP. One thing that we need to keep in mind - it could not work without DNS configured.

It works well: [rmgmt01@vl-nmr01] > system ntp client print enabled: yes primary-ntp: 0.0.0.0 secondary-ntp: 0.0.0.0 server-dns-names: 0.ru.pool.ntp.org,1.ru.pool.ntp.org,2.ru.pool.ntp.org,3.ru.pool.ntp.org mode: unicast poll-interval: 15m active-server: 94.247.111.10 last-update-from: 94.247.111.10 last-update-before: 16m33s430ms last-adjustment: 5ms477us last-bad-packet-from: 10.1.201.249 last-bad-packet-before: 12m8s350ms last-bad-packet-reason: server-ip-mismatch

P.S. I suppose I wil rewrite it with your improvement, but not within this pool request. I think that it would be great to avoid hardcoding any configuration in backup script. That's why I will divide code into 2 parts: first will just handle backup logic and second will be optional part which includes some configuration which is common for the most of setups, but it should be optional.

P.P.S. I am going to rewrite this code on golang because it's more reliable than a script. Also golang, python allows do ssh connection in single thread/iteration. As you can see my script initiates more than 2 ssh-connections :) It's not so cute as a single action.