NTP: Instalación y configuración

Instalación

RedHat/CentOS

1
yum install ntp

Debian/Ubuntu

1
apt-get install ntp

SLES/OpenSuse

Activar el primer repositorio e instalar ntp y ntpdate.

1
2
zypper mr -e 1
zypper install ntp ntpdate

Configuración

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
mv /etc/ntp.conf /etc/ntp.conf.ori
cat << EOF >/etc/ntp.conf
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/ntp/ntp.drift
# Specify one or more NTP servers.
server 172.16.0.128 iburst
server 172.16.0.009 iburst
# By default, exchange time with everybody, but dont allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1
# Enable this if you want statistics to be logged.
statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

Configurar el inicio del demonio

RedHat/CentOS

1
2
systemctl restart ntpd
systemctl enable ntpd

Debian/Ubuntu

1
2
/etc/init.d/ntp restart
update-rc.d ntp defaults

SLES/OpenSuse

1
2
/etc/init.d/ntp restart
update-rc.d ntp defaults

Comprobar el estado

Es posible comprobar el estado del servidor de NTP invocando ntpq -p.

Ejemplo RedHat/CentOS

1
2
3
4
5
6
7
[root@nagios /]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
-pdc1-2012.ad 130.206.3.166 2 u 4 64 1 0.563 -1.876 5.716
+pdc2-2012.ad 172.16.0.126 3 u 3 64 1 0.527 0.017 0.505
*hora.rediris.es .GPS. 1 u 2 64 1 3.579 1.717 0.173
+hora.roa.es .PPS. 1 u 1 64 1 18.320 2.429 0.238

Ejemplo Debian/Ubuntu

1
2
3
4
5
root@apache03:/# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*pdc1-2012.ad 130.206.3.166 2 u 968 1024 377 0.786 -5.358 5.717
+pdc2-2012.ad 172.16.0.126 3 u 1024 1024 377 1.302 6.081 5.420

Entradas de interés

Contenidos
  1. 1. Instalación
    1. 1.1. RedHat/CentOS
    2. 1.2. Debian/Ubuntu
    3. 1.3. SLES/OpenSuse
  2. 2. Configuración
  3. 3. Configurar el inicio del demonio
    1. 3.1. RedHat/CentOS
    2. 3.2. Debian/Ubuntu
    3. 3.3. SLES/OpenSuse
  4. 4. Comprobar el estado
    1. 4.1. Ejemplo RedHat/CentOS
    2. 4.2. Ejemplo Debian/Ubuntu