Software >> OS >> Unix >> Linux >> RHEL >> 7 >> RHCE >> Section 10 - NTP

 

Synchronize Time Using Other NTP Peers - set up local time server


## install required packages

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


## check currently configured NTP servers

[root@rhel7server1 ~]# grep ^server /etc/ntp.conf
server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst


## enable and start ntpd service

[root@rhel7server1 ~]# systemctl enable ntpd
Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.

[root@rhel7server1 ~]# systemctl start ntpd

[root@rhel7server1 ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+nets.org.sg     .NMC1.           1 u   41   64    1    6.095    0.583   0.797
*time1.maxonline .GPS.            1 u   40   64    1    6.558    6.094   1.767
-time.cloudflare 10.35.14.16      3 u   39   64    1   10.726    8.551   4.313
+time.cloudflare 10.35.14.16      3 u   11   64    3    3.591    5.652   1.406


## edit /etc/ntp.conf and comment out the following

#server 0.rhel.pool.ntp.org iburst
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst
#server 3.rhel.pool.ntp.org iburst


## add the following special IP for the local clock on the local machine

server 127.127.1.0


## restart ntpd service and open firewall ports

[root@rhel7server1 ~]# systemctl restart ntpd

[root@rhel7server1 ~]# firewall-cmd --permanent --add-service=ntp
success

[root@rhel7server1 ~]# firewall-cmd --reload
success

[root@rhel7server1 ~]# ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*LOCAL(0)        .LOCL.           5 l   37   64    1    0.000    0.000   0.000


## the server is now ready to provide NTP service to clients


back to Objectives

 

Synchronize Time Using Other NTP Peers - Peer with New time server


## install the required packages

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


## edit /etc/ntp.conf, comment out the default NTP servers, add our NTP server

#server 0.rhel.pool.ntp.org iburst
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst
#server 3.rhel.pool.ntp.org iburst
server rhel7server1.myexample.com iburst


## enable and start ntpd service and open firewall ports

[root@rhel7client1 ~]# systemctl enable ntpd
Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.

[root@rhel7client1 ~]# systemctl start ntpd

[root@rhel7client1 ~]# firewall-cmd --permanent --add-service=ntp
success

[root@rhel7client1 ~]# firewall-cmd --reload
success


## check NTP peer status

[root@rhel7client1 ~]# ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 rhel7server1.my LOCAL(0)         6 u    1   64    1    0.407    0.011   0.013



 back to Objectives