Tech Junkie Blog - Real World Tutorials, Happy Coding!: Linux Networking: Network Time Protocol (NTP) Part 1, Understanding Linux Time

Monday, July 5, 2021

Linux Networking: Network Time Protocol (NTP) Part 1, Understanding Linux Time

 NTP stands for Network Time Protocol, in a nutshell what this service does is that it synchronizes your servers so that communications is reliable between servers.  The reason NTP is needed is because there are three types of time in computer networking.  They are the following:

  1. Hardware time
  2. System time
  3. NTP
The first two types of time are not reliable by nature because it could be set by people or it could be wrong.  So there's NTP time which is synched to the internet, which we always trust because the internet never lies.  For example a system admin can use the date --set command and set the wrong time.  This is crucial if you have network peers.  You can use the date and hwclock commands to the display the system time and hardware time respectively

You can use the command hwclock --systohc to sync the hardware time to the system time or hwclock --hctosys in the reverse direction, but as you can see from the scenario the system time can be manipulated and set incorrectly.

NTP is graded by Stratums with a scale, yeah buzzwords! So if you have a stratum of 1 that means you are the champ you are at atomic clock synchronization, and if you are at 16 you are a chump!  Best explanation ever!

Anyways to check if you are using NTP you can type the timedatectl status on the terminal

As you can see I am a champ, because the timedatectl status command tells me that my system clock is synchronized and my NTP service is active, and if you say otherwise, "I will break you!".  It's my blog sorry.  Besides showing the status timedatectl is also useful in setting the time it will check to see if the time you set is reasonable for instance you can set the time to 1999 because you wanted to party like it's 1999.  Let's see what happens time using the command timedatectl set-time "1999-01-01 00:00:00" 

As you can see the NTP service will not allow you to party like it's 1999 it will give you a message that says set time command failed because NTP is active.  So it gives you a nice reminder that life is not one big party. With Linux you have total control for the most part so you can turn off ntp with the command timedatectl set-ntp false and then party like it's 1999.  But why would you want to do that?

1 comment:

  1. I just wanted to say that I love every time visiting your wonderful post! Great information you shared through this blog. Keep it up and best of luck for your future blogs and posts.


Search This Blog