Why do we need NTP? What is its structure and how should it be built? Some people say that the NTP protocol keeps the clocks on all your hosts in sync. In the end, let's take a look!

Network Time Protocol (NTP) is used to synchronize the system clocks of different hosts on the network. All managed hosts can synchronize time with a specified time server called an NTP server. On the other hand, the NTP server synchronizes its time with any public NTP server or any server of your choice. All NTP-managed devices can be accurate to the millisecond level when their system time is synchronized.

In an enterprise environment, if a company does not want to open a firewall for NTP traffic, it is necessary to set up an internal NTP server so that employees can use internal servers instead of public NTP servers. In this tutorial we will show you how to configure the CentOS system as an NTP server. Before you go into the details, let's take a look at the NTP concept.

Why do we need NTP?

Due to manufacturing differences, all (non-atomic) clocks do not run at exactly the same speed. Some clocks tend to go faster, while others go slower. So after a long period of time, the time of one clock gradually deviates from the other clock, resulting in the so-called "clock drift" or "time drift". In order to minimize the impact of clock drift, hosts using NTP should periodically contact the specified NTP server to keep the clock synchronized.

Time synchronization between different hosts is important for transactions such as scheduled backups, intrusion detection logs, distributed task scheduling, or transaction bookkeeping, and may even be a requirement for regulatory compliance.

NTP hierarchy

The NTP clocks are organized in a hierarchical hierarchy. Each layer in the hierarchy is called a stratum. The concept of layers describes how many NTP hops a machine has from an authoritative time source.

Analysis of the Importance of NTP (Taking CentOS as an Example)

Stratum 0 contains clocks with little time drift, such as atomic clocks. These clocks cannot be used directly over the network. The Stratum N(N) 1 server synchronizes its time against the Stratum N-1 server. Stratum N clocks can be connected to each other via the network.

NTP supports up to 15 layers in the hierarchy. Stratum 16 is considered to be out of sync and unusable.

Prepare the CentOS server

Now let's talk about how to set up an NTP server on CentOS.

First, we need to make sure that the server's time zone is set up correctly. In CentOS 7, we can use the TImedatectl command to view and change the server's time zone (such as "Australia/Adelaide").

# TImedatectl list-TImezones | grep Australia

# TImedatectl set-timezone Australia/Adelaide

# timedatectl

Analysis of the Importance of NTP (Taking CentOS as an Example)

Next, use yum to install the necessary software.

# yum install ntp

Then we will add a global NTP server to synchronize the time.

# vim /etc/ntp.conf

Server 0.oceania.pool.ntp.org

Server 1.oceania.pool.ntp.org

Server 2.oceania.pool.ntp.org

Server 3.oceania.pool.ntp.org

By default, NTP server logs are saved in /var/log/messages. If you want to use a custom log file, you can also specify the location of the file.

Logfile /var/log/ntpd.log

If you really choose to use a custom log file, be sure to change its ownership and SELinux context.

# chown ntp:ntp /var/log/ntpd.log

# chcon -t ntpd_log_t /var/log/ntpd.log

Now start the NTP service and make sure it has been added to the startup item.

# systemctl restart ntp

# systemctl enable ntp

Verify the NTP server clock

We can use the ntpq command to check how the local server's clock is synchronized via NTP.

Analysis of the Importance of NTP (Taking CentOS as an Example)

The following table explains the above output columns.

Analysis of the Importance of NTP (Taking CentOS as an Example)

Control access to the NTP server

By default, the NTP server allows inbound queries from all hosts. If you want to filter inbound NTP sync connections, you can add a rule to the firewall to filter traffic.

# iptables -A INPUT -s 192.168.1.0/24 -p udp --dport 123 -j ACCEPT

# iptables -A INPUT -p udp --dport 123 -j DROP

This rule will allow NTP servers from 192.168.1.0/24 (via port UDP/123) to deny traffic from all other networks. You can update the rules to suit your requirements.

Configuring an NTP client

1. Linux

The NTP client host requires the ntpdate package to synchronize its time against the server. It is easy to install the package using yum or apt-get. After installing the package, run the command with the server IP address.

# ntpdate "server-IP-address"

If it is based on RHEL and Debian systems, the commands are exactly the same.

2. Windows

If you use Windows, look for "Internet time" under the date and time settings.

3. Cisco equipment

If you want to synchronize the time of the device, you can use the following command from the global configuration mode.

# ntp server "server-IP-address"

P2.2X3 Automotive Right Angle Male Connector

P2.2X3 Automotive Right Angle Male Connector.Automobile connector is a kind of component that electronic engineers and technicians often contact. Its function is very simple: build a communication bridge between blocked or isolated circuits in the circuit, so as to make the current flow and realize the predetermined function of the circuit. The form and structure of automobile connector are ever-changing. It is mainly composed of four basic structural components: contact, shell (depending on the variety), insulator and accessories.

P2.2X3 Automotive Right Angle Male Connector

ShenZhen Antenk Electronics Co,Ltd , https://www.antenkcon.com

Posted on