免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5886 | 回复: 1

局域网内使用ntp服务器同步时间 [复制链接]

论坛徽章:
0
发表于 2008-10-17 13:48 |显示全部楼层
局域网内使用ntp服务器同步时间

solaris 10中已自带ntp服务的软件 可使用:pkginfo | grep ntp 查看
# pkginfo | grep ntp
system      SUNWntpr                         NTP, (Root)
system      SUNWntpu                         NTP, (Usr)
一、配置服务器端
1、编辑/etc/inet/ntp.conf文件
在/etc/inet目录下存在2个ntp模板文件 ntp.client ntp.server 。将ntp.server 复制为ntp.conf
  # cp ntp.server   ntp.conf
  #  vi ntp.conf

内容如下
# restrict default nomodify notrap
restrict 127.0.0.1
server 127.127.1.0  prefer
fudge 127.127.1.0 stratum 4

broadcast 192.168.0.255 ttl 4
#enable auth monitor
driftfile /var/ntp/ntp.drift
statsdir /var/ntp/ntpstats/
filegen peerstats file peerstats type day enable
filegen loopstats file loopstats type day enable
filegen clockstats file clockstats type day enable

#keys /etc/inet/ntp.keys
#trustedkey 0
#requestkey 0
#controlkey 0

restrict default nomodify notrap 表示不允许其他的计算机修改或查询本机的ntp服务,default表示所有ip.
restrict 127.0.0.1设置开放本机环路,对本地ntp服务进行监控及配置。
server 127.127.1.0  prefer设置使用本机系统时间作为时间源,prefer表示优先使用。
fudge 127.127.1.0 stratum 4设置本地时间源的层数为4,最大为15层,16表示不可访问。
broadcast 192.168.0.255 ttl 4设置本机的ntp服务器可以进行多播,若将ip换为224.0.1.1即设为可以进行多播。
driftfile /var/ntp/ntp.drift设置时间偏移量文件,该文件需要手工建立。
#keys /etc/inet/ntp.keys 设置认证文件,在局域网内不需认证注释掉即可。
实际上在配置ntp服务时 只需设置server 127.127.1.0  prefer  driftfile /var/ntp/ntp.drift即可
2、开启或重启ntp服务
# svcadm enable/restart ntp
3、查询ntp服务状态
#ntpq -p 或 # ntpq  ->  ntpr>peer
    remote           refid      st t when poll reach   delay   offset    disp
==============================================================================
*LOCAL(0)        LOCAL(0)         4 l   32   64  377     0.00    0.000   10.01
remote:上层服务器的ip或domainname,*表示上层ntp服务器是本机ntp的时间源
refid:表示上层ntp服务器的时间源
st:ntp服务器的层数
delay:表示与该上层ntp服务器联系所花的时间,单位毫秒
offset:本机ntp服务与上层ntp服务的时间偏移量
二、配置客户端
1、手动与ntp服务器同步时间
# ntpdate 10.10.0.60
出现如下结果:
17 Oct 13:38:28 ntpdate[3830]: adjust time server 10.10.0.60 offset -0.120840 sec
(使用这种方法客户端不需要开ntp服务,否则会包端口冲突的错)
2、编辑crontab文件,让客户端在固定时间与服务器同步时间。
# EDITOR=vi
# export EDITOR
#  crontab -e root

00 * * * * /usr/sbin/ntpdate 10.10.0.60


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/77786/showart_1319092.html

论坛徽章:
0
发表于 2009-10-05 10:54 |显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP