Linux ubuntu ntp server

Содержание
  1. How to Install NTP Server and Client(s) on Ubuntu 20.04 LTS
  2. Install and configure NTP Server on the host computer
  3. Step 1: Update repository index
  4. Step 2: Install NTP Server with apt-get
  5. Step 3: Verify installation (optional)
  6. Step 4: Switch to an NTP server pool closest to your location
  7. Step 5: Restart the NTP server
  8. Step 6: Verify that the NTP Server is running
  9. Step 7: Configure Firewall so that client(s) can access NTP server
  10. Configure NTP Client to be Time Synced with the NTP Server
  11. Step 1: Install ntpdate
  12. Step 2: Specify IP and hostname of the NTP server in the hosts file
  13. Step 3: Check if the client machine’s time is synchronized with NTP server
  14. Step 4: Disable the systemd timesyncd service on the client
  15. Step 5: Install NTP on your client
  16. Step 6: Configure the /etc/ntp.conf file to add your NTP server as the new time server
  17. Step 7: Restart the NTP server
  18. Step 8: View the Time Synchronization Queue
  19. Karim Buzdar
  20. How to Install NTP Server and Client on Ubuntu
  21. Testing Environments
  22. Install & Configure NTP Server on Ubuntu 18.04 Server
  23. Step 1: Update System Repositories
  24. Step 2: Install NTP Server on Ubuntu 18.04
  25. Step 3: Configure NTP Server Pools on Ubuntu 18.04
  26. Install & Configure NTP Client on Ubuntu 18.04 Client
  27. Step 1: Update System Repositories
  28. Step 2: Install Ntpdate on Ubuntu 18.04
  29. Step 3: Verify Client Time Sync with NTP Server
  30. Step 4: Install NTP Client on Ubuntu 18.04
  31. Step 5: Configure NTP Client on Ubuntu 18.04
  32. Step 6: Verify the NTP Time Synchronization Queue
  33. If You Appreciate What We Do Here On TecMint, You Should Consider:

How to Install NTP Server and Client(s) on Ubuntu 20.04 LTS

NTP or Network Time Protocol is a protocol that is used to synchronize all system clocks in a network to use the same time. When we use the term NTP, we are referring to the protocol itself and also the client and server programs running on the networked computers. NTP belongs to the traditional TCP/IP protocol suite and can easily be classified as one of its oldest parts.

When you are initially setting up the clock, it takes six exchanges within 5 to 10 minutes before the clock is set up. Once the clocks in a network are synchronized, the client(s) update their clocks with the server once every 10 minutes. This is usually done through a single exchange of messages (transaction). These transactions use port number 123 of your system.

In this article, we will describe a step-by-step procedure on how to:

  • Install and configure the NTP server on a Ubuntu machine.
  • Configure the NTP Client to be time synced with the server.

We have run the commands and procedures mentioned in this article on a Ubuntu 20.04 LTS system.

Install and configure NTP Server on the host computer

Follow these steps in order to install the NTP server on your host Ubuntu machine:

Note: We are using the Ubuntu command line, the Terminal, in order to install and configure NTP. You can open the Terminal application either through the application launcher search or the Ctrl+Alt+T shortcut.

Step 1: Update repository index

In order to install the latest available version of the software from the Internet repositories, your local repository index needs to be in line with them. Run the following command as sudo in order to update your local repository index:

Step 2: Install NTP Server with apt-get

Please run the following command as sudo in order to install NTP server daemon from the APT repositories:

Please note that only an authorized user can add, remove and configure software on Ubuntu.

Читайте также:  Установка virtualbox linux ubuntu

The system might ask you the password for sudo and also provide you with a Y/n option to continue the installation. Enter Y and then hit enter; NTP server will then be installed on your system. The process may, however, take some time depending on your Internet speed.

Step 3: Verify installation (optional)

You can verify your NTP installation and also check the version number by running the following command in your Terminal: Advertisement

Step 4: Switch to an NTP server pool closest to your location

