NTPD配置指南
ntpd -p的参数

ntpd -p的参数选项使用方法:
•-4:只使用IPv4。
•-6:只使用IPv6。
•-a:在NTP服务器和NTP服务器之间自动选择。
•-A:在NTP服务器和NTP服务器之间强制选择。
•-b:在启动时尝试广播。
•-d:增加调试信息到标准错误输出。
•-D:增加详细的调试信息到标准错误输出。
•-g:强制立即同步时间,而不等待NTP服务器之间的时间调整。
•-G:不使用任何延迟平滑算法。
•-h:打印帮助信息。
•-i:指定一个接口。
•-l:在日志文件中记录事件。
•-L:忽略所有NTP服务器的时间戳。
•-m:在启动时尝试多播。
•-n:只使用非递归模式。
•-N:使用最大可能的速率。
•-o:在启动时尝试单播。
•-p:指定一个PID文件。
•-P:设置NTP服务器的优先级。
•-q:退出并打印一个查询消息。
•-r:设置广播延迟。
•-s:设置统计目录。
•-t:测试时间戳。
•-u:设置用户ID和组ID。
•-U:设置接口更新间隔。
•-v:增加详细输出到标准错误输出。
•-V:打印版本信息并退出。
NTP时间服务器配置

NTP时间服务器学习笔记引言NTP时间服务器就是提供时间授权(对时)的服务器,它可以用Linux或Windows系统来架设。
总来说NTP时间服务器理解和配置都相对简单,我们只在此提醒一点NTP通信端口采用udp的123端口。
以下我们以Windows 2008/Redaht5.4作为时间服务器为服务端,Linux和Windows系统为客户端来学习一下。
服务端Windows NTP服务器默认情况下,独立服务器WINDOWS SERVER 2008是作为NTP客户端工作的,所以必须通过修改注册表,以使系统作为NTP服务器运行。
工作之前请先备份注册表文件。
1、修改以下选项的键值HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServe r内的[Enabled]设定为1。
打开NTP服务器功能(默认是不开启NTP Server服务,除非电脑升级成为域控制站)。
2、修改以下键值HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config\AnnounceFlags 设定为5.该设定强制主机将它自身宣布为可靠的时间源,从而使用内置的互补金属氧化物半导体(CMOS) 时钟。
如果要采用外面的时间服务器就用默认的a值即可.# 210.72.145.44 (国家授时中心服务器IP地址)3、修改以下键值HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters\Type内的[Type]设定为NTP。
4、重启Win32Time服务:先关闭windows time 服务,再开启该服务。
可以在“管理工具”的“服务”界面下完成,也可以以DOS 方式输入“net stop w32time”、“net start w32time”。
NTPD配置指南

NTPD配置指南本配置指南适用于使用NMEA格式gps,本文假定该gps使用$GPRMC格式数据,波特率为9600bps。
测试环境:操作系统,ubuntu11.10。
内核linux-3.1.6.tar.bz2。
ntp版本ntp-4.2.6p5.tar.gz,PPS测试工具ago-pps-tools-6b14c72.tar.gz,头文件ppsclock.h。
假定本机IP地址为192.168.1.1。
1.编译内核:$tar -xjvf linux-3.1.6.tar.bz2$cd linux-3.1.6$cp /boot/config-3.0.0-12-generic .config$make menuconfig选择以下驱动│┌─────────────────────────────────────────────────────────────────────┐│││ <*> PPS support ││││ [ ] PPS debugging messages ││││ *** PPS clients support *** ││││ <*> Kernel timer client (Testing client, use for debug) ││││ <*> PPS line discipline ││││ < > Parallel port PPS client ││││ *** PPS generators support ***{*} 8250/16550 and compatible serial support ││││ [*] Console on 8250/16550 and compatible serial port ││││ <*> 8250/16550 PCI device support$make$make modules$make modules_install$make install$reboot选择新内核启动系统$ cd /usr/include$ mv linux linux.old$ mv asm asm.old$ mv asm-generic asm-generic.old$ ln -s /lib/modules/$(uname -r)/build/include/linux linux$ ln -s /lib/modules/$(uname -r)/build/arch/x86/include/asm asm$ ln -s /lib/modules/$(uname -r)/build/include/asm-generic asm-generic$ cd /usr/include$ cp /usr/src/pps-tools/timepps.h timepps.h$ cp /usr/src/pps-tools/ppsclock.h ppsclock.h2.编译ntp$ sudo apt-get install ntp 获取相应的配置文件进入ntp-4.2.6p5目录$./configure --disable-all-clocks --enable-NMEA --enable-SHM --enable-ATOM --enable-LOCAL-CLOCK --disable-parse-clock$make;make install3.配置启动环境修改/etc/init.d/ntp文件第50行删除内容NTPD_OPTS="$NTPD_OPTS -u $UGID" 中的文字-u $UGID将16行的DAEMON=/usr/sbin/ntpd改为DAEMON=/usr/local/bin/ntpd15行下增加几行,这里假定使用串口4,此时的串口设备为/dev/ttyS4,如果使用其他串口,将下面的串口设备名做相应的修改:if [ ! -e /dev/pps1 ] ;thenldattach PPS /dev/ttyS4fiif [ -e /dev/gps0 ] ;thenrm -f /dev/gps0fiif [ -e /dev/gpspps0 ] ;thenrm -f /dev/gpspps0filn -s /dev/ttyS4 /dev/gps0ln -s /dev/pps1 /dev/gpspps0setserial /dev/ttyS4 low_latency4.配置ntpd启动文件更改配置文件/etc/ntp.conf去掉其他以server 开头的行,取消从网络获取时间编辑ntp.conf 方法:vim /etc/ntp.conf 回车进入界面,按i插入,编辑完成后,按ESC,按shift+Z 两次之后 /etc/init.d/ntp restart 回车启动ntp配置方法一:(推荐使用,同步更快,误差更小):增加一下两行:server 127.127.20.0 mode 17 minpoll 4 maxpoll 4 preferfudge 127.127.20.0 flag1 1 flag3 1 time2 0.085 (0.182)上面的time2 0.085 需要准确测量,它为秒脉冲前沿到串行数据结束之间的时间差,单位为秒。
NTPD手册

