Product SiteDocumentation Site

2.2.3. Configuring the Network Time Protocol

As opposed to the manual setup described above, you can also synchronize the system clock with a remote server over the Network Time Protocol (NTP). For the one-time synchronization only, use the ntpdate command:
  1. Check whether the selected NTP server is accessible by using the ntpdate command in the following form:
    ntpdate -q server_address
    For example, to connect to 0.fedora.pool.ntp.org, type:
    ~]$ ntpdate -q 0.fedora.pool.ntp.org
    server 204.15.208.61, stratum 2, offset -39.275438, delay 0.16083
    server 69.65.40.29, stratum 2, offset -39.269122, delay 0.17191
    server 148.167.132.201, stratum 2, offset -39.270239, delay 0.20482
    17 Oct 17:41:09 ntpdate[10619]: step time server 204.15.208.61 offset -39.275438 sec
  2. When you find a satisfactory server, as root, run the ntpdate command followed with one or more server addresses:
    ntpdate server_address…
    For instance:
    ~]# ntpdate 0.fedora.pool.ntp.org 1.fedora.pool.ntp.org
    17 Oct 17:42:13 ntpdate[10669]: step time server 204.15.208.61 offset -39.275436 sec
    Unless an error message is displayed, the system time is now set. You can verify the current time by running the date command with no additional arguments.
  3. In most cases, these steps are sufficient. Only if you really need one or more system services to always use the correct time, enable running the ntpdate at boot time by running the following command as root:
    systemctl enable ntpdate.service
    For more information about system services and their setup, refer to Chapter 7, Services and Daemons.

    Note

    If the synchronization with the time server at boot time keeps failing, that is, you find a relevant error message in the /var/log/boot.log system log, try to add the following line to /etc/sysconfig/network:
    NETWORKWAIT=1
However, the more convenient way is to set the ntpd daemon to synchronize the time at boot time automatically:
  1. As root, open the NTP configuration file /etc/ntp.conf in a text editor, creating a new one if it does not already exist.
  2. Add or edit the list of public NTP servers. If you are using Fedora 16, the file should already contain the following lines, but feel free to change or expand these according to your needs:
    server 0.fedora.pool.ntp.org iburst
    server 1.fedora.pool.ntp.org iburst
    server 2.fedora.pool.ntp.org iburst

    Speeding up initial synchronization

    To speed the initial synchronization up, it is recommended that the iburst directive is added at the end of each server line.
  3. In the same file, set the proper permissions, giving the unrestricted access to localhost only:
    restrict default kod nomodify notrap nopeer noquery
    restrict -6 default kod nomodify notrap nopeer noquery
    restrict 127.0.0.1
    restrict -6 ::1
  4. Save the changes, exit the editor, and restart the NTP daemon:
    systemctl restart ntpd.service
  5. Additionally, make sure that ntpd daemon is started at boot time:
    systemctl enable ntpd.service