{"id":6994,"date":"2018-10-10T20:48:32","date_gmt":"2018-10-10T17:48:32","guid":{"rendered":"https:\/\/www.howtoforge.com\/tutorial\/ubuntu-ntp-server\/"},"modified":"2018-10-10T20:48:32","modified_gmt":"2018-10-10T17:48:32","slug":"how-to-install-ntp-server-and-client-on-ubuntu-18-04-lts","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/how-to-install-ntp-server-and-client-on-ubuntu-18-04-lts\/","title":{"rendered":"How to Install NTP Server and Client on Ubuntu 18.04 LTS"},"content":{"rendered":"<p>NTP (Network Time Protocol) is a networking protocol designed to synchronize the clocks of computers over a network. NTP allows you to synchronize the clocks of all the systems within the network. NTP server synchronizes its time by contacting a number of servers around the world.<\/p>\n<p>In this tutorial, we will learn to install NTP server and Setup time synchronization on Ubuntu 18.04 server.<\/p>\n<h2 id=\"requirements\">Requirements<\/h2>\n<ul>\n<li>A server running Ubuntu 18.04 server.<\/li>\n<li>A non-root user with sudo privileges.<\/li>\n<li>A static IP address 192.168.43.229 configured on your server.<\/li>\n<\/ul>\n<h2 id=\"install-and-configure-ntp-server\">Install and Configure NTP Server<\/h2>\n<p>By default, NTP package is available in the Ubuntu 18.04 LTS default repository. You can install it by just running the following command:<\/p>\n<p class=\"command\">sudo apt-get install ntp -y<\/p>\n<p>Next, you will need to configure NTP to synchronize its time from public NTP server. You can do this by editing ntp.conf file:<\/p>\n<p class=\"command\">sudo nano \/etc\/ntp.conf<\/p>\n<p>Replace the lines:<\/p>\n<pre>pool 0.ubuntu.pool.ntp.org iburst&#13;\npool 1.ubuntu.pool.ntp.org iburst&#13;\npool 2.ubuntu.pool.ntp.org iburst&#13;\npool 3.ubuntu.pool.ntp.org iburst&#13;\n<\/pre>\n<p>With ones that match your location. In my case, I will use the following lines:<\/p>\n<pre>pool 0.asia.pool.ntp.org iburst&#13;\npool 1.asia.pool.ntp.org iburst&#13;\npool 2.asia.pool.ntp.org iburst&#13;\npool 3.asia.pool.ntp.org iburst&#13;\n<\/pre>\n<p>A list of available NTP Pool time servers can be found here:\u00a0<a href=\"http:\/\/support.ntp.org\/bin\/view\/Servers\/NTPPoolServers\" target=\"_blank\" rel=\"noopener\">http:\/\/support.ntp.org\/bin\/view\/Servers\/NTPPoolServers<\/a><\/p>\n<p>Save and close the file. Then, restart the NTP service to apply the changes:<\/p>\n<p class=\"command\">sudo systemctl restart ntp<\/p>\n<p>You can check the status of NTP with the following command:<\/p>\n<p class=\"command\">sudo systemctl status ntp<\/p>\n<p>Output:<\/p>\n<pre>? ntp.service - Network Time Service&#13; Loaded: loaded (\/lib\/systemd\/system\/ntp.service; enabled; vendor preset: enabled)&#13; Active: active (running) since Fri 2018-10-05 15:10:14 UTC; 42s ago&#13; Docs: man:ntpd(8)&#13; Main PID: 5587 (ntpd)&#13; Tasks: 2 (limit: 1114)&#13; CGroup: \/system.slice\/ntp.service&#13; ??5587 \/usr\/sbin\/ntpd -p \/var\/run\/ntpd.pid -g -u 113:116&#13;\n&#13;\nOct 05 15:10:15 ubuntu1804 ntpd[5587]: Soliciting pool server 123.108.200.124&#13;\nOct 05 15:10:16 ubuntu1804 ntpd[5587]: Soliciting pool server 64:ff9b::7b6c:c87c&#13;\nOct 05 15:10:16 ubuntu1804 ntpd[5587]: Soliciting pool server 64:ff9b::7b6c:c87c&#13;\nOct 05 15:10:18 ubuntu1804 ntpd[5587]: Soliciting pool server 2406:da1a:200:7201:d9ea:9ac5:32e3:339c&#13;\nOct 05 15:10:18 ubuntu1804 ntpd[5587]: Soliciting pool server 64:ff9b::7b6c:c87c&#13;\nOct 05 15:10:19 ubuntu1804 ntpd[5587]: Soliciting pool server 91.189.91.157&#13;\nOct 05 15:10:20 ubuntu1804 ntpd[5587]: Soliciting pool server 91.189.94.4&#13;\nOct 05 15:10:21 ubuntu1804 ntpd[5587]: Soliciting pool server 91.189.89.198&#13;\nOct 05 15:10:22 ubuntu1804 ntpd[5587]: Soliciting pool server 91.189.89.199&#13;\nOct 05 15:10:23 ubuntu1804 ntpd[5587]: Soliciting pool server 2001:67c:1560:8003::c7&#13;\n&#13;\n<\/pre>\n<h2 id=\"install-and-configure-ntp-client\">Install and Configure NTP Client<\/h2>\n<p>Now, we will install and configure NTP client to sync time with our NTP server.<\/p>\n<p>Before starting, you will need to setup \/etc\/hosts file. So, your NTP server can be resolved via hostname.<\/p>\n<p>To do so, open the \/etc\/hosts file:<\/p>\n<p class=\"command\">sudo nano \/etc\/hosts<\/p>\n<p>Add the following lines:<\/p>\n<pre>192.168.43.229 ntp-server-host&#13;\n<\/pre>\n<p>Replace the IP address with the IP of your NTP server (the one we installed in the precious chapter). Save and close the file.<\/p>\n<p>Next, install NTP and ntpdate with the following command:<\/p>\n<p class=\"command\">sudo apt-get install ntpdate ntp -y<\/p>\n<p>Now, manually check the time synchronization with your NTP server with the following command:<\/p>\n<p class=\"command\">sudo ntpdate ntp-server-host<\/p>\n<p>If everything is fine, you should see the following output:<\/p>\n<pre> 5 Oct 20:48:49 ntpdate[6067]: adjust time server ntp-server-host offset 0.049526 sec&#13;\n<\/pre>\n<p>Next, you will need to disable the default Ubuntu systemd&#8217;s timesyncd service. You can do this with the following command:<\/p>\n<p class=\"command\">sudo timedatectl set-ntp off<\/p>\n<p>Now, edit <em>\/etc\/ntp.conf<\/em> file and set your own configured NTP server as preferred NTP server for the time synchronization.<\/p>\n<p class=\"command\">sudo nano \/etc\/ntp.conf<\/p>\n<p>Add the following lines:<\/p>\n<pre>server ntp-server-host prefer iburst&#13;\n<\/pre>\n<p>Save and close the file. Then, restart NTP service to apply the changes:<\/p>\n<p class=\"command\">sudo systemctl restart ntp<\/p>\n<p>Finally, use the <em><strong>ntpq<\/strong><\/em> command to list the NTP time synchronization queue:<\/p>\n<p class=\"command\">ntpq -p<\/p>\n<p>You should see that ntp-server-host is selected as the current time synchronization source:<\/p>\n<pre> remote refid st t when poll reach delay offset jitter&#13;\n==============================================================================&#13; fwdns2.vbctv.in 202.73.57.107 4 u 3 64 1 127.437 -142.63 0.000&#13; alphyn.canonica 131.188.3.220 2 u 2 64 1 276.931 -106.99 0.000&#13; ntp-server-host 106.10.186.201 3 u 1 64 1 0.588 161.386 0.000&#13;\n<\/pre>\n<h2 id=\"links\">Links<\/h2>\n<div class=\"authorbox\" readability=\"30\">\n<img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/10\/how-to-install-ntp-server-and-client-on-ubuntu-18-04-lts.jpg\" alt=\"Hitesh Jethva\" title=\"\"> <\/p>\n<p><strong>About Hitesh Jethva<\/strong><\/p>\n<p>Over 8 years of experience as a Linux system administrator. My skills include a depth knowledge of Redhat\/Centos, Ubuntu Nginx and Apache, Mysql, Subversion, Linux, Ubuntu, web hosting, web server, Squid proxy, NFS, FTP, DNS, Samba, LDAP, OpenVPN, Haproxy, Amazon web services, WHMCS, OpenStack Cloud, Postfix Mail Server, Security etc.<\/p>\n<\/div>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fubuntu-ntp-server%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/10\/how-to-install-ntp-server-and-client-on-ubuntu-18-04-lts.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fubuntu-ntp-server%2F&amp;text=How+to+Install+NTP+Server+and+Client+on+Ubuntu+18.04+LTS&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/10\/how-to-install-ntp-server-and-client-on-ubuntu-18-04-lts-1.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/10\/how-to-install-ntp-server-and-client-on-ubuntu-18-04-lts-2.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fubuntu-ntp-server%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/10\/how-to-install-ntp-server-and-client-on-ubuntu-18-04-lts-3.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>NTP (Network Time Protocol) is a networking protocol designed to synchronize the clocks of computers over a network. NTP allows you to synchronize the clocks of all the systems within the network. NTP server synchronizes its time by contacting a number of servers around the world. In this tutorial, we will learn to install NTP [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-6994","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/6994","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=6994"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/6994\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=6994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=6994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=6994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}