LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-14-2019, 10:41 AM   #1
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Rep: Reputation: 8
Configure own "pool" of NTP servers in LAN


I have 3 NTP server in my LAN. They are based on RPi, QNAP NAS and Linux satellite receiver. Additionally RPi and QNAP NAS acts as DHCP/DNS server (both for LAN and Internet) using dnsmasq. All NTP servers are configured as "stratnum 0". Four time per day, RPi and QNAP NAS sync own RTC and system time with Internet server while Linux based satellite receiver sync on-line time with time provided by HotBird satellite. I want to create "pool" of NTP server similar to pool.ntp.org but dedicate for LAN nodes. How should I configure dnsmasq DNS server to have the same functionality? I mean in case of failure first NTP server, second one is used and the third at the end. Can somebody help me?

Last edited by mackowiakp; 08-14-2019 at 10:44 AM. Reason: grammar errors
 
Old 08-14-2019, 04:22 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,812

Rep: Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958
Technically I believe they should be stratum 1 and not 0 but probably does not matter.

As far as I know the pools are run by the NTP Pool project and I am not sure how to create your own. You can add each server to the clients ntp.conf file and the client will automatically determine which one has the "best" time and use that as the source just the same as a pool and if one fails it will not be used. The purpose of a pool is to distribute the load but you only have 3 so it does not matter.

Quote:
Four time per day, RPi and QNAP NAS sync own RTC and system time with Internet server while Linux based satellite receiver sync on-line time with time provided by HotBird satellite.
Depending on how well the system clocks are disciplined and how they drift four times a day may not be enough. The client will poll the servers at a faster interval and if the server has a lot of jitter it will not be used.
 
Old 08-14-2019, 10:48 PM   #3
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
But look at the nslookup output:

Code:
[maciek@Piotr ~]$ nslookup pool.ntp.org
Server:         192.168.0.201
Address:        192.168.0.201#53

Non-authoritative answer:
Name:   pool.ntp.org
Address: 213.199.225.30
Name:   pool.ntp.org
Address: 91.212.242.20
Name:   pool.ntp.org
Address: 192.86.14.67
Name:   pool.ntp.org
Address: 193.70.94.182
So 3 servers have the same name. So I try to add similar entry's to dnsmasq so 3 servers have two names for example "pvr" and "pool.home", "qnap" and "pool.home", "malina" and "pool.home" defined in dnsmasq config files. First is (in the order of dnsmasq) "malina"/"pool.home". If "malina"/"pool.home" is off, other nodes does not try to use other nodes named "pool.home". Thats the problem I have.
As for the accuracy of the clocks, it is quite sufficient for use in a home LAN.
 
Old 08-15-2019, 07:10 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,812

Rep: Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958
Quality and accuracy are two different things. NTP works best with 3 or 4 servers so a ntp.conf typically looks like:
Code:
server 0.somepool.pool.ntp.org iburst
server 1.somepool.pool.ntp.org iburst
server 2.somepool.pool.ntp.org iburst
server 3.somepool.pool.ntp.org iburst
I probably do not totally understand your question. Since your "pool" is only three then your ntp.conf would always be regardless:
Code:
server qnas iburst
server pvr iburst
server rpi iburst
ntp on the client will determine which one to actually use and drop the one that fails.
My desktop
Code:
-192.168.0.2     216.218.254.202  2 u  645 1024  377    0.266    5.033   1.988
+103.105.51.156  206.55.191.142   2 u  633 1024  377   58.297   -4.009   1.886
-199.180.255.17  184.105.182.7    3 u  575 1024  377   64.543    7.374   5.662
+184.105.182.16  216.218.254.202  2 u  561 1024  377   60.673    1.241   3.696
*104.168.88.15   164.67.62.194    2 u  875 1024  377   59.446   -2.957   4.342
My laptop
Code:
+192.168.0.2     216.218.254.202  2 u   28   64  377    1.240  -41.662   7.947
-23.239.24.67    199.249.223.123  2 u   27   64  377   31.868  -47.571   8.354
+173.255.215.209 127.67.113.92    2 u   15   64  277   67.154  -49.329   9.610
*69.89.207.99    .PPS.            1 u   25   64  377   61.119  -38.645   5.220
+50.205.244.22   50.205.244.27    2 u   14   64  377   65.210  -41.317   3.995
192.168.0.2 is my router. The asterisk indicates which one is being used as the source which is almost never my router.
 
