2023年11月27日发(作者:)
用组策略配置Windows时间客户端
用组策略配置Windows时间客户端
2009-12-15 23:09
经常我们会发现自己的计算机时间不准确,即使校对之后,不长时间发现时间又
不准确了。通常这跟主板上的芯片质量有关系,因为每台计算机的时钟发生器 的
精度不同。对于一般人来说,如果时间差异不大,都可以接受,但是对于许多时
间相关的系统来说,例如银行、电信等,这就非常重要的,这些系统至少需要保
证 同一套系统中所有服务器的时间相一致。解决方法是使用软件自动对时,时
间协议就是用于这个目的。可以在局域网中配置一个时间服务器,然后所有客户
端与之同 步时间。因特网上也有许多免费的时间服务器。
现在的操作系统大部分都自带时间服务器或客户端软件,只需要稍微配置一下,
就可以与时间服务器同步,从而保证自己的时间与服务器相一致。 Windows也
不例外,自Windows 2000开始,就可以很方便地配置时间客户端或时间服务。
下面以Windows 2003为例,使用组策略的方法来配置时间客户端。
首先选择“开始”-“运行”,并输入:
打开组策略编辑器,并选择“计算机配置”-“管理模板”-“系统”-
“Windows时间服务”-“时间提供程序”:
在右边栏中选择“启用Windows NTP客户端”,并在“启用Windows NTP客户端”
对话框中选择“已启用”:
点击“下一设置”,并在“配置Windows NTP客户端”对话框中配置相应信息(例
如将NtpServer设置为, 0x1,选择Type为NTP):
点击“下一设置”,并在对话框中选择“已禁用”:
点击“确定”,完成配置。之后系统将每小时(3600秒)与时间服
务器同步一次,这可以通过打开“日期和时间 属性”对话框来确
认:
关于如何配置时间服务器的方法,请参考此文档。
目录
使用Windows操作系统的客户端如何设置NTP网络服务器... 1
1 Windows 2000. 1
1.1 命令介绍... 1
1.1.1 NET TIME. 1
1.1.2 W32time. 1
1.1.3 设置示例... 2
1.1.4 可能出现的问题... 2
2 Windows XP. 2
2.1 命令介绍... 2
2.1.1 NET TIME. 2
2.1.2 W32time. 3
2.1.3 设置示例... 3
2.1.4 可能出现的问题... 3
3 Windows Server 2003. 3
3.1 命令介绍... 3
3.1.1 NET TIME. 3
3.1.2 W32time. 4
3.1.3 设置示例... 4
3.1.4 可能出现的问题... 4
1 Windows 2000
1.1 命令介绍
Windows 2000下有关时间的命令有两个,net time和W32tm,下面对这两个命令的
语法和参数加以说明。
1.1.1 NET TIME
net time命令使计算机的时钟与另一个计算机或域的时钟同步。如果在没有 /set 选项的
情况下使用,则显示另一个计算机或域的时间。net time的语法为:
net time [computername | /domain[:domainname] | /rtsdomain[:domainname]] [/set]
net time [computername] [/querysntp] | [/setsntp[:ntp server list]]
参数说明:
l 无参数,显示被指派为本地计算机的Windows服务器域时间服务器的当前时间。
l computername,指定要检查或与之同步的服务器的名称。
l /domain[:domainname],指定要同步时间的域。
l /rtsdomain[:domainname],指定要与之同步的可信时间服务器所在的域。
l /set,使计算机的时钟与指定的计算机或域的时间同步。
l /querysntp,显示当前为本地计算机或 computername 所指定的计算机配置网络时
间协议(NTP)服务器的名称。
l /setsntp[:ntp server list],指定本地计算机所使用的NTP时间服务器的列表。该列表
可以包含IP地址或DNS名称,用空格分开。如果要使用多个时间服务器,该列表必须用
引号引起来。例如net time /setsntp:",0x1 time-,0x1”,其
中的0x1是在使用完整域名称作为NTP服务器的时候需要的,如果使用IP地址则可以忽
略。
1.1.2 W32time
W32tm是用来同步本地计算机与远程计算机或域时间的类似命令。在域控制器上使用W3
2tm前必须停止W32Time,完成后再启动W32Time。W32tm的语法为:
w32tm [ -tz | -s [computer] | -adj | -adjoff | -source | -once ]
[-test] [-v] [-p ] [-period ]
关于W32tm语法的详细说明,可以在命令提示符下键入W32tm /?,将列出语法和所有
参数的说明。
1.2 注册表项
以下注册表项位于 HKLMSYSTEMCurrentControlSetServicesW32Time
1.2.1 ParametersPeriod
HKLMSYSTEMCurrentControlSetServicesW32TimeParametersPeriod 注册
表项控制着 Windows 时间服务同步的频率。为它指定的值只能是以下列表中的某个特殊
值:
l 65531, "DailySpecialSkew" - 设置为每隔 45 分钟同步一次,直到有一次成功,然
后每天同步一次。
l 65532, "SpecialSkew" - 设置为每隔 45 分钟同步一次,直到有三次成功,然后每隔
八小时同步一次。这是默认设置。
l 65533, "Weekly" - 设置为每隔七天同步一次。
l 65534, "Tridaily" - 设置为每隔三天同步一次。
l 65535, "BiDaily" - 设置为每隔两天同步一次。
l 0 - 对于 NT5DS,则每隔 45 分钟同步一次,直到有三次成功,然后每隔八小时同步
一次。对于 NTP,则每隔 8 小时同步一次。
l freq - freq 代表您希望 Windows 时间服务每天同步的次数。如果您不想使用那些事
先指定好的值,则必须使用此选项。
1.3 设置示例
设置 Windows Time 服务:在“控制面板”中打开“管理工具”,再打开“服务”;在服务中
找到“Windows Time”,双击服务名称,在打开的“Windows Time的属性”中设置“启动
类型”为“自动”,再按下启动按钮。
在“运行(R)”中用“cmd”命令进入在DOS命令行窗体;执行以下命令(注意空格):
net time /setsntp:192.168.1.232
net stop w32time
net start w32time
w32tm –s
(设置时间服务器地址)
(停止时间服务)
(启动时间服务)
(立即同步时间)
1.4 可能出现的问题
计算机没有同步。因为没有可用的时间数据。(The computer did not resync becau
se no time data was available)
出现该问题的原因可能是windows time service没有正确的启动,或者与组策略中的时
间配置冲突。请在组策略()中将配置更改为“未配置”。
2 Windows XP
2.1 命令介绍
Windows XP下有关时间的命令有两个,net time和W32tm,下面对这两个命令的语法
和参数加以说明。
2.1.1 NET TIME
net time命令使计算机的时钟与另一个计算机或域的时钟同步。如果在没有 /set 选项的
情况下使用,则显示另一个计算机或域的时间。net time的语法为:
net time [computername | /domain[:domainname] | /rtsdomain[:domainname]] [/set]
net time [computername] [/querysntp] | [/setsntp[:ntp server list]]
参数说明:
l 无参数,显示被指派为本地计算机的Windows服务器域时间服务器的当前时间。
l computername,指定要检查或与之同步的服务器的名称。
l /domain[:domainname],指定要同步时间的域。
l /rtsdomain[:domainname],指定要与之同步的可信时间服务器所在的域。
l /set,使计算机的时钟与指定的计算机或域的时间同步。
l /querysntp,显示当前为本地计算机或 computername 所指定的计算机配置网络时
间协议(NTP)服务器的名称。
l /setsntp[:ntp server list],指定本地计算机所使用的NTP时间服务器的列表。该列表
可以包含IP地址或DNS名称,用空格分开。如果要使用多个时间服务器,该列表必须用
引号引起来。例如net time /setsntp:",0x1 time-,0x1”,其
中的0x1是在使用完整域名称作为NTP服务器的时候需要的,如果使用IP地址则可以忽
略。
2.1.2 W32time
W32tm是用来同步本地计算机与远程计算机或域时间的类似命令。在域控制器上使用W3
2tm前必须停止W32Time,完成后再启动W32Time。W32tm的语法为:w32
w32tm [/? | /register | /unregister ]
w32tm /monitor [/domain:
[/computers:
[/threads:
w32tm /ntte
w32tm /ntpte
w32tm /resync [/computer:
w32tm /stripchart /computer:
[/dataonly] [/samples:
w32tm /config [/computer:
[/manualpeerlist:
[/LocalClockDispersion:
w32tm /tz
w32tm /dumpreg [/subkey:
关于W32tm语法的详细说明,可以在命令提示符下键入W32tm /?,将列出语法和所有
参数的说明。
2.2 注册表项
以下注册表项位于 HKLMSYSTEMCurrentControlSetServicesW32Time
注册表项
路径
注意
MaxPosPhaseCorrection
HKLMSYSTEMCurrentControlSetServicesW32TimeConfig
该 项指定服务可进行的最大正时间校准量(以秒为单位)。如果服务确定某个更改幅度大于
所需的幅度,它将记录一个事件。特殊情况:0xFFFFFFFF 表示总是校准时间。域成员的默
认值是 0xFFFFFFFF。独立客户端和服务器的默认值是 54,000(15 小时)。
注册表项
路径
MaxNegPhaseCorrection
HKLMSYSTEMCurrentControlSetServicesW32TimeConfig
该项指定服务可进行的最大负时间校准量(以秒为单位)。如果服务确定某个更改幅度大于
注意 所需的幅度,它将转而记录一个事件。特殊情况:-1 表示总是校准时间。域成员的默认值
是 0xFFFFFFFF。独立客户端和服务器的默认值是 54,000(15 小时)。
注册表项
路径
MaxPollInterval
HKLMSYSTEMCurrentControlSetServicesW32TimeConfig
该项指定系统轮询间隔所允许的最大间隔(单位是对数表示的秒)。请注意,尽管系统必须
注意 根据预定的间隔进行轮询,但是提供程序可以根据请求拒绝生成示例。域成员的默认值是
10。独立客户端和服务器的默认值是 15。
注册表项
路径
SpecialPollInterval
HKLMSYSTEMCurrentControlSetServicesW32TimeTimeProvidersNtpClient
该项指定手动对等端的特殊轮询间隔(以秒为单位)。当启用 SpecialInterval 0x1 标志
注意 时,W32Time 将使用此轮询间隔而非操作系统确定的轮询间隔。域成员的默认值是
3,600。独立客户端和服务器的默认值是 604,800。
注册表项
路径
MaxAllowedPhaseOffset
HKLMSYSTEMCurrentControlSetServicesW32TimeConfig
该项指定 W32Time 尝试使用时钟速率调整计算机时钟的最大偏移(以秒为单位)。当偏
注意 移大于该速率时,W32Time 将直接设置计算机时钟。域成员的默认值是 300。独立客户
端和服务器的默认值是 1。
2.2.1 ParametersNtpServer
HKLMSYSTEMCurrentControlSetServicesW32TimeParametersNtpServer
Data type Range Default value
REG_SZ DNS name or IP address[,0x1 | 0x2 | 0x3] t,0x1
Description
Stores a list of time sources that this computer uses to synchronize its tim
e. The time sources appear either as a DNS name or an IP address of the
time source server. The list is space-delimited, with one address per line.
Each time source may also be followed by a comma and a DWORD contai
ning flags for special handling of that time source. If the flags are not spe
cified, they default to 0x0. The available flags are:
Value Meaning
Instead of following the NTP specification, wait for the interval specified in the
0x1
SpecialPollInterval entry before attempting to recontact this time source. Setting this
flag decreases network usage, but it also decreases accuracy.
0x2
Use this time source only as a fallback. If all time sources that are not fallbacks have
failed, then the system selects one fallback time source at random and uses it.
Set the local computer to operate in symmetric active mode in the association with this
source.
Set the local computer to operate in client mode in the association with this source. 0x8
0x4
例如net time /setsntp:",0x1 time-,0x1”,其中的0x1是
在使用完整域名称作为NTP服务器的时候需要的,如果使用IP地址则可以忽略。
Change Method
You can change the value of this entry by using the /setsntp parameter of
the net time command at the command line. For more information about
net time, see Help and Support Center for Windows XP.
2.2.1 ParametersType
HKLMSYSTEMCurrentControlSetServicesW32TimeParameters
Data type Range Default value
REG_SZ
NoSync | NTP | Nt5DS | Nt5DS for computers joined to a domain; NTP for
AllSync others
Description
Specifies the type of time sources, if any, to which the computer synchron
izes its time.
Value Meaning
NoSync Does not synchronize time.
NTP Synchronizes time to the time sources specified in the ParametersNtpServer entry.
Nt5DS Synchronizes time to the domain hierarchy.
AllSync Uses all synchronization mechanisms available.
Change Method
To change the value of this entry, use the command-line tool
(specifically, the command w32tm /config /syncfromflags). For more inform
ation about , see Windows Server 2003 Help and Support Cente
r.
Activation Method
To make changes to this entry effective, at the command line, type:
w32tm /config /update
2.3 设置示例
2.3.1 使用“时间和日期 属性”设置对话框
双击任务栏右下角“时间”,打开“时间和日期 属性”设置对话框;
选择“Internet时间”标签;
选中“自动与Internet时间服务器同步”选项,在“服务器”中填入网络时间服务器的IP地址,
如“192.168.1.232”(只能输入1个服务器地址)。按“立即更新”可直接同步。
2.3.2 命令方式
在“运行(R)”中用“cmd”命令进入在DOS命令行窗体;执行以下命令(注意空格):
net time /setsntp: ”192.168.1.232
,0x1”
net stop w32time
net start w32time
w32tm /resync /nowait /rediscover
(设置时间服务器地址,可多个)
(停止时间服务)
(启动时间服务)
(立即同步时间)
2.4 可能出现的问题
计算机没有同步。因为没有可用的时间数据。(The computer did not resync becau
se no time data was available)
出现该问题的原因可能是windows time service没有正确的启动,或者与组策略中的时
间配置冲突。请在组策略()中将配置更改为“未配置”。
3 Windows Server 2003
3.1 命令介绍
Windows Server 2003下有关时间的命令有两个,net time和W32tm,下面对这两
个命令的语法和参数加以说明。
3.1.1 NET TIME
net time命令使计算机的时钟与另一个计算机或域的时钟同步。如果在没有 /set 选项的
情况下使用,则显示另一个计算机或域的时间。net time的语法为:
net time [computername | /domain[:domainname] | /rtsdomain[:domainname]] [/set]
net time [computername] [/querysntp] | [/setsntp[:ntp server list]]
参数说明:
l 无参数,显示被指派为本地计算机的Windows服务器域时间服务器的当前时间。
l computername,指定要检查或与之同步的服务器的名称。
l /domain[:domainname],指定要同步时间的域。
l /rtsdomain[:domainname],指定要与之同步的可信时间服务器所在的域。
l /set,使计算机的时钟与指定的计算机或域的时间同步。
l /querysntp,显示当前为本地计算机或 computername 所指定的计算机配置网络时
间协议(NTP)服务器的名称。
l /setsntp[:ntp server list],指定本地计算机所使用的NTP时间服务器的列表。该列表
可以包含IP地址或DNS名称,用空格分开。如果要使用多个时间服务器,该列表必须用
引号引起来。参见注册表项中NtpServer项说明。
3.1.2 W32time
W32tm是用来同步本地计算机与远程计算机或域时间的类似命令。在域控制器上使用W3
2tm前必须停止W32Time,完成后再启动W32Time。W32tm的语法为:
w32tm [/? | /register | /unregister ]
w32tm /monitor [/domain:
[/computers:
[/threads:
w32tm /ntte
w32tm /ntpte
w32tm /resync [/computer:
w32tm /stripchart /computer:
[/dataonly] [/samples:
w32tm /config [/computer:
[/manualpeerlist:
[/LocalClockDispersion:
w32tm /tz
w32tm /dumpreg [/subkey:
关于W32tm语法的详细说明,可以在命令提示符下键入W32tm /?,将列出语法和所有
参数的说明。
3.2 注册表项
以下注册表项位于 HKLMSYSTEMCurrentControlSetServicesW32Time
注册表项
路径
MaxPosPhaseCorrection
HKLMSYSTEMCurrentControlSetServicesW32TimeConfig
该 项指定服务可进行的最大正时间校准量(以秒为单位)。如果服务确定某个更改幅度大于
注意 所需的幅度,它将记录一个事件。特殊情况:0xFFFFFFFF 表示总是校准时间。域成员的默
认值是 0xFFFFFFFF。独立客户端和服务器的默认值是 54,000(15 小时)。
注册表项
路径
MaxNegPhaseCorrection
HKLMSYSTEMCurrentControlSetServicesW32TimeConfig
该项指定服务可进行的最大负时间校准量(以秒为单位)。如果服务确定某个更改幅度大于
注意 所需的幅度,它将转而记录一个事件。特殊情况:-1 表示总是校准时间。域成员的默认值
是 0xFFFFFFFF。独立客户端和服务器的默认值是 54,000(15 小时)。
注册表项
路径
MaxPollInterval
HKLMSYSTEMCurrentControlSetServicesW32TimeConfig
该项指定系统轮询间隔所允许的最大间隔(单位是对数表示的秒)。请注意,尽管系统必须
注意 根据预定的间隔进行轮询,但是提供程序可以根据请求拒绝生成示例。域成员的默认值是
10。独立客户端和服务器的默认值是 15。
注册表项
路径
SpecialPollInterval
HKLMSYSTEMCurrentControlSetServicesW32TimeTimeProvidersNtpClient
该项指定手动对等端的特殊轮询间隔(以秒为单位)。当启用 SpecialInterval 0x1 标志
注意 时,W32Time 将使用此轮询间隔而非操作系统确定的轮询间隔。域成员的默认值是
3,600。独立客户端和服务器的默认值是 604,800。
注册表项
路径
MaxAllowedPhaseOffset
HKLMSYSTEMCurrentControlSetServicesW32TimeConfig
该项指定 W32Time 尝试使用时钟速率调整计算机时钟的最大偏移(以秒为单位)。当偏
注意 移大于该速率时,W32Time 将直接设置计算机时钟。域成员的默认值是 300。独立客户
端和服务器的默认值是 1。
3.2.1 ParametersNtpServer
HKLMSYSTEMCurrentControlSetServicesW32TimeParametersNtpServer
Data type Range Default value
REG_SZ DNS name or IP address[,0x1 | 0x2 | 0x3] t,0x1
Description
Stores a list of time sources that this computer uses to synchronize its tim
e. The time sources appear either as a DNS name or an IP address of the
time source server. The list is space-delimited, with one address per line.
Each time source may also be followed by a comma and a DWORD contai
ning flags for special handling of that time source. If the flags are not spe
cified, they default to 0x0. The available flags are:
Value Meaning
Instead of following the NTP specification, wait for the interval specified in the
0x1
SpecialPollInterval entry before attempting to recontact this time source. Setting this
flag decreases network usage, but it also decreases accuracy.
0x2
Use this time source only as a fallback. If all time sources that are not fallbacks have
failed, then the system selects one fallback time source at random and uses it.
Set the local computer to operate in symmetric active mode in the association with this
source.
Set the local computer to operate in client mode in the association with this source. 0x8
0x4
例如net time /setsntp:",0x1 time-a.n,0x1”,其中的0x1是
在使用完整域名称作为NTP服务器的时候需要的,如果使用IP地址则可以忽略。
Change Method
You can change the value of this entry by using the /setsntp parameter of
the net time command at the command line. For more information about
net time, see Help and Support Center for Windows Server 2003.
3.2.2 ParametersType
HKLMSYSTEMCurrentControlSetServicesW32TimeParameters
Data type Range Default value
REG_SZ
NoSync | NTP | Nt5DS | Nt5DS for computers joined to a domain; NTP for
AllSync others
Description
Specifies the type of time sources, if any, to which the computer synchron
izes its time.
Value Meaning
NoSync Does not synchronize time.
NTP Synchronizes time to the time sources specified in the ParametersNtpServer entry.
Nt5DS Synchronizes time to the domain hierarchy.
AllSync Uses all synchronization mechanisms available.
Change Method
To change the value of this entry, use the command-line tool
(specifically, the command w32tm /config /syncfromflags). For more inform
ation about , see Windows Server 2003 Help and Support Cente
r.
Activation Method
To make changes to this entry effective, at the command line, type:
w32tm /config /update
3.3 设置示例
3.3.1 使用“时间和日期 属性”设置对话框
双击任务栏右下角“时间”,打开“时间和日期 属性”设置对话框;
选择“Internet时间”标签;
选中“自动与Internet时间服务器同步”选项,在“服务器”中填入网络时间服务器的IP地址,
如“192.168.1.232”(只能输入1个服务器地址)。按“立即更新”可直接同步。
3.3.2 命令方式
在“运行(R)”中用“cmd”命令进入在DOS命令行窗体;执行以下命令(注意空格):
net time /setsntp: ”192.168.1.232
,0x1”
net stop w32time
net start w32time
w32tm /resync /nowait /rediscover
(设置时间服务器地址,可多个)
(停止时间服务)
(启动时间服务)
(立即同步时间)
3.4 可能出现的问题
计算机没有同步。因为没有可用的时间数据。(The computer did not resync becau
se no time data was available)
出现该问题的原因可能是windows time service没有正确的启动,或者与组策略中的时
间配置冲突。请在组策略()中将配置更改为“未配置”。
4 参考
有关 Windows 时间服务的更多信息,请单击下面的文章编号,以查看 Microsoft 知识库
中相应的文章:
216734 如何在 Windows 2000 中配置权威时间服务器
321708 如何在 Windows 2000 中使用网络诊断工具 ()
314054 如何在 Windows XP 中配置权威时间服务器
816042 如何在 Windows Server 2003 中配置权威时间服务器
816043 如何打开 Windows 时间服务中的调试日志
884776 配置 Windows 时间服务以防出现大的时间偏移
发布评论