Atlantic.Net Blog

Install and Configure Network Time Protocol (NTP) on Arch Linux

Hitesh Jethva
by Atlantic.Net (509 posts) under Dedicated Server Hosting, Tutorials
0 Comments

NTP, also known as a “Network Time Protocol,” is an Internet time protocol used to sync computer time with network time. NTP is built on UDP and uses port 123 for communication, while NTP clients use port 1023. NTP can be installed on any operating system and uses time from an external source to maintain time within its local internal clock. Generally, NTP is required for many distributed applications where time synchronization is a must between all nodes.

In this post, we will show you how to install NTP on Arch Linux.

Prerequisites

  • A fresh Arch Linux server on the Atlantic.Net Cloud Platform
  • A root password configured on your server

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Arch Linux as the operating system with at least 2GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Step 2 – Configure Repository

By default, the default repository is outdated in Arch Linux, so you will need to modify the default mirror list. You can do it by editing the mirrorlist configuration file:

nano  /etc/pacman.d/mirrorlist

Remove all lines and add the following lines:

## Score: 0.7, United States
Server = http://mirror.us.leaseweb.net/archlinux/$repo/os/$arch
## Score: 0.8, United States
Server = http://lug.mtu.edu/archlinux/$repo/os/$arch
Server = http://mirror.nl.leaseweb.net/archlinux/$repo/os/$arch
## Score: 0.9, United Kingdom
Server = http://mirror.bytemark.co.uk/archlinux/$repo/os/$arch
## Score: 1.5, United Kingdom
Server = http://mirrors.manchester.m247.com/arch-linux/$repo/os/$arch
Server = http://archlinux.dcc.fc.up.pt/$repo/os/$arch
## Score: 6.6, United States
Server = http://mirror.cs.pitt.edu/archlinux/$repo/os/$arch
## Score: 6.7, United States
Server = http://mirrors.acm.wpi.edu/archlinux/$repo/os/$arch
## Score: 6.8, United States
Server = http://ftp.osuosl.org/pub/archlinux/$repo/os/$arch
## Score: 7.1, India
Server = http://mirror.cse.iitk.ac.in/archlinux/$repo/os/$arch
## Score: 10.1, United States
Server = http://mirrors.xmission.com/archlinux/$repo/os/$arch

Save and close the file, then update all the package indexes with the following command:

pacman -Syu

Step 3 – Basic Time Commands

You can use the date command to view the data and time on your server.

date

You will get the following output.

Wed Jan  4 11:05:42 AM UTC 2023

As you can see, the timezone is set to UTC. To list all time zones, run the following command.

timedatectl list-timezones

You can set the timezone to America/New_York using the following command.

timedatectl set-timezone America/New_York

You can also verify time synchronization on your server using the following command.

timedatectl

You should see that time synchronization is active on your server.

               Local time: Wed 2023-01-04 06:07:10 EST
           Universal time: Wed 2023-01-04 11:07:10 UTC
                 RTC time: Wed 2023-01-04 11:07:11
                Time zone: America/New_York (EST, -0500)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

Before installing NTP, you will need to disable time synchronization. You can disable it with the following command.

timedatectl set-ntp no

You can verify it with the following command.

timedatectl

Output.

               Local time: Wed 2023-01-04 06:07:52 EST
           Universal time: Wed 2023-01-04 11:07:52 UTC
                 RTC time: Wed 2023-01-04 11:07:53
                Time zone: America/New_York (EST, -0500)
System clock synchronized: yes
              NTP service: inactive
          RTC in local TZ: no

Step 4 – Install and Configure NTP

By default, the NTP package is available in the Arch Linux default repository. You can install it with the following command.

pacman -S ntp

Once NTP is installed, edit the NTP default configuration file:

nano /etc/ntp.conf

Change the default NTP server pool with your nearest server.

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

Save and close the file, then restart NTP to apply the changes.

systemctl restart ntpd

Now, verify time synchronization with the following command.

ntpq -p

If everything is fine, you will get the following output.

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 103.177.8.228 ( .INIT.          16 u    -   64    0    0.000   +0.000   0.000
 time.firstlink. 202.12.97.45     2 u    3   64    1  268.468   -4.858   0.000
 time.cloudflare 10.15.13.248     3 u    6   64    1    2.406   -0.133   0.000
 ns.tu.ac.th     110.170.126.105  2 u    6   64    1  264.671   +7.973   0.000

Conclusion

In this post, we explained how to install an NTP server on Arch Linux. You can now install NTP in your local network to synchronize system time with internet time. You can test your NTP server on dedicated server hosting from Atlantic.Net!

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

Install Netdata Monitoring Tool on Arch Linux
How to Install Vue.js on Arch Linux
How to install Monit Monitoring Tool on Arch Linux
Top 10 Best Cloud HR / HRMS Solutions in 2023
Install and Configure Network Time Protocol (NTP) on Arch Linux

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2008 Lookout Dr,

Garland, Texas 75044

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources