How to Install and Configure NTP Server on Ubuntu 14.04

The Network Time Protocol (NTP) is used to synchronize between computer systems over the network. Time synchronization is very crucial to determine when events happened to computers system or server systems. NTP will be very useful when we want to implement replication between servers. NTP uses 123/UDP protocol. Please make sure UDP port from each client to NTP has been opened. This article will describe how to install and configure NTP server on Ubuntu 14.04 server.

1. Install ntp service :

ehowstuff@ubuntu14:~$ sudo apt-get install ntp -y

2. Configure NTP service :

ehowstuff@ubuntu14:~$ sudo vi /etc/ntp.conf

For Malaysia, add the following NTP servers :

server 0.asia.pool.ntp.org
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org
server 3.asia.pool.ntp.org

3. Once configuration file updated, restart ntp to take affect :

ehowstuff@ubuntu14:~$ sudo service ntp restart
 * Stopping NTP server ntpd                                                                  [ OK ]
 * Starting NTP server ntpd                                                                  [ OK ]

4. Verify that NTP service is synchronizing to remote NTP servers :

ehowstuff@ubuntu14:~$ sudo ntpq -p

Example :

ehowstuff@ubuntu14:~$ sudo ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 balthasar.gimas 65.32.162.194    3 u    1   64    1  146.094  -10.741   0.000
 chobi.paina.jp  .INIT.          16 u    -   64    0    0.000    0.000   0.000
 194.27.44.55    .INIT.          16 u    -   64    0    0.000    0.000   0.000
 202-65-114-202. .INIT.          16 u    -   64    0    0.000    0.000   0.000
 europium.canoni .INIT.          16 u    -   64    0    0.000    0.000   0.000

5. Configure NTP for Client :
ubuntu14-ntp1

How to Configure NTP Server for Time Adjustment on CentOS 6.3

ntpThis post covers the steps to install NTP server on CentOS 6.3. NTP, Network Time Protocol, it is an Internet protocol used to synchronize the clocks of computers or servers to some NTP server on internet or intranet.

1. Install ntp using yum command :

[root@centos63 ~]# yum install ntp -y

2. Once NTP is installed you need to update the configuration file, ntp.conf located in the /etc directory :

[root@centos63 ~]# vi /etc/ntp.conf
# Hosts on local network are less restricted.
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org
#server 1.centos.pool.ntp.org
#server 2.centos.pool.ntp.org
server 0.asia.pool.ntp.org
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org
server 3.asia.pool.ntp.org

..
..

3. Start the NTP service :

[root@centos63 ~]# /etc/rc.d/init.d/ntpd start
Starting ntpd:                                             [  OK  ]

4. NTP service start at boot :

[root@centos63 ~]# chkconfig ntpd on

5. Test your ntp client status :

[root@centos63 ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 103.6.16.254    10.84.87.146     2 u   16   64    1  129.453   18.233   0.002
 superluminal.sf 189.70.85.38     2 u   16   64    1  128.466    1.971   0.002
 fnttkyo043241.t 165.246.43.176   3 u   15   64    1  125.813   11.528   0.002
 send.mx.cdnetwo 131.107.13.100   2 u   14   64    1  250.371  -53.987   0.002

6. To verify the NTP service is now running on the server using the following command :

[root@centos63 ~]# ps -e | grep ntpd
 5206 ?        00:00:00 ntpd

How to install and Configure NTP client on CentOS/RHEL to Synchronize the Clock

NTP, Network Time Protocol, it is an Internet protocol used to synchronize the clocks of computers or servers to some NTP server on internet or intranet. In CentOS, it is very easy to install and configure the ntp client.

Install your NTP client using yum command:

    [root@server ~]# yum install ntp
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * addons: ftp.oss.eznetsols.org
     * base: ftp.oss.eznetsols.org
     * epel: ftp.cuhk.edu.hk
     * extras: ftp.oss.eznetsols.org
     * updates: ftp.oss.eznetsols.org
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package ntp.x86_64 0:4.2.2p1-9.el5.centos.2.1 set to be updated
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =====================================================================================
     Package      Arch            Version                            Repository     Size
    =====================================================================================
    Installing:
     ntp          x86_64          4.2.2p1-9.el5.centos.2.1           base          1.3 M
    
    Transaction Summary
    =====================================================================================
    Install       1 Package(s)
    Upgrade       0 Package(s)
    
    Total download size: 1.3 M
    Is this ok [y/N]: y
    Downloading Packages:
    ntp-4.2.2p1-9.el5.centos.2.1.x86_64.rpm                       | 1.3 MB     00:04
    Running rpm_check_debug
    Running Transaction Test
    Finished Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing     : ntp                                                           1/1
    
    Installed:
      ntp.x86_64 0:4.2.2p1-9.el5.centos.2.1
    
    Complete!
    

Configure your ntp.conf file and pointing to your NTP server

    [root@server ~]# vi /etc/ntp.conf
    
    server 0.centos.pool.ntp.org     //set this to your primary NTP server  - Line 17
    server 1.centos.pool.ntp.org     //set this to your Secondary NTP server (Optional)  - Line 18
    server 2.centos.pool.ntp.org     //set this to your tertiary  NTP server(Optional)  - Line 19
    

As for example :

    server ntp1.server.local
    server ntp2.server.local
    

Restart your ntp client using below command:

    [root@server ~]# service ntpd restart
    

or

    [root@server ~]# /etc/init.d/ntpd restart
    

Test your ntp client status whether properly configured or not by running below command:

    [root@server ~]# ntpq -p