ubuntu 下 ntp测试

来源:互联网 发布:四大名著 知乎 编辑:程序博客网 时间:2024/06/07 11:11

环境:

PC1 : ubuntu 12.04 (client)

PC2: ubuntu 16.04 (server)


NTP 服务器 客户端 配置简单同步:


1、安装

 # apt-get install ntp

2、配置

# cp /etc/ntp.config   /etc/ntp.config_bak

# vi /etc/ntp.config

修改内容:

*******************

restrict  default nomodify  //允许任何客户端同步

以下是ntp 和自身同步,如果无法连接外网

server 127.127.1.0

fudge 127.127.1.0  stratum 8

**************************

3、服务端

修改完成后,执行

#  /etc/init.d/ntp restart

# watch  ntpq  -p   //查看同步状态

4、客户端

执行: # ntpdate -d server_ip 

如果没有错误,去掉 -d 再执行,即可同步。

5、错误解决

ntp的错误 no server suitable for synchronization found

错误的原因有以下2个:

(1).Server dropped: Strata too high(报错)

在ntp客户端运行ntpdate serverIP,呈现no server suitable for synchronization found的错误。

在ntp客户端用ntpdate –d serverIP查看,发明有“Server dropped: strata too high”的错误,并且显示“stratum 16”。

而正常景象下stratum这个值得局限是“0~15”。

这是因为NTP server还没有和其自身或者它的server同步上。


在ntp server上从头启动ntp服务后,ntp server自身或者与其server的同步的须要一个时候段,这个过程可能是5分钟,在这个时候之内涵客户端运行ntpdate号令时会产生no server suitable for synchronization found的错误。


在ntp server上应用命令:

# watch ntpq -p

可知道何时ntp server完成了和自身同步的过程

(2)、Server dropped: no data (报错)

呈现这个题目的原因可能有2:

a) 搜检ntp的版本,若是你应用的是ntp4.2(包含4.2)之后的版本,在restrict的定义中应用了notrust的话,会导致以上错误。

b) 搜检ntp server的防火墙。可能是server的防火墙樊篱了upd 123端口。

          #service iptables stop
           来关掉iptables办过后再测验测验从ntp客户端的同步,若是成功,证实是防火墙的题目,须要更改iptables的设置。

6、服务器地址

210.72.145.44 (国家授时中心服务器IP地址) 

133.100.11.8 日本 福冈大学 

time-a.nist.gov 129.6.15.28 NIST, Gaithersburg, Maryland 

time-b.nist.gov 129.6.15.29 NIST, Gaithersburg, Maryland 

time-a.timefreq.bldrdoc.gov 132.163.4.101 NIST, Boulder, Colorado 

time-b.timefreq.bldrdoc.gov 132.163.4.102 NIST, Boulder, Colorado 

time-c.timefreq.bldrdoc.gov 132.163.4.103 NIST, Boulder, Colorado 

utcnist.colorado.edu 128.138.140.44 University of Colorado, Boulder 

time.nist.gov 192.43.244.18 NCAR, Boulder, Colorado 

time-nw.nist.gov 131.107.1.10 Microsoft, Redmond, Washington 

nist1.symmetricom.com 69.25.96.13 Symmetricom, San Jose, California 

nist1-dc.glassey.com 216.200.93.8 Abovenet, Virginia 

nist1-ny.glassey.com 208.184.49.9 Abovenet, New York City 

nist1-sj.glassey.com 207.126.98.204 Abovenet, San Jose, California 

nist1.aol-ca.truetime.com 207.200.81.113 TrueTime, AOL facility, Sunnyvale, California 

nist1.aol-va.truetime.com 64.236.96.53 TrueTime, AOL facility, Virginia 

———————————————————————————————————— 

ntp.sjtu.edu.cn 202.120.2.101 (上海交通大学网络中心NTP服务器地址) 

s1a.time.edu.cn 北京邮电大学 

s1b.time.edu.cn 清华大学 

s1c.time.edu.cn 北京大学 

s1d.time.edu.cn 东南大学 

s1e.time.edu.cn 清华大学 

s2a.time.edu.cn 清华大学 

s2b.time.edu.cn 清华大学 

s2c.time.edu.cn 北京邮电大学 

s2d.time.edu.cn 西南地区网络中心 

s2e.time.edu.cn 西北地区网络中心 

s2f.time.edu.cn 东北地区网络中心 

s2g.time.edu.cn 华东南地区网络中心 

s2h.time.edu.cn 四川大学网络管理中心 

s2j.time.edu.cn 大连理工大学网络中心 

s2k.time.edu.cn CERNET桂林主节点 

s2m.time.edu.cn 北京大学