Home | 簡體中文 | 繁體中文 | 雜文 | 知乎專欄 | Github | OSChina 博客 | 雲社區 | 雲棲社區 | Facebook | Linkedin | 視頻教程 | 打賞(Donations) | About
知乎專欄多維度架構 微信號 netkiller-ebook | QQ群:128659835 請註明“讀者”

第 31 章 OpenNTPD

Synchronizes system time using the Network Time Protocol (NTP)

目錄

31.1. install
31.1.1. ntpd - Network Time Protocol (NTP) daemon
31.1.2. Ubuntu
31.1.3. ntpdate
31.2. ntpdate
31.2.1. CentOS 7
31.2.2. CentOS 6
31.3. ntpd.conf / ntp.conf
31.3.1. server 配置
31.3.2. ntp 安全設置
31.4. ntpstat - show network time synchronisation status
31.5. ntpq - standard NTP query program

http://www.ntp.org

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

31.1. install

31.1.1. ntpd - Network Time Protocol (NTP) daemon

過程 31.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
    					

31.1.2. Ubuntu

ubuntu

sudo apt-get install openntpd
			

31.1.3. ntpdate