NTPD手册LINUX环境:Linux localhost.localdomain 2.6.23.1-42.fc8 #1 SMP Tue Oct 30 13:55:12 EDT 2007 i686 i686 i386 GNU/LinuxTERM=linuxSHELL=/bin/bashHISTSIZE=1000USER=rootCCACHE_DIR=/var/cache/ccachePA TH=/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/arm/3.4.1/bin:/usr/local/sbin:/usr/local/b in:/sbin:/bin:/usr/sbin:/usr/bin:/root/binPWD=/mnt/hgfs/exchangeCCACHE_UMASK=002LANG=en_US.UTF-8HOME=/rootLOGNAME=rootCVS_RSH=sshG_BROKEN_FILENAMES=1_=/bin/envOLDPWD=/mnt/hgfsGCC:Reading specs from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/specsConfigured with: /work/crosstool-0.27/build/arm-linux/gcc-3.4.1-glibc-2.3.2/gcc-3.4.1/configure --target=arm-linux --host=i686-host_pc-linux-gnu --prefix=/usr/local/arm/3.4.1 --with-headers=/usr/local/arm/3.4.1/arm-linux/include --with-local-prefix=/usr/local/arm/3.4.1/arm-linux --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-longThread model: posixgcc version 3.4.1(3.3.2也可以)配置命令:./configure --build=i386-pc-linux-gnu --host=arm-linux --target=arm-linux配置文件:config.hPPS API:timepps.hNTPD版本:4.2.4p4修改后的config.h和Makefile见目录。
Linux时间同步,ntpd,ntpdate-简单设置

linux时间同步,ntpd、ntpdate在Windwos中,系统时间的设置很简单,界面操作,通俗易懂。
而且设置后,重启,关机都没关系。
系统时间会自动保存在Bios的时钟里面,启动计算机的时候,系统会自动在Bios里面取硬件时间,以保证时间的不间断。
但在Linux下,默认情况下,系统时间和硬件时间,并不会自动同步。
在Linux运行过程中,系统时间和硬件时间以异步的方式运行,互不干扰。
硬件时间的运行,是靠Bios电池来维持,而系统时间,是用CPU tick来维持的。
在系统开机的时候,会自动从Bios中取得硬件时间,设置为系统时间。
一.Linux系统时间的设置在Linux中设置系统时间,可以用date命令://查看时间[root@localhost ~]# date2008年12月12日星期五14:44:12 CST//修改时间[root@localhost ~]# date --set "1/1/09 00:01" <== (月/日/年时:分:秒)2009年01月01日星期四00:01:00 CST//date 有几种时间格式可接受,这样也可以设置时间:[root@localhost ~]# date 012501012009.30 <== 月日时分年.秒2009年01月25日星期日01:01:30 CST二.Linux硬件时间的设置硬件时间的设置,可以用hwclock或者clock命令。
其中,clock和hwclock用法相近,只用一个就行,只不过clock命令除了支持x86硬件体系外,还支持Alpha硬件体系。
//查看硬件时间可以是用hwclock ,hwclock --show 或者hwclock -r[root@localhost ~]# hwclock --show2008年12月12日星期五06时52分07秒-0.376932 seconds//设置硬件时间[root@localhost ~]# hwclock --set --date="1/25/09 00:00" <== 月/日/年时:分:秒[root@localhost ~]# hwclock2009年01月25日星期日00时00分06秒-0.870868 seconds三.系统时间和硬件时间的同步同步系统时间和硬件时间,可以使用hwclock命令。
NTP时间服务器配置

