Configurar Servidores de NTP (Linux) – parte 2
Por Spawnzao em 08/08/2014 - 2,423 views
Continuando o artigo anterior, já temos o nosso Servidor Windows rodando o Active Directory com a hora atualizada com os servidores NTP do www.ntp.br Oficiais:
- a.st1.ntp.br
- b.st1.ntp.br
- c.st1.ntp.br
- d.st1.ntp.br
- a.ntp.br
- b.ntp.br
- c.ntp.br
- gps.ntp.br
Agora vamos configurar os nossos servidores Linux para sincronizar o NTP com o Servidor principal de NTP interno, que no nosso tutorial é o domainserver.local.seweb.corp, no qual possui o Active Directory.
Abaixo segue a topologia sugerida:
Caso o NTP não esteja instalado, execute:
yum install ntp ntpdate
Agora vamos configurar o arquivo /etc/ntp.conf, que inicialmente vem com o seguinte conteúdo:
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).driftfile /var/lib/ntp/drift
# 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 127.0.0.1
restrict -6 ::1# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst#
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst#broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client# Enable public key cryptography.
#cryptoincludefile /etc/ntp/crypto/pw
# 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 ntpdc utility.
#requestkey 8# Specify the key identifier to use with the ntpq utility.
#controlkey 8# Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats
Vamos deixá-lo assim:
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).driftfile /var/lib/ntp/drift
# 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 127.0.0.1
restrict -6 ::1# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server domainserver.local.seweb.corp iburst# Enable public key cryptography.
#cryptoincludefile /etc/ntp/crypto/pw
# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
Agora vamos iniciar o serviço de NTP local:
service ntpd start
Vamos forçar uma sincronização inicial, caso o servidor esteja com diferença de hora acima de 16 minutos.
ntpd -q -g
Agora podemos confirmar se o NTP está rodando corretamente e sincronizado com o domainserver.local.seweb.corp.
ntpq -p
Temos o seguinte resultado:
remote refid st t when poll reach delay offset jitter
==============================================================================
domainserver.lo 192.168.1.1 3 u 314 64 360 0.000 0.000 266676.
Segue abaixo o significado:
- remote – nome ou IP da fonte de tempo
- refid – a referência (par do sistema) à qual o servidor de tempo remoto está sincronizado
- st – o estrato da fonte de tempo
- when – quanto segundos se passaram desde a última consulta à essa fonte de tempo
- poll – de quantos em quantos segundos essa fonte é consultada
- reach – um registrador de 8 bits que vai girando para a esquerda representado na forma octal, que mostra o resultado das últimas 8 consultas à fonte de tempo: 377 = 11.111.111 significa que todas as consultass foram bem sucedidas; outros número indicam falhas, por exemplo 375 = 11.111.101, indica que a penúltima consulta falhou
- delay – atrasou, ou tempo de ida e volta, em milisegundos, dos pacotes até essa fonte de tempo
- offset – deslocamento, ou quanto o relógio local tem de ser adiantado ou atrasado, em milisegundos, para ficar igual ao da fonte de tempo
- jitter – a variação, em milisegundos, entre as diferentes medidas de deslocamento para essa fonte de tempo
Para visualizar as variáveis globais, podemos usar:
ntpq -c rl
associd=0 status=0618 leap_none, sync_ntp, 1 event, no_sys_peer,
version=”ntpd 4.2.6p5@1.2349-o Sat Nov 23 18:21:48 UTC 2013 (1)”,
processor=”x86_64″, system=”Linux/2.6.32-431.11.2.el6.x86_64″, leap=00,
stratum=3, precision=-24, rootdelay=43.196, rootdisp=155.500,
refid=192.168.1.1,
reftime=d78dba9e.365ebe8d Fri, Aug 8 2014 18:07:10.212,
clock=d78fedcd.dd6570d1 Fri, Aug 8 2014 18:21:17.864, peer=51447,
tc=10, mintc=3, offset=6.352, frequency=49.871, sys_jitter=7.518,
clk_jitter=6.812, clk_wander=0.522
Até o próximo.