惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Security Archives - TechRepublic
Security Archives - TechRepublic
O
OpenAI News
W
WeLiveSecurity
Hacker News: Ask HN
Hacker News: Ask HN
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Troy Hunt's Blog
L
LINUX DO - 最新话题
SecWiki News
SecWiki News
Schneier on Security
Schneier on Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
H
Heimdal Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Palo Alto Networks Blog
Project Zero
Project Zero
Attack and Defense Labs
Attack and Defense Labs
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Tor Project blog
Scott Helme
Scott Helme
T
Threat Research - Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
Spread Privacy
Spread Privacy
Cisco Talos Blog
Cisco Talos Blog
T
Threatpost
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
Google DeepMind News
Google DeepMind News
P
Privacy & Cybersecurity Law Blog
Know Your Adversary
Know Your Adversary
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
L
Lohrmann on Cybersecurity
Cloudbric
Cloudbric
I
Intezer
The Hacker News
The Hacker News
L
LINUX DO - 热门话题
AI
AI
B
Blog
S
Securelist
P
Proofpoint News Feed
量子位
Jina AI
Jina AI
V2EX - 技术
V2EX - 技术
T
The Exploit Database - CXSecurity.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
CERT Recently Published Vulnerability Notes
J
Java Code Geeks
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

博客园 - ю意思я

视频播放的进化(一) 图片同步 WPF初体验 C#实现开关显示器功能 图片裁剪 共享文件夹 w32Time服务(NTP)的一些配置 ShutdownAPI 将文件读取到内存中 如何与使用DHCP获取IP地址的设备组网 在VS内添加Web Reference 如何消除锯齿,在图片上画出高质量的文字 如何让Firefox3支持迅雷 获取和设置IP地址 判断字符串是否为IPv4地址 axWindowsMediaPlayer操作 关于相对路径匹配的问题 ToFriendlyFileSize Class的设计
在windows server 2003服务器上提供NTP时间同步服务
ю意思я · 2009-05-15 · via 博客园 - ю意思я

  Network Time Protocol(NTP)是用来使计算机时间同步化的一种协议,它可以使计算机对其服务器或时钟源(如石英钟,GPS等等)做同步化,它可以提供高精准 度的时间校正(LAN上与标准间差小于1毫秒,WAN上几十毫秒),且可介由加密确认的方式来防止恶毒的协议攻击。

  NTP采用C/S结构,Server端作为时间来源,可以是原子钟、天文台、卫星,也可以从Internet上获取;而在我们的局域网内,则可以配置一个服务器,将其硬件时间作为时间源来提供服务;我在网上搜索了一下,大部分关于NTP服务的文章都是基于Linux的,提到windows server系列操作系统的不是很多,不过还是有很实用的内容;总结下来,其实要在windows server 2003上配置NTP服务是一件很简单的事情,如果该服务器是域控制器(DC),则已经默认启动了一个叫做win32time的服务,这个服务就是我们的NTPServer;如果不是域控制器,只需要修改注册表HKEY_LOCAL_MACHINE>>SYSTEM>>CurrentControlSet>>Services>>W32Time>>TimeProviders>>NtpServer下的Enabled为1(true)即可强制其宣布自身为可靠的时间源以启动win32time服务。

  Client端通过主动连接有效的Server端即可同步本地时间;以下是我在CodeProject上找到的有关NTPClient在C#下实现的代码(原帖地址):

NTPClient

   对NTPClient的调用

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TimeSync;
using System.Configuration;namespace CommandLine {
    
class Program {
        
static void Main(string[] args) {
            timeServer 
= ConfigurationManager.AppSettings["NTPServer"];
            Console.WriteLine(
"Connecting to:{0}", timeServer);try {
                client 
= new NTPClient(timeServer);
                client.Connect(
true);

                Console.Write(client.ToString());
            } 

catch (Exception ex) {
                Console.WriteLine(ex);
            }

            Console.WriteLine(

"== End ==");
            Console.ReadKey();
        }
private static string timeServer;
        
private static NTPClient client;
    }
}

   配置文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    
<appSettings>
        
<add key="NTPServer" value="192.168.16.101"/>
    
</appSettings>
</configuration>

   运行结果:

 

  对于大型局域网,可以使用多台服务器在逻辑上形成阶梯式的架构相互连接,对服务器进行分层(Stratum),Stratum-1的时间服务器是整个系统的基础,Stratum-2从Stratum-1获取时间,Stratum-3从Stratum-2获取时间,以此类推,Stratum的总数限制在15以内;由于我目前只是使用单一服务器提供整个局域网内的时间服务,因此服务端配置比较简单,而层的配置则相对复杂,还有很多需要研究的地方。