NTP服务器配置实验环境:RHEL5Server:192.168.2.10Client:192.168.2.120一、搭建时间同步服务器1、编译安装ntp serverrpm -qa | grep ntp2、修改ntp.conf配置文件vi /etc/ntp.conf①、第一种配置:允许任何IP的客户机都可以进行时间同步#restrict default kod nomodify notrap nopeer noqueryrestrict default modify notrap②、第二种配置:只允许192.168.2.0网段的客户机进行时间同步在restrict default nomodify notrap noquery(表示默认拒绝所有IP的时间同步)之后增加一行:restrict 192.168.2.0 mask 255.255.255.0 nomodify notrap3、启动ntp服务service ntpd start开机启动服务chkconfig --level 35 ntpd on4、ntpd启动后,客户机要等几分钟再与其进行时间同步,否则会提示“no server suitable for synchronization found”错误。
二、配置时间同步客户机手工执行ntpdate <ntp server> 来同步或者利用crontab来执行crontab -e0-59/10 * * * * /usr/sbin/ntpdate 192.168.2.10 >> /root/ntpdate.log 2>&1表示每隔10分钟同步一次时间三、在服务端验证:# watch ntpq -pEvery 2.0s: ntpq -p Tue Dec 7 05:52:55 2010remote refid st t when poll reach delay offset jitter====================================================================== ========*LOCAL(0) .LOCL. 8 l 22 64 377 0.000 0.000 0.001服务正常运行在客户端进行同步验证:# ntpdate -d 192.168.2.107 Dec 05:54:42 ntpdate[3627]: ntpdate 4.2.2p1@1.1570-o Thu Nov 26 11:35:07 UTC 2009 (1) Looking for host 192.168.2.10 and service ntphost found : 192.168.2.10transmit(192.168.2.10)receive(192.168.2.10)transmit(192.168.2.10)receive(192.168.2.10)transmit(192.168.2.10)receive(192.168.2.10)transmit(192.168.2.10)receive(192.168.2.10)transmit(192.168.2.10)server 192.168.2.10, port 123stratum 9, precision -20, leap 00, trust 000refid [192.168.2.10], delay 0.02632, dispersion 0.00061transmitted 4, in filter 4reference time: d0a890f1.b4d040ff Tue, Dec 7 2010 5:54:41.706originate timestamp: d0a89102.09318178 Tue, Dec 7 2010 5:54:58.035transmit timestamp: d0a890f2.3c8effe2 Tue, Dec 7 2010 5:54:42.236filter delay: 0.02910 0.02632 0.02808 0.026410.00000 0.00000 0.00000 0.00000filter offset: 15.80026 15.79880 15.79793 15.798370.000000 0.000000 0.000000 0.000000delay 0.02632, dispersion 0.00061offset 15.7988017 Dec 05:54:42 ntpdate[3627]: step time server 192.168.2.10 offset 15.798801 sec附:当用ntpdate -d 来查询时会发现导致no server suitable for synchronization found 的错误的信息有以下2个:错误1.Server dropped: Strata too high在ntp客户端运行ntpdate serverIP,出现no server suitable for synchronization found的错误。
NTP时间同步客户端配置步骤

如果想设置NTP客户端,与时间服务器同步,可以采用如下步骤
1、客户端查询NTP服务器
ntp客户端使用 ntpdate 命令来确认是否可用指定的 ntp 服务器进行时间同步,命令的结果会显示客户端与服务器的时间偏移。
#ntpdate -d 192.168.30.221
……
18 Mar 10:52:54 ntpdate[23578]: step time server 192.168.30.221 offset 86323.068272 sec
c. driftfile /etc/ntp.drift
(3)编辑/etc/rc.config.d/netdaemons
更改一个参数:
export XNTPD=1 下次重启主机仍然生效
(4)启动xntpd
#date
Wed Mar 19 11:06:54 BEIST 2003
2、编辑 NTP 客户端上的 /etc/ntp.conf文件
内容如下:
#vi /etc/ntp.conf
—————————-
#broadcastclient
server 192.168.30.221
driftfile /etc/ntp.drift
touch
server 133.64.5.84/132.129.24.6
fudge 133.64.5.83 stratum 8
driftfile /etc/ntp.drift
IBM AIX:
xntpd是一个关于网络时间协议的守护进程,它遵循了因特网时间服务器的通用标准。在启动 xntpd 时, xntpd 会读取/etc/ntp.conf 配置文件来确定网络中系统时钟服务器,以ntp 服务器的系统时间为标准,来调整本机的系统时间。
海康威视NVR如何配置NTP和DST说明书

