Tuesday, October 24, 2006

Windows 2003 Domain Time Synchronization


The best way to maintain all your computers and devices time synchronized its that one server handle the task of Time Server. In a windows domain environment, the PDC Emulator its the responsible of that task, but only to windows computers members of that domain.

To allow that server to the role of Time Server to other computers or devices I do the following.

In the PDC emulator of the forest root domain (the first domain controller you installed in the forest), open registry editor (regedit.exe) and configure the following:

HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters\Type

This registry entry determines which peers W32Time will accept synchronization from. I change this REG_SZ value from NT5DS to NTP so the PDC Emulator synchronizes from the list of reliable time servers specified in the NtpServer registry entry described below.

HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config\AnnounceFlags

This registry entry controls whether the local computer is marked as a reliable time server (which is only possible if the previous registry entry is set to NTP as described above). Change this REG_DWORD value from 10 to 5 here.

HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters\NtpServer

This registry entry specifies a space-delimited list of stratum 1 time servers from which the local computer can obtain reliable time stamps. The list may consist of one or more DNS names or IP addresses (if DNS names are used then you must append ,0x1 to the end of each DNS name). For example, to synchronize the PDC Emulator in your forest root domain with tock.usno.navy.mil, an open-access SNTP time server run by the United States Naval Observatory, change the value of the NtpServer registry entry from time.windows.com,0x1 to 1.north-america.pool.ntp.org,0x1 here. Alternatively, you can specify the IP address of this time server, which is 200.9.74.4 (this DNS record has many values) instead.

Now stop and restart the Windows Time service using the following commands:

net stop w32time

net start w32time

It may take an hour or so for the PDC Emulator to fully synchronize with the external time server because of the nature of the polling method W32Time uses. Depending on the latency of your Internet connection, the accuracy of the CMOS clock on your forest root PDC Emulator may be within a second or two of UTC. If you need more accurate time however, you can purchase a hardware time source like an atomic clock and connect it to your PDC emulator.

Alternatively, if you don’t want to wait for time convergence to occur between your stratum 2 time server (your forest root PDC Emulator) and the external stratum 1 time server, you can run the following command on your PDC Emulator:

w32tm /resync /rediscover

Now you can also synchronize all other devices with your internal server.

This is the TCPDUMP output when my Time queries the pool.ntp.org server.

# tcpdump -i fxp0 port 123
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on fxp0, link-type EN10MB (Ethernet), capture size 96 bytes
15:31:54.405417 IP 192.168.0.1.ntp > 209.134.156.193.ntp: NTPv4, Client, length 48
15:31:54.583201 IP 209.134.156.193.ntp >
192.168.0.1.ntp: NTPv4, Server, length 48
15:31:54.583400 IP
192.168.0.1.ntp > 209.134.156.193.ntp: NTPv4, Client, length 48
15:31:54.718812 IP 209.134.156.193.ntp >
192.168.0.1.ntp: NTPv4, Server, length 48
15:31:54.718958 IP
192.168.0.1.ntp > 209.134.156.193.tp: NTPv4, Client, length 48
15:31:54.860833 IP 209.134.156.193.ntp >
192.168.0.1.ntp: NTPv4, Server, length 48
15:31:54.860965 IP
192.168.0.1.ntp > 209.134.156.193.ntp: NTPv4, Client, length 48
15:31:55.026748 IP 209.134.156.193.ntp >
192.168.0.1.ntp: NTPv4, Server, length 48

As you can see, it queries the pool server four times.

This are the first two packets(first query) decoded.

15:41:47.169673 IP (tos 0x0, ttl 64, id 28921, offset 0, flags [none], proto: UDP (17), length: 76) 192.168.0.1.12
3 > 24.79.79.83.123: [udp sum ok] NTPv4, length 48
Client, Leap indicator: clock unsynchronized (192), Stratum 0, poll 4s, precision -6
Root Delay: 1.000000, Root dispersion: 1.000000, Reference-ID: (unspec)
Reference Timestamp: 0.000000000
Originator Timestamp: 0.000000000
Receive Timestamp: 0.000000000
Transmit Timestamp: 3370711307.169597354 (2006/10/24 15:41:47)
Originator - Receive Timestamp: 0.000000000
Originator - Transmit Timestamp: 3370711307.169597354 (2006/10/24 15:41:47)

15:41:47.254032 IP (tos 0x0, ttl 115, id 5765, offset 0, flags [none], proto: UDP (17), length: 76) 24.79.79.83.123 >
192.168.0.1.123: [udp sum ok] NTPv3, length 48
Server, Leap indicator: (0), Stratum 3, poll 4s, precision -6
Root Delay: 0.075942, Root dispersion: 0.089370, Reference-ID: 209.167.68.100
Reference Timestamp: 3370711255.533787299 (2006/10/24 15:40:55)
Originator Timestamp: 3370711307.169597354 (2006/10/24 15:41:47)
Receive Timestamp: 3370711307.228787299 (2006/10/24 15:41:47)
Transmit Timestamp: 3370711307.228787299 (2006/10/24 15:41:47)
Originator - Receive Timestamp: +0.059189944
Originator - Transmit Timestamp: +0.059189944



REGARDS

No comments: