Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎專欄 | Search | About

第 32 章 OpenNTPD

Synchronizes system time using the Network Time Protocol (NTP)

目錄

32.1. install
32.1.1. ntpd - Network Time Protocol (NTP) daemon
32.1.2. Ubuntu
32.1.3. ntpdate
32.2. ntpdate
32.2.1. CentOS 7
32.2.2. CentOS 6
32.3. ntpd.conf / ntp.conf
32.3.1. server 配置
32.3.2. ntp 安全設置
32.4. ntpstat - show network time synchronisation status
32.5. ntpq - standard NTP query program

http://www.ntp.org

http://www.pool.ntp.org/

32.1. install

32.1.1. ntpd - Network Time Protocol (NTP) daemon

過程 32.1. ntp server

  1. # yum install ntp	
    					
  2. port

    [root@ntp ~]# netstat -unlnp |grep 123
    udp        0      0 192.168.5.5:123             0.0.0.0:*                               10810/ntpd
    udp        0      0 172.16.0.5:123              0.0.0.0:*                               10810/ntpd
    udp        0      0 192.168.3.5:123             0.0.0.0:*                               10810/ntpd
    udp        0      0 127.0.0.1:123               0.0.0.0:*                               10810/ntpd
    udp        0      0 0.0.0.0:123                 0.0.0.0:*                               10810/ntpd
    udp        0      0 ::1:123                     :::*                                    10810/ntpd
    udp        0      0 fe80::225:64ff:fe9a:123     :::*                                    10810/ntpd
    udp        0      0 :::123                      :::*                                    10810/ntpd
    
    [root@ntp ~]# lsof -i :123
    COMMAND   PID USER   FD   TYPE DEVICE SIZE NODE NAME
    ntpd    10810  ntp   16u  IPv4  35921       UDP *:ntp
    ntpd    10810  ntp   17u  IPv6  35922       UDP *:ntp
    ntpd    10810  ntp   18u  IPv6  35923       UDP [fe80::225:64ff:fe9a:d7e0]:ntp
    ntpd    10810  ntp   19u  IPv6  35924       UDP localhost6.localdomain6:ntp
    ntpd    10810  ntp   20u  IPv4  35925       UDP localhost.localdomain:ntp
    ntpd    10810  ntp   21u  IPv4  35926       UDP nis.example.com:ntp
    ntpd    10810  ntp   22u  IPv4  35927       UDP 172.16.0.5:ntp
    ntpd    10810  ntp   23u  IPv4  35928       UDP 192.168.5.5:ntp
    					
  3. status

    ntpstat

    [root@subversion ~]# ntpstat
    synchronised to local net at stratum 11
       time correct to within 11 ms
       polling server every 1024 s
    					
    [root@subversion ~]# ntptrace -n 127.0.0.1
    127.0.0.1: stratum 11, offset 0.000000, synch distance 0.010984
    					
    [root@subversion ~]# ntpq -p
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
     122.226.192.4   .INIT.          16 u    - 1024    0    0.000    0.000   0.000
     218.75.4.130    .INIT.          16 u    - 1024    0    0.000    0.000   0.000
     www.chinaepg.ne .INIT.          16 u    - 1024    0    0.000    0.000   0.000
    *LOCAL(0)        .LOCL.          10 l   60   64  377    0.000    0.000   0.001
    					
  4. http://www.pool.ntp.org/

    vim /etc/ntp.conf
    server 2.cn.pool.ntp.org
    server 3.asia.pool.ntp.org
    server 2.asia.pool.ntp.org
    					
  5. # chkconfig ntpd on
    # service ntpd start/stop/restart
    					

32.1.2. Ubuntu

ubuntu

sudo apt-get install openntpd
			

32.1.3. ntpdate