NTP服务器搭建与测试

本文介绍了如何在服务器上搭建NTP服务,包括安装ntp、修改配置文件及重启服务,并展示了如何在客户端配置时间同步及验证同步状态。同时提供了常用的时间服务器地址和参考资料。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

服务器
首先是安装:
sudo apt-get install ntp

修改配置文件(ntp仅有的配置文件):
sudo vi /etc/ntp.conf

# 如果进行局域网配置,可参考如下:
# Specify one or more NTP servers.
server 192.168.0.100  #这个是该ntp server 的上层server
# 配置可以访问该server的网段
restrict 192.168.5.0 mask 255.255.255.0 nomodify notrap 
# 如果可以联网,可配置公用的NTP server:
# Specify one or more NTP servers.
 server 0.cn.pool.ntp.org
 server 1.cn.pool.ntp.org
 server 2.cn.pool.ntp.org
 server 3.cn.pool.ntp.org

配置完成重启ntp 服务:
sudo /etc/init.d/ntp restart

查看ntp 运行状态
ntpq -p

remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*192.168.0.100   LOCAL(0)        11 u  209  256  377    0.131    0.793   0.226
 LOCAL(0)        .LOCL.          10 l 108m   64    0    0.000    0.000   0.000

客户端
客户端同样安装ntp 服务,进行配置:
sudo vi /etc/ntp.conf
只需增加 server 即可。

配置完成,手动进行时间同步:
ntpdate -u 192.168.0.x

查询命令:
ntpdc -n -c lispeers 192.168.0.x
ntpdc -n -c monlist 192.168.0.x

常用的时间服务器地址
http://www.pool.ntp.org/zone/cn
参考链接:
http://blog.csdn.net/wzy_1988/article/details/8629304
http://acooly.iteye.com/blog/1993484

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值