{"id":848,"date":"2011-04-17T12:20:49","date_gmt":"2011-04-17T04:20:49","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=848"},"modified":"2023-04-28T09:50:30","modified_gmt":"2023-04-28T09:50:30","slug":"how-to-install-and-configure-ntp-client-on-centosrhel-to-synchronize-the-clock","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-install-and-configure-ntp-client-on-centosrhel-to-synchronize-the-clock\/","title":{"rendered":"How to install and Configure NTP client on CentOS\/RHEL to Synchronize the Clock"},"content":{"rendered":"<p>The Network Time Protocol (NTP) is a protocol used to synchronize the clocks of computers over a network. NTP uses a hierarchical architecture of time sources, which can be either local or external. In this guide, we will show you how to install and configure an NTP client on CentOS\/RHEL to synchronize the clock with an NTP server.<\/p>\n<h2>Step 1: Install NTP<\/h2>\n<p>The first step is to install the NTP package. You can do this by running the following command as root:<\/p>\n<pre>\r\nyum install ntp\r\n<\/pre>\n<p>This will download and install the NTP package and its dependencies.<\/p>\n<pre>\r\nLoaded plugins: fastestmirror\r\nLoading mirror speeds from cached hostfile\r\n * addons: ftp.oss.eznetsols.org\r\n * base: ftp.oss.eznetsols.org\r\n * epel: ftp.cuhk.edu.hk\r\n * extras: ftp.oss.eznetsols.org\r\n * updates: ftp.oss.eznetsols.org\r\nSetting up Install Process\r\nResolving Dependencies\r\n--&gt; Running transaction check\r\n---&gt; Package ntp.x86_64 0:4.2.2p1-9.el5.centos.2.1 set to be updated\r\n--&gt; Finished Dependency Resolution\r\n\r\nDependencies Resolved\r\n\r\n=====================================================================================\r\n Package      Arch            Version                            Repository     Size\r\n=====================================================================================\r\nInstalling:\r\n ntp          x86_64          4.2.2p1-9.el5.centos.2.1           base          1.3 M\r\n\r\nTransaction Summary\r\n=====================================================================================\r\nInstall       1 Package(s)\r\nUpgrade       0 Package(s)\r\n\r\nTotal download size: 1.3 M\r\nIs this ok [y\/N]: y\r\nDownloading Packages:\r\nntp-4.2.2p1-9.el5.centos.2.1.x86_64.rpm                       | 1.3 MB     00:04\r\nRunning rpm_check_debug\r\nRunning Transaction Test\r\nFinished Transaction Test\r\nTransaction Test Succeeded\r\nRunning Transaction\r\n  Installing     : ntp                                                           1\/1\r\n\r\nInstalled:\r\n  ntp.x86_64 0:4.2.2p1-9.el5.centos.2.1\r\n\r\nComplete!\r\n<\/pre>\n<h2>Step 2: Configure NTP<\/h2>\n<p>After installing NTP, you need to configure it to synchronize the clock with an NTP server. The NTP configuration file is located at \/etc\/ntp.conf. You can edit this file with a text editor to add the NTP server you want to synchronize with.<\/p>\n<pre>\r\n# vi \/etc\/ntp.conf\r\n<\/pre>\n<p>Find the lines that specify the NTP servers and add the IP address or hostname of the NTP server you want to use.<\/p>\n<pre>\r\nserver 0.centos.pool.ntp.org     \/\/set this to your primary NTP server  - Line 17\r\nserver 1.centos.pool.ntp.org     \/\/set this to your Secondary NTP server (Optional)  - Line 18\r\nserver 2.centos.pool.ntp.org     \/\/set this to your tertiary  NTP server (Optional)  - Line 19\r\n<\/pre>\n<p>For example, to synchronize with the NTP server at IP address 192.0.2.1, add the following line:<\/p>\n<pre>\r\nserver 192.0.2.1\r\n<\/pre>\n<p>Save the file and exit the text editor.<\/p>\n<h2>Step 3: Start NTP<\/h2>\n<p>After configuring NTP, you need to start the NTP service. You can do this by running the following command as root:<\/p>\n<pre>\r\nsystemctl start ntpd\r\n<\/pre>\n<p>This will start the NTP service and synchronize the clock with the NTP server you specified in the configuration file.<\/p>\n<h2>Step 4: Enable NTP at boot<\/h2>\n<p>To ensure that NTP starts automatically at boot time, you need to enable the NTP service. You can do this by running the following command as root:<\/p>\n<pre>\r\nsystemctl enable ntpd\r\n<\/pre>\n<p>This will create a symbolic link in the \/etc\/systemd\/system\/multi-user.target.wants\/ directory to the NTP service unit file.<\/p>\n<h2>Step 5: Verify NTP synchronization<\/h2>\n<p>After starting NTP, you can verify that the clock is synchronized with the NTP server by running the following command:<\/p>\n<pre>\r\nntpq -p\r\n<\/pre>\n<p>This will display a list of NTP servers and their status. The &#8220;*&#8221; symbol indicates the NTP server that the client is synchronized with.<\/p>\n<h2>Commands Mentioned:<\/h2>\n<ul>\n<li><span class=\"fw-bold\">yum install<\/span> &#8211; installs packages<\/li>\n<li><span class=\"fw-bold\">systemctl start<\/span> &#8211; starts a systemd service<\/li>\n<li><span class=\"fw-bold\">systemctl enable<\/span> &#8211; enables a systemd service to start at boot<\/li>\n<li><span class=\"fw-bold\">ntpq -p<\/span> &#8211; displays NTP server status<\/li>\n<\/ul>\n<h2>Conclusion:<\/h2>\n<p>In this guide, we have shown you how to install and configure an NTP client on CentOS\/RHEL to synchronize the clock with an NTP server. By synchronizing the clock with an NTP server, you can ensure that the time on your server is accurate, which is important for various applications such as logging and authentication. Remember to verify that NTP synchronization is working correctly by using the ntpq command.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Network Time Protocol (NTP) is a protocol used to synchronize the clocks of computers over a network. NTP uses a hierarchical architecture of time sources, which can be either&#8230;<\/p>\n","protected":false},"author":6,"featured_media":323,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[2064,1065],"tags":[1246,1536],"class_list":["post-848","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ntp","category-system-administration","tag-centos-5-5","tag-linux"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=848"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/848\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/323"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}