Configuring NTP on Windows Server 2012

Configuring NTP on Windows Server 2012

by Admin | Jul 26, 2012 | Windows | 16 comments

This article explains how to configure NTP on Windows Server 2012. If you’re looking for Windows Server 2008 R2, see my article here. Remember, that in a domain environment, time synchronization is taken care of but you should configure the PDC Emulator of a domain to sync externally since that is the server which decides what time it is!

Are you looking how to configure NTP using GPO, please read my article on it here.

This is all you need if you want to keep it simple. Run using PowerShell as admin:

w32tm /config /manualpeerlist:pool.ntp.org /syncfromflags:MANUAL
Stop-Service w32time
Start-Service w32time

If the machine is a VM inside Hyper-V, you have to disable time sync. Open VM settings -> Management -> Integration Services and uncheck Time Synchronization.

**That should be it! **Want to know more? Doesn’t work? Have you screwed up the config and want to start from the beginning? Keep on reading…

W32tm is the command to use. Sure, there are articles out there mentioning “net time”, but you should not use that. Some other also mentions editing the registry directly, but as Microsoft mentions in the article: It is recommended that you do not directly edit the registry unless there is no other alternative. But if you really want to check the registry, it’s here: HKLM\System\CurrentControlSet\Services\W32Time.

Which NTP-server to use? Or several?

The pool.ntp.org is a round-robin of random selected NTP servers. As they say “This is usually good enough for end-users“. But you might want to add several NTP-servers yourself for redundancy?

w32tm /config /manualpeerlist:”0.pool.ntp.org 1.pool.ntp.org” /syncfromflags:MANUAL

Just keep adding them with a space in between them. Yes, I know some sites say you should separate them using comma but that doesn’t work. Also, I’ve experienced issues that it configures correctly, but still after restarting the service, it doesn’t work. I just needed to do the configuration again, and try once more. Also, remember that cut’n’paste from the web can sometimes screw up the ” character so write it manually instead of cut’n’paste to be sure.

Don’t forget your firewall

If you got a firewall between your host and the Internet, it might drop udp/123 which is the NTP protocol. This is how it looked in my Cisco ASA FW:

So I created a rule to allow it and after that it worked.

More info and debug logging

The following commands are quite useful which lists the current source, when it last sync’ed etc.

w32tm /query /status

Eventually, when the server can’t get time from the NTP server it will add an event to the event log:

Log Name: System
Source: Microsoft-Windows-Time-Service
Event ID: 47
Level: Warning
Description: Time Provider NtpClient: No valid response has been received from manually configured peer pool.ntp.org after 8 attempts to contact it. This peer will be discarded as a time source and NtpClient will attempt to discover a new peer with this DNS name. The error was: The peer is unreachable.

Otherwise, when it’s working, you will get:

Log Name: System
Source: Microsoft-Windows-Time-Service
Event ID: 35
Level: Information
Description: The time service is now synchronizing the system time with the time source pool.ntp.org (ntp.m|0x0|0.0.0.0:123->85.10.240.253:123).

You still getting problems? You can easily turn on debugging to a logfile which in this case is limited t0 10 MB and include ALL debug entries.

w32tm /debug /enable /file:C:\Temp\w32tmdebug.log /size:10485760 /entries:0-300

Turn it off again with:

w32tm /debug /disable

Expect a lot of info in this debug log. For me, when it worked, the following entries showed it was working:

– Reachability: peer pool.ntp.org (ntp.m|0x0|0.0.0.0:123->129.70.132.35:123) is reachable.
– Logging information: NtpClient is currently receiving valid time data from pool.ntp.org (ntp.m|0x0|0.0.0.0:123->129.70.132.35:123).

But when I had my firewall blocking the packets, I would get the following. Don’t trust this too much though, since I did get this when I allowed it in the firewall also, but when it was blocked, I did not get the entries above.

– Logging error: NtpClient has been configured to acquire time from one or more time sources, however none of the sources are currently accessible and no attempt to contact a source will be made for 1 minutes. NTPCLIENT HAS NO SOURCE OF ACCURATE TIME.

Force a resync

If you want to force the client to resync, run:

w32tm /resync
Sending resync command to local computer
The command completed successfully.

If you get the following error, the computer can’t reach the NTP-server(s).

The computer did not resync because no time data was available.

Start from scratch

If you completely screwed up the config, you can always do the following command and it will completely erase and add a default W32time configuration:

Stop-Service w32time
w32tm /unregister
w32tm /register

When doing the unregister I got the following error for some reason, but it seems like it worked anyway.

The following error occurred: Access is denied. (0x80070005)

Sometimes when doing the /register, I would get the following. This usually solved by waiting for a while. I would suggest you stop the service before doing /unregister. Otherwise, a reboot would probably solve most problems.

The following error occurred: The specified service has been marked for deletion. (0x80070430)

If you miss any important information, let me know and I’ll add it.

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末惊来,一起剝皮案震驚了整個(gè)濱河市冗疮,隨后出現(xiàn)的幾起案子晋控,更是在濱河造成了極大的恐慌,老刑警劉巖趾撵,帶你破解...
    沈念sama閱讀 219,427評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異共啃,居然都是意外死亡占调,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,551評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門(mén)移剪,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)究珊,“玉大人,你說(shuō)我怎么就攤上這事挂滓】嘁” “怎么了啸胧?”我有些...
    開(kāi)封第一講書(shū)人閱讀 165,747評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)幔虏。 經(jīng)常有香客問(wèn)我纺念,道長(zhǎng),這世上最難降的妖魔是什么想括? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 58,939評(píng)論 1 295
  • 正文 為了忘掉前任陷谱,我火速辦了婚禮,結(jié)果婚禮上瑟蜈,老公的妹妹穿的比我還像新娘烟逊。我一直安慰自己,他們只是感情好铺根,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,955評(píng)論 6 392
  • 文/花漫 我一把揭開(kāi)白布宪躯。 她就那樣靜靜地躺著,像睡著了一般位迂。 火紅的嫁衣襯著肌膚如雪访雪。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 51,737評(píng)論 1 305
  • 那天掂林,我揣著相機(jī)與錄音臣缀,去河邊找鬼。 笑死泻帮,一個(gè)胖子當(dāng)著我的面吹牛精置,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播锣杂,決...
    沈念sama閱讀 40,448評(píng)論 3 420
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼脂倦,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了元莫?” 一聲冷哼從身側(cè)響起狼讨,我...
    開(kāi)封第一講書(shū)人閱讀 39,352評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎柒竞,沒(méi)想到半個(gè)月后政供,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,834評(píng)論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡朽基,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,992評(píng)論 3 338
  • 正文 我和宋清朗相戀三年布隔,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片稼虎。...
    茶點(diǎn)故事閱讀 40,133評(píng)論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡衅檀,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出霎俩,到底是詐尸還是另有隱情哀军,我是刑警寧澤沉眶,帶...
    沈念sama閱讀 35,815評(píng)論 5 346
  • 正文 年R本政府宣布,位于F島的核電站杉适,受9級(jí)特大地震影響谎倔,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜猿推,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,477評(píng)論 3 331
  • 文/蒙蒙 一片习、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧蹬叭,春花似錦藕咏、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 32,022評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至坦喘,卻和暖如春卦碾,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背起宽。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 33,147評(píng)論 1 272
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留济榨,地道東北人坯沪。 一個(gè)月前我還...
    沈念sama閱讀 48,398評(píng)論 3 373
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像擒滑,于是被迫代替她去往敵國(guó)和親腐晾。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,077評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容