When you install the NTP server, it is mostly configured to fetch the proper time. However, you can switch the server pool to the ones closest to your location. This includes making some changes in the /etc/ntp.conf file.

Open the file in the nano editor as sudo by running the following command:

In this file, you will be able to see a pool list. We have highlighted this list in the above image. The task here is to replace this pool list by a pool of time servers closest to your location. The pol.ntp.org project provides reliable NTP service from a big cluster of time servers. To choose a pool list according to your location, visit the following page:

We have searched for a pool list for the US:

The page tells us to add the following lines to the ntp.conf file:

This is how my file looks after adding the above lines to it:

Quit the file by hitting Ctrl+X and then by entering y for saving changes.

Step 5: Restart the NTP server

In order for the above changes to take effect, you need to restart the NTP server. Run the following command as sudo in order to do so:

Step 6: Verify that the NTP Server is running

Now, check the status of the NTP service through the following command:

The Active status verifies that your NTP server is up and running.

Step 7: Configure Firewall so that client(s) can access NTP server

Finally, it is time to configure your system’s UFW firewall so that incoming connections can access the NTP server at UDP Port number 123.

Run the following command as sudo to open port 123 for incoming traffic:

Your Ubuntu host machine is now configured to be used as an NTP server.

Configure NTP Client to be Time Synced with the NTP Server

Let us now configure our Ubuntu client machine to be time-synchronized with the NTP server.

Step 1: Install ntpdate

The ntpdate command will let you manually check your connection configuration with the NTP-server. Open the Terminal application on the client machine and enter the following command as sudo:

Step 2: Specify IP and hostname of the NTP server in the hosts file

For your NTP server to be resolved by a hostname in your client machine, you need to configure your /etc/hosts file.

Open the hosts file as sudo in the nano editor by entering the following command:

Now add your NTP server’s IP and specify a hostname as follows in this file:

Quit the file by hitting Ctrl+X and then save it by entering y.

Step 3: Check if the client machine’s time is synchronized with NTP server

The following ntpdate command will let you manually check if time is synchronized between the client and server systems:

The output should ideally show a time offset between the two systems.

Step 4: Disable the systemd timesyncd service on the client

Because we want our client to sync time with the NTP server, let us disable the timesyncd service on the client machine.

Enter the following command to do so:

Step 5: Install NTP on your client

Run the following command as sudo in order to install NTP on your client machine:

Читайте также:  Assembler ide mac os

Step 6: Configure the /etc/ntp.conf file to add your NTP server as the new time server

Now we want our client machine to use our own NTP host server to be used as the default time server. For this, we need to edit the /etc/ntp.conf file on the client machine.

Run the following command as sudo in order to open the file in the Nano editor:

Then, add the following line in the file, where NTP-server-host is the hostname you specified for your NTP server:

This is how my file looks like after I have specified the time server:

Hit Ctrl+x in order to quit the file and then enter y to save the changes.

Step 7: Restart the NTP server

In order for the above changes to take effect, you need to restart the NTP service. Run the following command as sudo in order to do so:

Step 8: View the Time Synchronization Queue

Now your client and server machines are configured to be time-synced. You can view the time synchronization queue by running the following command:

You should be able to see NTP-server-host as the time synchronization host/source in the queue.

So this was all you needed to know about installing and configuring NTP to synchronize time on your networked Ubuntu machines. The process may seem a little cumbersome but if you follow all of the above steps carefully, one-by-one, your machines will be synced in no time.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Источник

How to Install NTP Server and Client on Ubuntu

Network Time Protocol, commonly referred to as NTP, is a protocol that’s responsible for synchronizing system clocks in a network. NTP refers to both the protocol and the client system alongside the server programs residing on the networked systems.

In this guide, we will show you how to install NTP server and client(s) on Ubuntu 18.04.

Testing Environments

This guide aims at accomplishing the following:

  • Installing and configuring NTP server on Ubuntu 18.04 server.
  • Installing NTP client on Ubuntu 18.04 client machine and ensure that it is synched by the Server.

