1.服务器
vi /etc/ntp.conf
restrict default nomodify notrap noquery(默认不允许修改或者查询ntp,并且不接收特殊封包)
restrict 127.0.0.1 (给予权限允许本机修改ntp)
restrict 192.168.10.0 mask 255.255.255.0 nomodify notrap
restrict 10.132.224.0 mask 255.255.255.0 nomodify notrap
(允许子网同步,但不允许修改)
server time.nuri.net prefer (设置时间服务器,加prefer表示优先)
server time.nist.gov
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
server 127.127.1.0 (开放本机查询)
fudge 127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
broadcastdelay 0.008 (广播延迟时间)
keys /etc/ntp/keys
restrict time.nuri.net mask 255.255.255.255 nomodify notrap noquery
restrict time.nist.gov mask 255.255.255.255 nomodify notrap noquery
restrict 0.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict 1.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict 2.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
(同步上级时间源服务器,但不允许它们修改或者查询ntp)
2.客户端
linux
方法一:任务计划
crontab -e
*/5 * * * * ntpdate serverip
(可写入bios: hwclock -w)
方法二:编辑ntp.conf
restrict default nomodify notrap noquery
restrict 127.0.0.1
driftfile /var/lib/ntp/drift
broadcastdelay 0.008
keys /etc/ntp/keys
restrict 所在网段 mask 255.255.255.0 nomodify
server 服务器ip
restrict 服务器ip mask 255.255.255.255 nomodify notrap noquery
windows 2003
方法一:利用操作系统提供的校时服务:
1、通过注册表进行修改键值(修改更新的时间间隔,默认为7天):
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/W32Time/
TimeProviders/NtpClient/SpecialPollInterval
可以采用十进制方式编辑,默认值为:604800
2、 双击任务栏右下角“时间”,打开 [ 时间和日期 属性 ] 设置对话框,
打开 [ 时间和日期 属性 ] 设置对话框
3、选择 [ Internet时间 ] 标签, 选中 [ 自动与Internet时间服务器同
步 ] 选项,在 [ 服务器 ] 中填入时间服务器的ip地址或者域名。点击
[ 应用 ] 并按 [ 立即更新 ] 可直接同步。。
方法二:使用工具软件Automachron实现时间同步
1. 下载achron5.exe
2. 安装软件;
3. 运行:程序-->Automachron-->Automachron;
4. 右键单击任务栏右下脚选取Automachron图标-->Properties-->Host-->Ne
twork Host;
填入时间服务器的ip地址或者域名,Sync at startup前复选框打勾,Run
at startup前复选框打勾,
系统每次启动后均会自动同步时间,如需手动同步,点击Sync按钮即可 。
Linux下手动同步时间
>ntpdate 10.132.224.253或192.168.10.253或202.178.126.253(时间服务器的IP,根据网段选择)
查看时间
>date
本文详细介绍如何在Linux环境下配置NTP服务器与客户端,包括设置时间服务器、限制访问权限及客户端同步方法等,并提供Windows环境下时间同步的两种方案。

2661

被折叠的 条评论
为什么被折叠?



