NTP

NTP: The Network Time Protocol

1,项目介绍:
CPU: 64位ARMv8处理器
RAM: 1GB DDR3
FLASH: 32MB NOR FLASH
IO: PCIE, SPI, I2C, UART, JTAG, SD等
U-Boot: u-boot-2016.09
Linux Kernel: linux-4.1
FS: busybox-1.27.1

2,NTP Server搭建
由于busybox已经保护了ntpd命令,不需要再下载NTP包了,只需要搭建NTP server即可测试。
环境: Ubuntu
安装过程:
1).sudo apt-get install ntp
2).sudo vim /etc/ntp.conf
# Specify one or more NTP servers,因为是内网,所以用本地时间做为服务器时间,注意这里不是127.0.0.1
server 127.127.1.0
#注释掉了这些东西
#pool 0.ubuntu.pool.ntp.org iburst
#pool 1.ubuntu.pool.ntp.org iburst
#pool 2.ubuntu.pool.ntp.org iburst
#pool 3.ubuntu.pool.ntp.org iburst
# Use Ubuntu’s ntp server as a fallback.
#pool 127.127.1.0
#增加了NTP服务器自身到时间服务器的同步
fudge 127.127.1.0 stratum 8
#增加了一些需要同步的客户端的ip
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited
restrict 135.242.15.151
3).sudo service ntp restart / sudo /etc/init.d/ntp restart
4).sudo service ntp status
3,测试
# ntpd -p 135.251.100.227 -qNn
ntpd: reply from 135.251.100.227: peer is unsynced
Alarm clock
在ntp server上重新启动ntp服务后,ntp server自身或者与其server的同步的需要一个时间段,这个过程可能是5分钟,在这个时间之内在客户端运行ntpdate命令时会产生no server suitable for synchronization found的错误。(在busybox命令ntpd -p 135.251.100.227上的错误如上所示)
那么如何知道何时ntp server完成了和自身同步的过程呢?
在ntp server上使用命令:ntpq -pn
同步完成以后,可以在ntp client上用ntpd同步时间了,如下:
# date
Thu Jan 1 00:06:57 UTC 1970
# date -R
Thu, 01 Jan 1970 00:07:00 +0000
# ntpd -p 135.251.100.227 -qNn
ntpd: setting time to 2018-08-31 06:02:11.822944 (offset +1535691187.187479s)
# date
Fri Aug 31 06:02:14 UTC 2018
# date -R
Fri, 31 Aug 2018 06:06:33 +0000

【1】http://www.ntp.org/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值