Let’s get started !

Install & Configure NTP Server on Ubuntu 18.04 Server

Below is a step-by-step procedure of installing the NTP server and making the necessary modifications to achieve the desired time synchronization in the network.

Step 1: Update System Repositories

To start off, let’s begin by updating the system packages as shown.

Update Ubuntu System

Step 2: Install NTP Server on Ubuntu 18.04

With system packages already installed, install NTP protocol on Ubuntu 18.04 LTS by running.

When prompted, type Y and hit ENTER to complete the installation process.

Install NTP Server on Ubuntu

To confirm that NTP protocol has been successfully installed, run the command.

Check NTP on Ubuntu

Step 3: Configure NTP Server Pools on Ubuntu 18.04

By default, NTP protocol comes with default NTP pool servers already configured in its configuration file as shown below in the /etc/ntp.conf file.

Default NTP Server Pools

These usually work just as fine. However, you may consider changing to NTP server pools closest to your location. The link below directs you to a page where you can select your most preferred NTP pool list.

In our example, we will use the NTP pools located in Europe as shown.

NTP Pools from Europe

To replace the default NTP pool servers, open the NTP configuration file using your favorite text editor as shown.

Читайте также:  Singularity нет звука windows

Copy and paste the NTP pool list in Europe to the configuration files as shown.

Configure NTP Pools on Ubuntu

Next, save and quit the text editor.

For the changes to take effect, restart the NTP service and verify its status using the commands.

Verify NTP Status

If UFW firewall is enabled, we need to allow NTP service across it so that client machines can access the NTP server.

To implement the changes, reload the firewall as shown.

To verify the changes made execute the command.

Verify NTP Access on UFW Firewall

Perfect! we have successfully set up our NTP server on Ubuntu 18.04 LTS system. Let’s now set up NTP on the client system.

Install & Configure NTP Client on Ubuntu 18.04 Client

In this section, we shall install and configure a NTP client on Ubuntu 18.04 client system to be synchronized by the Ubuntu 18.04 NTP Server system.

Step 1: Update System Repositories

To start off, update the system by running.

Update NTP Client Machine

Step 2: Install Ntpdate on Ubuntu 18.04

ntpdate is a utility/program that quickly allows a system to synchronize time and date by querying an NTP server.

To install ntpdate run the command.

Install ntpdate on Ubuntu Client

For the client system to resolve the NTP server by hostname, you need to add the NTP server’s IP address and hostname in the /etc/hosts file.

Therefore, Open the file using your favorite text editor.

Append the IP address and hostname as shown.

Add IP Address and Hostname

Step 3: Verify Client Time Sync with NTP Server

To manually check if the client system is in sync with the NTP server’s time, run the command.

In our case, the command will be.

A time offset between the NTP server and the client system will be displayed as shown.

Verify Client Time Sync with NTP Server

To synchronize the client time with the NTP server, you need to turn off the timesynchd service on the client system.

Step 4: Install NTP Client on Ubuntu 18.04

Next, you need to install NTP service on the client system. To achieve this, issue the command.

Press Y when prompted and hit ENTER to proceed with the installation process.

Install NTP Client on Ubuntu

Step 5: Configure NTP Client on Ubuntu 18.04

The objective in this step is to use the NTP server earlier configured to act as our NTP server. For this to happen we need to edit the /etc/ntp.conf file.

Append the line below where bionic is the NTP server’s hostname.

Configure NTP Client on Ubuntu

Save and exit the configuration file.

For the changes to come into effect, restart the NTP service as shown.

Step 6: Verify the NTP Time Synchronization Queue

With the client and NTP server insync, you can view the sync details by executing the command.

Sample Output

This brings us to the end of this guide. At this point you have successfully configured the NTP server on Ubuntu 18.04 LTS and configured a client system to be synchronized with the NTP server. Feel free to reach out to us with your feedback.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.

Источник

Оцените статью