The ntpd is a daemon that synchronizes the system clock to remote ntp time server or local reference clock. The ntpd's configuration file is /etc/ntp.conf. In order to set up a ntp server in Fedora host, you should configure this file first.
It is better to comment all default server's list in this file and added open and free stratum-1 server that I found on the internet (clock.nyc.he.net)
If you want to enable logging and statistics files, you should add following lines to this file as well:
statistics clockstats cryptostats loopstats peerstats
Also, we should add a rule in iptables to accept all incoming udp protocols for destination port 123.
iptables -t filter -I INPUT -p udp –dport 123 -j ACCEPT
Now, we are ready to start our ntp daemon:
service ntpd start
Here is the log records in /var/log/messages when I started ntpd:
May 16 21:42:32 f13 ntpd: ntpd firstname.lastname@example.org
May 16 21:42:32 f13 ntpd: proto: precision = 0.106 usec
May 16 21:42:32 f13 ntpd: 0.0.0.0 c01d 0d kern kernel time sync enabled
May 16 21:42:32 f13 ntpd: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
May 16 21:42:32 f13 ntpd: Listen and drop on 1 v6wildcard :: UDP 123
May 16 21:42:32 f13 ntpd: Listen normally on 2 lo 127.0.0.1 UDP 123
May 16 21:42:32 f13 ntpd: Listen normally on 3 eth0 192.168.2.5 UDP 123
May 16 21:42:32 f13 ntpd: Listen normally on 4 lo ::1 UDP 123
May 16 21:42:32 f13 ntpd: Listen normally on 5 eth0 fe80::a00:27ff:fe02:f415 UDP 123
May 16 21:42:32 f13 ntpd: Listening on routing socket on fd #22 for interface updates
May 16 21:42:32 f13 ntpd: logging to file /var/log/ntp
All ntp server's statistics file are located in /var/log/ntpstats/ and the following is the records of peerstats file:
[root@f13 ~]# cat /var/log/ntpstats/peerstats
55486 10480.347 22.214.171.124 9024 -0.014972077 0.055863590 7.937508078 0.000000060
55486 10547.406 126.96.36.199 9024 -0.013583095 0.049342619 3.937763318 0.001388983
55486 10613.364 188.8.131.52 9024 -0.010081588 0.041968563 1.938010883 0.004253083
The peerstats file records peer statistics information. This includes statistics records of all peers of a NTP server. Each valid update appends a line to this file. The first two fields show the date (Modified Julian Day) and time (seconds and fraction past UTC midnight). The next two fields show the peer address in dotted-quad notation and status. The status field is encoded in hex in the format described in Appendix A of the NTP specification RFC 1305. The final four fields show the offset, delay, dispersion and RMS jitter, all in seconds.
Another ntp server's statistics file is /var/log/ntpstats/loopstats and the following is its records in this file:
[root@f13 ~]# cat /var/log/ntpstats/loopstats
55486 10680.412 -0.003679314 452.701 0.001300834 0.249356 6
55486 10874.342 -0.009402045 450.961 0.002361007 0.657753 6
55486 11264.377 -0.008711860 447.721 0.002221960 1.300365 6
It records the loop filter statistics information. Each update of the local clock outputs a line to the file. Again, the first two fields show the date (Modified Julian Day) and time (seconds and fraction past UTC midnight). The next five fields show time offset (seconds), frequency offset (parts per million - PPM), RMS jitter (seconds), Allan deviation (PPM) and clock discipline time constant.
In order to demonstrate that my host and guest machine work correctly, I ran ntpstat command in both machine and these were the outputs:
[root@f13 ~]# ntpstat
synchronised to NTP server (184.108.40.206) at stratum 2
time correct to within 42 ms
polling server every 512 s
[root@vm01 ~]# ntpstat
synchronised to NTP server (192.168.2.5) at stratum 3
time correct to within 131 ms
polling server every 256 s
Accuracy: As you noticed in ntpstat command, the time correction is within milliseconds and don't forget that the accuracy is also depend on network delay and distance as well.
Advantages: The advantage of using ntpd among other time synchronization mechanisms is its continuous adaption to a time server time provided in the internet.
Disadvantages: It may take up to 30 minutes for the client's clock to synchronize for the first time on a time server. If, in addition, the difference between the two clocks is more than a few minutes, it can take much more time for synchronization to occur for the first time.