- 2 ways to check NTP server in Linux
- What is NTP?
- Check ntp server with ntpq command in Linux
- Check ntp service with systemctl command in Linux
- how to change ntp server in Linux
- How to use multiple NTP servers at once?
- What is the default polling interval for the NTP service?
- Which is better, a manually configured ntp service or an automatic one?
- What is the ‘driftfile’ for NTP
- Why is my ntp server not working?
- How do I find my NTP server in Debian
- How do I find my NTP server on Debian
- Conclusion
- About the author
- Hammad Zahid
2 ways to check NTP server in Linux
In this blog post, we will show you how to check the NTP server on Linux. This is an important task if you are running a server and need to make sure that your time is accurate. The NTP service can be used to synchronize the time on your computer with a time server. This can help ensure that your system is always running accurately and on schedule. Let’s take a look at how to check the NTP service on Linux!
What is NTP?
The Network Time Protocol (NTP) is a protocol used to synchronize the time on your computer with a time server. This can help ensure that your system is always running accurately and on schedule. By default, most Linux distributions come with the Network Time Protocol (NTP) service installed and running.
Check ntp server with ntpq command in Linux
The ntpq command is the best way to check ntp server in Linux. It can be used to get information about the NTP service, such as the server that it is using to synchronize the time.To do this, we can type in ‘ntpq -p’ in the terminal and press Enter.
This will list the NTP servers the system is synchronizing with:
remote refid st t when poll reach delay offset jitter
==============================================================================
*85.199.214.98 .GPS. 1 u 38 64 377 5.047 -0.184 0.131
+81.21.65.168 .STEP. 16 u – 1024 0 0.000 0.000 0.000
-178.79.155.116 .STEP. 16 u – 1024 0 0.000 0.000 0.000
81.21.76.27 .STEP. 16 u – 1024 0 0.000 0.000 0.000
The host addresses shown in the remote column should agree with the DNS entries in the configuration file, plus any peers not mentioned in the file at the same or lower than your stratum that happen to be configured to peer with you. Be prepared for surprises in cases where the peer has multiple addresses or multiple names. The refid entry shows the current source of synchronization for each peer, while the st reveals its stratum and the poll entry the polling interval, in seconds.
The when entry shows the time since the peer was last heard, normally in seconds, while the reach entry shows the status of the reachability register (see RFC-1305), which is in octal format. The remaining entries show the latest delay, offset and dispersion computed for the peer, in milliseconds.
The tattletale character at the left margin displays the synchronization status of each peer. The currently selected peer is marked * , while additional peers designated acceptable for synchronization, but not currently selected, are marked + . Peers marked * and + are included in a weighted average computation to set the local clock; the data produced by peers marked with other symbols are discarded. See the ntpq documentation for the meaning of these symbols.
The ‘ntpq’ command is a powerful tool that can be used to troubleshoot the NTP service. In order to use the ntpq command, we need to type in ‘ntpq -h’ and press Enter. This will show us all of the options that are available for the ntpq command.
Check ntp service with systemctl command in Linux
we can also use the command ‘sudo systemctl status ntp’ to check the status of the NTP service. This will give us more information about the service, including whether it is running or not.
The ‘systemctl’ command is a powerful tool that can be used to manage services on Linux. We can use the ‘systemctl status’ command to check the status of a service. This will tell us whether the service is running or not.
We can also use the ‘systemctl start’ and ‘systemctl stop’ commands to start and stop services. In this case, we would use the ‘sudo systemctl start ntp’ and ‘sudo systemctl stop ntp’ commands to start and stop the NTP service.
We can use the ‘systemctl enable’ command to enable a service to start automatically at boot time. In this case, we would use the ‘sudo systemctl enable ntp’ command to enable the NTP service.
We can also use the ‘systemctl disable’ command to disable a service from starting automatically at boot time. In this case, we would use the ‘sudo systemctl disable ntp’ command to disable the NTP service.
how to change ntp server in Linux
In order to change the NTP server that is used by the NTP service, we can use the ‘ntpdate’ command. This command can be used to set the time on your computer using a time server. We can use the ‘ntpdate’ command to change the NTP server that is used by the NTP service. To do this, we will type in ‘sudo ntpdate time.nist.gov’ and press Enter. This will change the NTP server to the National Institute of Standards and Technology (NIST) time server.
We can also change the ntp server in Linux by editing the ‘/etc/ntp.conf’ file. This file contains a list of all of the available time servers. We can add or remove servers as needed.
How to use multiple NTP servers at once?
Yes, you can use multiple time servers at once by adding them to the ‘/etc/ntp.conf’ file. You can add or remove servers as needed.
What is the default polling interval for the NTP service?
The default polling interval is 64 seconds. This can be changed by editing the ‘/etc/ntp.conf’ file.
Which is better, a manually configured ntp service or an automatic one?
It depends on your needs. If you need more control over the NTP service, then you should configure it manually. If you don’t need as much control, then an automatic configuration may be better.You can find more information about the NTP service in the ‘/etc/ntp.conf’ file. This file contains a list of all of the available time servers. You can add or remove servers as needed.
What is the ‘driftfile’ for NTP
The driftfile is used by the NTP service to store the current time offset. This file is located at ‘/var/lib/ntp/drift’.
Why is my ntp server not working?
- There are a few reasons why your ntp server may not be working. First, make sure that you have added the correct server to the ‘/etc/ntp.conf’ file. You can add or remove servers as needed.
- Second, make sure that your firewall is configured to allow traffic on port 123 UDP.
- Third, make sure that the NTP service is running. You can check the status of the service with the ‘sudo systemctl status ntp’ command.
- If you are still having trouble, you can try using a different time server. You can find a list of available time servers at ‘/etc/ntp.conf’.
The NTP service is a vital part of keeping your computer’s time accurate. By using the ‘ntpq’ and ‘systemctl’ commands, we can easily check the status of the NTP service and change the NTP server if necessary. With a few simple commands, we can ensure that our computer is always running on schedule.
That’s all there is to it! In this blog post, we have shown you how to check the NTP service on Linux. This is an important task if you are running a server and need to make sure that your time is accurate. The NTP service can be used to synchronize the time on your computer with a time server. This can help ensure that your system is always running accurately and on schedule. Thanks for reading!
How do I find my NTP server in Debian
NTP is an abbreviation of “Network Time Protocol” which is used to synchronize the time of the server and the client machine. In this process, the client machine requests the server for the current time and the server sends data in the form of packets. There is a standard of time that is universal and followed by everyone known as UTC (Coordinated Universal Time). Port 123 is by default allocated to the NTP server and this whole process is followed by the User Datagram Protocol (UDP).
In this post, we are focusing on finding the NTP server by installing and configuring the NTP in Debian.
How do I find my NTP server on Debian
NTP is a process in which the client machine requests the server to set its time. So first we will understand how to install and configure the NTP server then will learn how to find out the IP addresses of NTP.
Installation and Configuration of NTP : First, we will update Debian’s repository:
We will install the latest package available of NTP:
By default, after the installation, NTP should be of active status, you can confirm it by checking its status but if it is inactive, you can start the NTP server:
After restarting, check its status whether it is running or not:
Hence the NTP is running. Now, we will configure the firewall so it will allow the client to request the server else it will restrict the client to send any query and for this purpose will first go to the root mode.
Run these two commands here, asking the firewall to allow the queries on port 123 which is by default allocated to the NTP.
iptables -A OUTPUT -p udp —dport 123 -j ACCEPT
iptables -A INPUT -p udp —dport 123 -j ACCEPT
Now we will exit the root user mode as:
Verification of the NTP working using ntpstat : The ntpstat command shows us whether the connection is established between the server and client, if the connection is established, then the status will be “synchronized”. If ntpstat generates the error of “command not found” on running the command:
Then we can install ntpstat running the following command.
Now to check the status, again run the command.
The output shows the NTP server IP address along with the recent details of the correction of time with the server and to verify the status of synchronization of the clock we will run the command to get the exit status.
The outcome “0” means the client’s clock is synchronized with the server. The other outcomes can be either “1” which means the clock of the client machine is not synchronized with the server or “2” which means the client is not connected to the server.
Checking the ntp server using ntpq command : Ntpq command monitors the NTP daemon, ntpd operations, and determines the performance of the NTP. We will use flags, p which means print the entire list of the peers known by the server with the summary of their state, and n which means display the host addresses.
Conclusion
NTP enables us to synchronize with the same time units that the world is following. NTP sets the time of its machine by asking the server to give it time information and then both are synchronized with the time of the internet. In this post, we have discussed two methods by which we can get the information about our NTP server in Debian. Hope this post will help you understand not only how to find our NTP server on Debian but also the installation and configuration of NTP on both server and client’s machine.
About the author
Hammad Zahid
I’m an Engineering graduate and my passion for IT has brought me to Linux. Now here I’m learning and sharing my knowledge with the world.