Linux时间服务器的配置

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.253192.168.10.253202.178.126.253(时间服务器的IP,根据网段选择)

查看时间

>date

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值