FAQ: Network Time Protocol configuration

Version 2

    Controlling the NTP deamon service

     

    service ntpd start

    service ntpd stop

    service ntpd restart

    service ntpd status

     

    Configuring NTP

     

    Configuration file location: /etc/ntp.conf

     

    I left the majority of the default configuration intact.  I commented out all of the server lines, and than added the following.

    server timeserver.police.ctb

    server 127.127.1.0

    fudge  127.127.1.0 stratum 10

     

    This configures NTP to use two time servers, the first being timeserver.police.ctb and the second being the local time.  The address 127.127.1.0 is a special IP that causes NTP a "local driver" to get the time (don't confuse this with 127.0.0.1 which is a server IP).  The fudge line is used to make sure that the local clock is used last, which means it is only ever used if timeserver.police.ctb is unreachable.

     

    Configuring NPTD to start on Linux Reboot

     

    Linux has multiple "run levels", including single-user mode, multi-user mode, multi-user with networking, halt, and reboot.  You can think of these as different levels of safe-mode and normal mode.  You can use the chkconfig tool to turn on/of and otherwise configure what services run at what levels.

     

    For the purposes of NTP we just want to make sure that it is set to automatically run when the server is rebooted.

     

    To see what run levels the ntpd server will automatically start on run chkconfig --list ntpd:

    $ chkconfig --list ntpd

    ntpd           0:off 1:off 2:off 3:off 4:off 5:off 6:off

     

    If all of run levels show "off" like this, you want to turn them on:

    chkconfig ntpd on

     

    This will by default turn "on" auto-start for levels 2 (multi-user), 3 (multi-user w/network), 4 (special), and 5 (normal).

     

    Force an update

     

    To force an update you need to stop the ntpd service then use the following command.  Be sure to turn the service back on after.

    /usr/sbin/ntpdate timeserver.police.ctb

     

    Status

     

    I have configured all servers to...

    • Use the ntp.conf configuration noted above.
    • Start on reboot.
    • Forced a time update