Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.