Windows Time and The W32TM Service
Windows Time and The W32TM Service
Windows Time and the W32TM service.............................................................................1 Contents...............................................................................................................................1 Introduction..........................................................................................................................2 Time Sync Principles...........................................................................................................3 Why time sync:................................................................................................................3 What is Network Time Protocol......................................................................................3 What are we configuring within Windows......................................................................3 Time Protocol Interoperability.........................................................................................4 Time Sync Hierarchy and Stratum:..................................................................................4 Reliable Time Source Configuration...............................................................................5 Windows 2000 Time Sync...................................................................................................6 Windows 2003 uses W32TM not NET TIME.....................................................................7 Locating Time Servers:........................................................................................................9 Best Practise:......................................................................................................................10 Preventing Large Time Changes....................................................................................10 Troubleshooting Time Sync...............................................................................................12 My Troubleshooting steps:............................................................................................12 Other useful w32tm commands:....................................................................................14 How to turn on debug logging:......................................................................................14 References..........................................................................................................................16
Introduction
In the last few days this issue of time sync in Windows domains has come up a few times both at work and on the Minasi forum of which I am a member (http://web2.minasi.com/forums). Each time there has been confusion as to exactly how time sync occurs in a Windows domain. Therefore, I decided that I would put this article together in order to try to provide a decent answer as to what is going on and how to troubleshoot any issues that arise. The first thing about Time Sync in Windows is to realise that it is a little different between Windows 2000 machines and Windows XP/2003 machines. This is because in Windows 2000 the Simple Network Time Protocol (SNTP) was used and was configured with the NET TIME command. Now, with XP and 2003, Network Time Protocol (NTP) is used which give benefits such as more reliable time due to better correction methods. This is configured using the new W32TM commands which we will look at later on. To start with, however, I will look at the principles that remain the same for both Windows 2000, 2003 and XP computers/domains.
NtpClient input provider. This is a time client that obtains time information from another source, either a hardware device or an NTP server, and can return time samples that are useful for synchronizing the local clock. The Windows Time service is implemented in a dynamic link library called W32Time.dll. W32Time.dll is installed by default in the Systemroot\System32 folder during Windows Server 2003 setup and installation.
You should also note that if the time is more than 3 minutes out then the w32time service will use a process of gradual adjustment to bring things into line rather than simply changing the clock immediately.
w32tm /configure /manualpeerlist:time.windows.com,0x1 /syncfromflags:manual /update Note: if using a DNS name for the time server then it is important to add the 0x1 to the end. If using and IP address this can be omitted. After making any changes to the w32time service configuration you should restart the W32TIME service. This can be done from a command prompt as follows: net stop w32time && net start w23time After issuing either of these commands, you should tell your system to update its time with the following command: w32tm /resync /rediscover So that gets you the basics setup for a Windows Server 2003 or Windows XP machines. To see a list of all the commands you can use with w32tm, type: W32tm /?
Another way to verify whether a machine is a time server is to use the w32tm /monitor command. This can be used as follows: W23tm /monitor /computers:uk.pool.ntp.org w32tm /monitor /computers:uk.pool.ntp.org uk.pool.ntp.org [82.71.9.63]: ICMP: error IP_REQ_TIMED_OUT - no response in 1000ms NTP: -4.9009063s offset from local clock RefID: utserv.mcc.ac.uk [130.88.200.6] You should get output similar to the above. In particular the NTP: line which shows that my clock is 4 seconds behind the online time server.
Best Practise:
Preventing Large Time Changes
As I have already stated, it is highly recommended to setup your root PDCe to sync with an external time source of some sort. However, having done this, you are then open to a possible problem caused by an error with the clock you sync to. If something were to go wrong and the time were to change dramatically on your external clock your root PDCe would by default follow this time change and apply it. This would then filter all through you domain which obviously would be a bad thing! To prevent this you should configure the MaxPosPhaseCorrection and MaxNegPhaseCorrection registry entries. From Microsoft sources on the Internet, it would appear that the recommended value is 900 seconds (15 mins). I would suggest that having a 15 minute time change occur on your network is likely unacceptable. I would therefore recommend setting this interval for 300 seconds so that the time change internally is never greater than 5 minutes. This should help to prevent problems if a large change was received which then prevented Kerberos authentication working as some
machines would have a time difference of greater than 5 minutes before full time sync could occur. If you are particularly worried about this type of problem then you could also set the values for your internal systems as well as for your root PDCe. For a little more info about these keys, including where to find them, look in the table below: Obviously the above also means that if your clock were to get a long way out then correction wouldnt be automatic. In this case you should monitor the time of your network fairly regularly and also set the value of the MaxPollInterval registry entry to 10 or less, or that you set value of the SpecialPollInterval registry entry to 3600 (1 hour) or less to enable frequent time checks. As with all these setting changes for more information have a browse of the Windows Time Service Technical Reference which can be found through the link below: http://technet2.microsoft.com/WindowsServer/en/library/b43a025f-cce2-4c82b3ea-3b95d482db3a1033.mspx?mfr=true
My Troubleshooting steps:
Here are the steps I take when troubleshooting Time Sync issues on a PDCe box. 1. First I will investigate the forest structure looking at how many domains and DCs exist. Then on one of the DCs I will install the Windows 2003 support tools and type netdom query fsmo 2. This will locate the holders of the FSMO roles and allow me to find the server holder the PDCe role. 3. I will then verify with replmon that good replication is occurring within the forest. 4. I will next use the NTPQuery utility mentioned above to verify that the time.windows.com time server can be accessed from the machine. This will verify that the relevant ports are open. Another way of doing this would be to use portqry as shown below which should return a Listening or Filtered output portqry n time.windows.com e 123 p UDP 5. Next I will open up regedit and locate the registry key below. Once there I will check that the desired time server is configured and that if a DNS name is used the ,0x1 suffix is used: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ W32Time\Parameters\NtpServer 6. I will next attempt to ping the server that is referred to. Although this is not always possible due to settings at either end, it does provide a clear indication that the server is available. Another way to get this verification would be to use the portqry command above.
7. Open Registry Editor (regedit.exe) and configure the following registry entries so that it is set to NTP not NT5DS: HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters\ Type 8. Whilst in the registry ensure that the registry key below has a value of 5. HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config\Ann ounceFlags 9. Now stop and restart the Windows Time service using the following command: net stop w32time && net start w32time 10. Next re-sync the w32time service using the following command: w32tm /resync /rediscover 11. Next check in the system event log to see if errors are still logged. If the above has fixed the problem then you should now receive an event ID of 35 logged by the w32time service. 12. If you still have errors then reboot the server. 13. Then in the registry point the time server to the same time source as above but use the 0x8 flag instead of the 0x1 flag to force W32time to send normal client requests. 14. Restart the w32time service as shown above and check the event log. If errors continue carry on as follows. 15. Check the Default Domain Controllers group policy and the Default Domain group policy and any others that could affect the PDCe or other DCs. Check the following areas: Computer configuration/Administrative Templates /System/Windows Time service/Time Providers Ensure that all three settings listed are set to not configured. 16. Now stop and restart the Windows Time service using the following commands: net stop w32time && net start w32time 17. At this point check the system event logs and you should see event id 35
18. If you are still having problems then as a final attempt, you can un-register and reregister the w32time service. This will clear out all configurations and let you start again from scratch. The details of how to do this are in the next section titled Other useful w32tm commands.
A final tip is that after any changes you should restart the w32time service
Value name: FileLogName Data Type: String Value data: C:\w32tmlog\w32time.log This registry value specifies the location of the log file. The path is not fixed. You can
Value name: FileLogEntries Data Type: String Value: 0-116 This registry value specifies the level of detail of the information in the debug log. If you must have more detailed logging information, contact a Microsoft Support Professional. Note The Data Type value must be of type REG_SZ (String). You must type the value exactly as shown (that is, type 0-116). The highest possible value is 0-300 for most detailed logging. The meaning of this value is: Log all entries within the range of 0 and 116.
The information above has been taken from the following MS KB article: http://support.microsoft.com/kb/816043/
References
Below are some links to pages I found useful when researching this article. The http://technet2.microsoft.com/WindowsServer/en/library/a0fcd250-e5f7-41b3-b0e8240f8236e2101033.mspx?mfr=true How to configure the Windows Time Service against a large time offset: http://support.microsoft.com/kb/884776/ Registry entries for the W32Time Service: http://support.microsoft.com/kb/q223184/ How to configure Debug logging: http://support.microsoft.com/kb/816043/ How to configure and authoritative time server in Windows Server 2003: http://support.microsoft.com/kb/816042 http://labmice.techtarget.com/windows2000/timesynch.htm http://www.pool.ntp.org/