内网状况下配置NTP服务器

本文主要针对服务器在内网,没法与外界取得链接的场景配置NTP服务,须要有一台机器能与外网取得联系,其余服务与该外网服务链接html

NTP服务器【Network Time Protocol(NTP)】是用来使计算机时间同步化的一种协议,它能够使计算机对其服务器或时钟源(如石英钟,GPS等等)作同步化,它能够提供高精准度的时间校订(LAN上与标准间差小于1毫秒,WAN上几十毫秒),且可介由加密确认的方式来防止恶毒的协议攻击。时间按NTP服务器的等级传播。按照离外部UTC源的远近把全部服务器纳入不一样的Stratum(层)中。

clipboard.png

时钟服务器为树状结构,顶层是由国家(国际)受权时中心提供,逐层向下扩展

clipboard.png
(1)NTP软件包安装:yum install ntp
若是网络不通,须要经过代理或下载rpm文件包进行安装
(2)配置文件路径:/etc/ntp.conf
(3)内网服务设置
1.内网NTP服务centos

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

经过链接能够PING通的时钟服务获取时钟信息,查看是否能够连通服务器

service ntpd stop
 0.centos.pool.ntp.org
 service ntpd start

2.内网其余服务:
须要NTP服务容许指定网段访问网络

restrict 127.0.0.1 
restrict ::1
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

主要配置与NTP服务关联tcp

Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 192.168.1.93
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

(4)查看端口监听:netstat -anptu|grep 123,判断NTP服务是否启动ide

tcp        0      0 0.0.0.0:9123            0.0.0.0:*               LISTEN      16350/haproxy       
udp        0      0 192.168.1.93:123        0.0.0.0:*                           1359/ntpd           
udp        0      0 127.0.0.1:123           0.0.0.0:*                           1359/ntpd           
udp        0      0 0.0.0.0:123             0.0.0.0:*                           1359/ntpd           
udp6       0      0 fe80::f816:3eff:fee:123 :::*                                1359/ntpd           
udp6       0      0 ::1:123                 :::*                                1359/ntpd           
udp6       0      0 :::123                  :::*                                1359/ntpd

(5)启动:加密

service ntpd start(stop,restart同理)

(6)设置开机启动:spa

chkconfig ntpd on

(7)几分钟后指令ntpstat显示与NTP服务链接信息3d

clipboard.png

相关文章
相关标签/搜索