Linux - Network Time Protocol su Centos

1) Installiamo ntp:

[root@ns ~]# yum -y install ntp

[root@ns ~]# mv /etc/ntp.conf /etc/ntp.conf.bk

[root@ns ~]# vim /etc/ntp.conf

Vedere la fine dell'articolo per vedere come settare correttamente i vari parametri.

2) Finito ciò bisogna sincronizzare l'ora del sistema:

[root@ns ~]#  ntpdate -b

3) Per vedere se i client sono sincronizzati correttamente si usa il comando ntpq
- L'opzione -p si usa per vedere tutti i client.
- L'opzione -4 permette di risolvere il nome del client nell'IP

4) ntpq -4 -p localhost

5) Va aperta la porta del firewall locale per il protocollo NTP TCP/UDP 123 con il comando:

[root@ns ~]# system-config-securitylevel-tui

e la sintassi 123:tcp 123:udp

6) [root@ns ~]# /etc/init.d/ntpd start

[root@ns ~]# chkconfig ntpd on

[root@ns ~]# ntpq -p

[root@ns ~]# chkconfig --level 2345 ntpd on
[root@ns ~]# /etc/init.d/ntpd restart

7) Per settare il sntp in windows xp/2000

C:\net time /querysntp
This computer is not currently configured to use a specific SNTP server.

To configure the client to use the time server, use the following command:

C:\net time /setsntp:

It may be necessary to restart the w32time service. To do this from the command line, use the following two commands:

net stop w32time

net start w32time

These settings will persist after the system reboots.

8) di seguito un esempio del file ntp.conf

# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict -6 ::1

# Hosts on local network are less restricted.
restrict mask nomodify notrap

# Use public servers from the project.
# Please consider joining the pool (

#broadcast key 42         # broadcast server
#broadcastclient                 # broadcast client
#broadcast key 42             # multicast server
#broadcast key 42             # multicast server
#multicastclient              # multicast client
#manycastserver         # manycast server
#manycastclient key 42  # manycast client

# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server     # local clock
fudge stratum 10

# Drift file.  Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
driftfile /var/lib/ntp/drift

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42
# Specify the key identifier to use with the ntpq utility.
#controlkey 8