1. Ubuntu NTP服务器搭建
1.1 安装ntp服务 sudo apt-get install ntp
1.2 修改配置文件/etc/ntp.con
1 # /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
2
3 3 driftfile /var/lib/ntp/ntp.drift
4 driftfile /var/lib/ntp/ntp.drift
43 driftfile /var/lib/ntp/ntp.drift
4
5
6 # Enable this if you want statistics to be logged.
7 #statsdir /var/log/ntpstats/
8
9 statistics loopstats peerstats clockstats
10 filegen loopstats file loopstats type day enable
11 filegen peerstats file peerstats type day enable
12 filegen clockstats file clockstats type day enable
13
14
15 # You do need to talk to an NTP server or two (or three).
16 server ntp.ubuntu.com
17
18
19 # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
20 # details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
21 # might also be helpful.
22 #
23 # Note that "restrict" applies to both servers and clients, so a configuration
24 # that might be intended to block requests from certain clients could also end
25 # up blocking replies from your own upstream servers.
26
27 # By default, exchange time with everybody, but don't allow configuration.
28 restrict -4 default kod notrap nomodify nopeer noquery
29 restrict -6 default kod notrap nomodify nopeer noquery
30
31 # Local users may interrogate the ntp server more closely.
32 restrict 127.0.0.1
33 restrict ::1
34
35 # Clients from this (example!) subnet have unlimited access, but only if
36 # cryptographically authenticated.
37 #restrict 192.168.123.0 mask 255.255.255.0 notrust
38
39
40 # If you want to provide time to your local subnet, change the next line.
41 # (Again, the address is an example only.)
42 broadcast 192.168.1.255
43
44 # If you want to listen to time broadcasts on your local subnet, de-comment the
45 # next lines. Please do this only if you trust everybody on the network!
46 disable auth
47 broadcastclient
1.3 启动ntp服务 sudo service ntp start
2. DM8168 NTP客户端
2.1 下载源码: http://support.ntp.org/bin/view/Main/SoftwareDownloads
2.2 编译生成可执行文件
tar xfvz ntp-XXX.tar.gz
cd ntp-XXX
./configure
修改 sntp/libopts/Makefile libntp/Makefile ntpdate/Makefile 将gcc g++修改为交叉编译环境中对应的编译器
对三个目录依次进行make
将ntpdate/ntpdate拷贝到目标设备上
2.3 测试ntpdate
在目标设备上执行ntpdate x.x.x.x // x.x.x.x为ntp服务dstip
2.4 编辑crontab (注意此时需要将ntpdate放知道系统的执行目录下)
crontab -e
*/15 * * * * ntpdate x.x.x.x