How to configure NTP and DSTPurposeSometime the device date/time may be incorrect. In order to avoid this, HIKVISION devices use NTP (Network Time Protocol) as well as DST (Daylight Saving Time) to adjust device time.How to configure NTP:Steps:1. Enter the Network Settings interface.Menu >Configuration> Network2. Select the NTP tab to enter the NTP Settings interface. Check the Enable NTP checkbox to enable this feature.4. Configure the following NTP settings:•Interval: Time interval between the two synchronizing actions with NTP server. The unit is minute.•NTP Server: IP address of NTP server.•NTP Port: Port of NTP server. Default as 123.5. Click the Apply button to save and exit the interface.6. Or configure it via web browser in the interface below.Note:The time synchronization interval can be set from1 to 10080min, and the default value is60min. If the NVR is connected to a public network, you should use a NTP server that has a time synchronization function, such as the server at the National Time Center (IP Address: 210.72.145.44). If the NVR is setup in a more customized network, NTP software can be used to establish a NTP server used for time synchronization.How to configure DST:Steps:1. Enter the General Settings interface.Menu >Configuration>General2. Choose DST Settings tab.You can check the checkbox of Auto DST Adjustment item.Or you can manually check the Enable DST checkbox, and then you choose the date/time of the DST period.3. Or configure it via web browser in the interface below.Note:1. When it is daylight saving time, if you just enable NTP without DST enabled, your device time may not be synchronized with local DST time. The solution is to enable DST.2. If you have an IPC added to NVR, just set NTP and DST in NVR would be OK. The device time of IPC would be synchronized by NVR.First Choice for Security Professionals HIK VISION Technical Support。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
NTPD配置指南
NTPD(网络时间协议守护进程)是一个用于同步计算机的系统时钟的服务程序。
配置正确的NTPD是确保计算机时间准确性的重要步骤,尤其是在需要与其他计算机进行时间同步的情况下。
以下是一个NTPD配置指南,包括了一些常用的配置选项和参数。
1.安装NTPD:
在大多数Linux发行版中,NTPD都是默认安装的。
如果没有安装,可以使用以下命令安装它:
```
sudo apt-get install ntpd
```
或者
```
sudo yum install ntpd
```
2.配置NTPD:
3.选择NTP服务器:
NTPD从一个或多个NTP服务器同步时间。
可以在配置文件中指定要使用的NTP服务器。
例如:
```
```
可以使用多个server行指定多个NTP服务器,以提供冗余和更好的
时间源。
4.本地时钟源:
除了外部NTP服务器,NTPD还可以使用本地时钟源进行时间同步。
要启用本地时钟源,可以在配置文件中添加以下行:
```
server 127.127.1.0
fudge 127.127.1.0 stratum 10
```
这将使用NTPD的本地时钟进行时间同步,并将其宣布为stratum 10。
5.配置日志:
NTPD可以生成日志以记录时间同步的活动和错误信息。
可以配置NTPD以指定日志文件的位置和详细级别。
例如:
```
logfile /var/log/ntp.log
driftfile /var/lib/ntp/ntp.drift
```
这将将日志记录写入/var/log/ntp.log,并将时钟漂移数据保存在
/var/lib/ntp/ntp.drift中。
6.启用认证:
为了确保时间的准确性和安全性,可以启用NTPD的认证功能来验证传入的时间数据。
可以在配置文件中添加以下行来启用认证:```
keys /etc/ntp/keys
trustedkey 1
```
这将启用NTPD的认证功能,并使用/etc/ntp/keys文件存储密钥。
7.配置访问控制:
对NTP服务的访问进行适当的限制对于保护服务器的安全至关重要。
可以在配置文件中添加以下行来配置访问控制:
```
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict x.x.x.x
```
第一行限制了默认的访问权限,不允许修改、捕获控制台、对等点或查询。
第二行限制了只有本地主机可以使用NTP服务。
第三行限制了允许访问NTP服务的特定IP地址。
8.启动NTPD:
完成配置后,可以使用以下命令启动NTPD服务:
```
sudo systemctl start ntpd
```
或者
```
sudo service ntpd start
```
9.验证同步:
可以使用以下命令验证NTPD是否成功同步时间:
```
ntpq -p
```
该命令将显示已与NTP服务器同步的详细信息。
10.定期重新启动:
为了确保NTPD长期稳定运行,建议定期重新启动服务。
可以使用以下命令来定期重新启动NTPD:
```
sudo systemctl restart ntpd
```
或者
```
sudo service ntpd restart
```
通过按照以上步骤和配置选项,您将能够成功配置和管理NTPD服务,确保计算机时间的准确性和同步。
请记住,正确配置的NTPD是确保网络
中所有设备时间一致性的关键。