Old 08-15-2019, 08:34 AM   #5
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
OK. You are right if You deal with "real" Linux based systems (desktops, servers, router with OpenWRT for example etc). Simply entering several NTP servers to conf file resolve the problem.
But I have several different network nodes for example based on ESP8266 chip with EasyESP SW installed. They all work in a home automation system. Just like a vacuum cleaner or refrigerator with a touch screen displaying the status of each individual automation components. In these cases I cannot enter several addresses or names into any conf file. There is only one line/entry fild in some setup where I can enter only one address/name of the NTP server. On the other hand, "my philosophy" is that a home automation system must work even in the absence of internet connectivity. And it cannot be dependent on any overseas server/cloud. It must also be as resistant as possible to power problems. And almost all home automation devices do not have their own RTC and must use some NTP server. Well, time is the basic parameter for such devices. Hence the attempt to create own home "pool" of NTP servers. I hope the whole thing is a bit clearer now.

Last edited by mackowiakp; 08-15-2019 at 10:45 AM.
 
Old 08-15-2019, 11:13 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,812

Rep: Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958
Not sure if this will work. Try adding the the IP address for each device to your dnsmasq server's /etc/hosts file.
Change your local domain to match your settings.

192.168.1.10 mypool mypool.localnet
192.168.1.11 mypool mypool.localnet
192.168.1.12 mypool mypool.localnet

Just within the past few months there was supposedly an internet outage in the northeast US and all the Google smart devices would not work. Since US internet is not considered a utility thanks to the President the ISP we connect with basically has ultimate control of our incoming traffic.
 
Old 08-15-2019, 11:29 PM   #7
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
Yep. "Big Brother is watching You".

I try such solution. Does not work because if You implement dnsmasq, RPi, NAS or any other Linux based unit acts as DNS server for itself. So /etc/hosts contains only entry 127.0.0.1 for localhost. Of course /etc/hosts has priority over DNS but only for internal usage of Linux device not for installed services like dnsmasq.
 
Old 08-16-2019, 05:22 AM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,812

Rep: Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958Reputation: 5958
Add to the dns server hosts file not the client. Dnsmasq does read /etc/hosts file and uses the entries.

Many distributions like mint use dnsmasq as a DNS cache forwarder which is why their resolv.comf use localhost. Not a problem as dhcp client. If the Pi does I would think using network manager to configure a static ip address should work.

Last edited by michaelk; 08-16-2019 at 05:59 AM.
 
1 members found this post helpful.
Old 08-16-2019, 09:55 AM   #9
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
All my "fixed location" network nodes (excluding smartphones, tablets and laptop) have static IP configuration. And also nodes with static IP configuration have static MAC to IP defined in dnsmasq. Mainly because the IoT devices of the automation system have frequently changed firmware. And this change often forces factory reset. And this causes that they work in DHCP client mode and not with static IP. Of course, it is easy to restore the configuration from the settings backup file.
Adding "pool" entries to /etc/hosts did nothing.
But adding entries to /etc/dnsmasq/hosts/hosts file seems to work fine. I added the name "pool" as the second name for RPi, QNAP and sat receiver. RPi has two IP address. The output from nslookup from my desktop PC below:

Code:
[maciek@Piotr ~]$ nslookup pool
Server:         192.168.0.201
Address:        192.168.0.201#53

Name:   pool
Address: 192.168.0.25
Name:   pool
Address: 192.168.0.4
Name:   pool
Address: 192.168.0.7
Thats OK.

We'll see how it works by turning off devices one by one. It is also possible that the NTP client in IoT devices is incomplete enough that it cannot choose the best NTP server itself. I have to test it. These devices have poor processors and are not performance mistries.

Last edited by mackowiakp; 08-16-2019 at 09:58 AM.
 
Old 08-24-2019, 11:19 AM   #10
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
Yep. As I wrote, that some NTP client in IoT devices is incomplete enough that it cannot choose the best NTP server itself. Simply it takes first IP address from "pool". If this NTP server is down, it can not by itself try to communicate with other working one. It's not cool at all. But well, I have to live with it.
 
  


Reply

Tags
dnsmasq, ntp, pool



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How To Install And Configure NTP Server And NTP Client In Linux? LXer Syndicated Linux News 0 03-31-2019 10:12 PM
NTP Server Using the NTP Time not External Servers or Pools jackgun Red Hat 3 11-04-2016 02:37 PM
Does RANDOM entrpy pool init ensure /dev/urandom entrpy pool init ? RV11 Linux - General 4 04-01-2015 06:43 AM
SAN storage pool for VM Guest OS images - which pool type is best practice myc5 Linux - Virtualization and Cloud 1 11-23-2014 09:14 PM
ntp drift file in /etc/ntp instead of /var/lib/ntp - suggestion for a patch in Slack niels.horn Slackware 16 05-07-2009 07:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration