Network Time Protocol NTP daemon

Ntpd is a daemon used to keep system time of server synchronized with Internet standard time servers. Ntpd is the acronymous of Network Time Protocol (NTP) daemon. Your server could be a client (asks time) or a server (gives time). Even if you don’t have ntpd set, your server has an internal clock which keep your server time updated (but of course not synchronized with Internet standard time servers).

NTP configuration

You can find ntp configuration in the file:


In this file are indicated the ip address of the ntp servers you need for sync

server ntpserver1
server ntpserver2

Hardware Clock and System Clock

Any server has two different clock: hardware and system.
Hardware Clock is set on BIOS and it is independent from the system you have installed in your server. Server Battery keeps Hardware clock update even if you switch off your server.
System Clock is kept by Kernel Linux, It is a software Clock.

date and hwclock are two command necessary to show or set system clock (date) or hardware clock (hwclock).

[root@server ~]# date
gio 21 mag 2015, 15.19.37, UTC
[root@server ~]# hwclock
gio 21 mag 2015 15:20:21 UTC -0.562774 seconds

 Synchronize Clock

If your server is not synchronized or you have a mismatch between hardware clock and system clock, you can manually synchronize your server using the following:

service ntpd stop
ntpdate ntp_server_name_or_ip
hwclock --systohc
service ntpd start

hwclock –systohc sync hardware and system clock. You can set it as UTC or Localtime as you prefer

hwclock --systohc --utc
hwclock --systohc --localtime

In case you need to the clock difference between your server and another_server you need clockdiff command

clockdiff another_server host=another_server rtt=750(187)ms/0ms delta=79685ms/79685ms Thu May 21 15:35:11 2015

Open iptables NTP port

NTP uses port 123 udp. So it is important that you open this port in your IPTABLES if you are configuring an ntp server.

-A INPUT -p udp --dport 123 -j ACCEPT
-A OUTPUT -p udp --sport 123 -j ACCEPT


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.