NTPD client setup
I want to set the NTP daemon up on my machine, to synchronize my time with the internets. So i properly chmodded the rc.ntpd to start on boot and put NTP servers into /etc/ntp.conf as follows:
Quote:
My question is: it is all what it takes or am i missing something, like cron job for example? The manpages and Slackware related info i googled up were server side oriented and overly complicated, so i'm posting a question here. |
Yes, that's pretty much it; you have added servers in /etc/ntp.conf (you really only need three), /etc/rc.d/rc.ntpd is executable and starts the daemon. After booting and a few minutes, if you open a terminal and
Code:
/usr/sbin/ntpq -pn On a new installation it will take a week or so for NTP to "walk" your system clock into synchronization (it does this with small adjustments). Long-term, the daemon just runs, your system clock stays synchronized and life is good. You do not need any cron job or manual intervention with NTP; once going, you're good. Now, the LOCL clock at 127.127.1.0? That's there so when or if your internet connection goes away NTP will "fall-back" to the system clock and continue running; when the internet "comes-back," it will then synchronize with one of the defined pool servers. It will also evaluate the pool servers periodically and "throw out" one that has become unusable (for whatever reason) and get another server address from the pool in its place (pool servers are volunteers and they occasionally go off line so NTP is "smart" enough to recognize that and select another server). You also, once you've gotten your clock synchronized, do not need to use ntpdate; NTP, when it starts, will slew the clock (if it's way out of time) to the correct time then keep it there. Hope this helps some. |
Hi tronayne, thanks very much for the post, it's really very informative. But it looks i have a problem after all.
Quote:
Quote:
/var/log/syslog info related to last ntpd start is: Quote:
ntpdate output is: Quote:
I suspect the router or firewall, or maybe provider's firewall. I tried to portforward the router, no change. If i'm missing something obvious or something i haven't thought of, it would be nice to know. If it is iptables thing (didn't touch it since install) or something similar, i'm going to drop this, i don't really need those two secs anyway, i wasted over 3 hours troubleshooting it. Which raises a question, did it actually work all the time i thought it worked, running other distros? |
Before you check or edit any of the following, stop the NTP daemon (/etc/rc.d/rc.ntpd stop, then make sure that there are no accidental NTP daemons running:
Code:
ps -ef | grep ntpd Code:
kill -9 PID (using the number). Your local clock should be defined like this in /etc/ntp.conf: Code:
server 127.127.1.0 # local clock Here's my /etc/ntp.conf; other than the 0.us.pool.ntp.org entries, yours should be identical (plus or minus commented-out lines): Code:
cat /etc/ntp.conf It does work just fine on all my systems and should on yours. Check your /etc/rc.d/rc.ntpd if you have edited it (don't bother if you haven't): Code:
cat /etc/rc.d/rc.ntpd Code:
ping -c 5 0.cz.pool.ntp.org You can't use ntpdate if the NTP daemon is running as you probably already know; you have to, as root, execute /etc/rc.d/rc.ntpd stop first. Your example above looks as though it worked -- it set the system clock. I assume your locale is set correctly and that ntpdate set your system clock to the correct time for your locale? So, if all the above is correct, start the damon: Code:
/etc/rc.d/rc.ntpd start Code:
ntpq -pn Hope this helps some. |
There's an article I wrote on the subject here:
http://docs.slackware.com/howtos:network_services:ntp |
Quote:
This is my /etc/ntp.conf Quote:
/etc/rc.d/rc.ntpd is vanilla; i changed the CMDLINE="/usr/sbin/ntpd -g" to CMDLINE="/usr/sbin/ntpd -4 -g" to try to run it IPv4 only, but i reverted it later. I checked it word by word, it's the same as yours. The ping command works properly: Quote:
Quote:
Quote:
Quote:
Well actually, if ntpdate corrects the time by itself i don't need the daemon running. But i'm really curious where is the problem. |
Quote:
I think i'll mark this as SOLVED, thanks guys for help --------------------- Is there any way to rename the thread, to better emphasize that it is a wicd issue? |
So, you're using wicd to connect to the internet (either wired or wi-fi)? Do you manually select one or the other after the system boots and you've logged in? And you let it run continuously?
That just may be your problem: the NTP daemon is started at boot (when no wicd-connected network is available) and, of course, it's going to time out before wicd gets started and a network gets selected (although it may sync up on its own once a network is connected). Perhaps you could just start it manually after wicd is running and you've selected a network to connect to? NTP pretty much expects a hard-wired connection to the Internet, always available. One way around this is that, if you have an Ethernet network, simply plug the Ethernet cable in to the computer from your modem/router/whatever -- you can always use wicd to disconnect from the hard-wired network and connect to a wi-fi network (I do this with my laptop, it's usually connected via Ethernet cable to a router but, every so often, it's on "foreign ground" and only wif-fi is available and I use wicd to connect to an available network and (usually) restart ntpd to get it connected via wi-fi). If Ethernet is available, you'll get connected automatically at boot time (and wicd will "know" that). If you want to switch to wi-fi, you just open wicd, turn off the Ethernet connection and turn on the wi-fi. Simple. Hope this helps some. |
Quote:
During my troubleshooting i restarted the NTP daemon at least 20x, with internet connection well established. Didn't work. rc.wicd actually starts at the same time as networkmanager. This is rc.M snippet around line 200: Quote:
All inet connections were wi-fi as well. So i can only confirm that the NTP daemon works well with rc.inet and NetworkManager but not with wicd, at least on this machine. |
I create a file called settime in cron.daily with the following
Code:
/usr/sbin/ntpdate north-america.pool.ntp.org && /sbin/hwclock -w |
Quote:
|
Check /etc/hosts
I've just realized that the ntpd daemon on my server does not accept queries on localhost whereas the identical configuration (i.e. same ntp.conf, same iptables allowing UDP on port 123) on another computer works. The "ntpd -p" command from the local console simply responded with a "localhost.localdomain: timed out, nothing received".
The only difference was in /etc/hosts file where the non-working computer had the localhost for IPv6 defined as: ::1 localhost6.localdomain6 localhost6 and the correct /etc/hosts entry (as far as ntpd is concerned) is ::1 localhost.localdomain localhost6 localhost When I've changed the /etc/hosts entry on the server, it worked right away. |
All times are GMT -5. The time now is 03:50 PM. |