首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >独立NTP配置

独立NTP配置
EN

Server Fault用户
提问于 2019-01-16 21:52:51
回答 1查看 597关注 0票数 2

我正在尝试为一些测试设置本地NTP服务器。我已经在Ubuntu 18.04上安装了NTP,并在配置文件中注释了服务器池块。

下面是完整的配置:

代码语言:javascript
复制
driftfile /var/lib/ntp/ntp.drift

leapfile /usr/share/zoneinfo/leap-seconds.list

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited

restrict 127.0.0.1
restrict ::1

restrict source notrap nomodify noquery

restrict 10.24.0.0 mask 255.255.0.0 notrust

server 127.127.1.0
fudge 127.127.1.0 stratum 10

使用此命令设置我想要的sudo timedatectl set-time "2013-06-02 23:26:00"时间

我还试着查看ntp服务是否由正在运行的sudo systemctl status ntp.service运行,但在123端口上显示时,我没有发现任何正在运行的服务。与ps一起发现

代码语言:javascript
复制
ubuntu@ntp:~$ ps auxww | grep '[n]tp'
ntp      13517  0.0  0.8 103212  4136 ?        Ssl  Jun02   0:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 111:115

当客户端试图从此服务器上运行的NTP中获得时间时,就会超时。在/var/log/syslog中也看不到任何消息

更多信息:

代码语言:javascript
复制
ubuntu@ntp:~$ ps auxww | grep '[n]tp'
ntp        807  0.0  0.7 103212  3480 ?        Ssl  Jan28   0:02 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 111:115

ubuntu@ntp:~$ ntpq -pn
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*127.127.1.0     .LOCL.          10 l    2   64  377    0.000    0.000   0.000

ubuntu@ntp:~$ ntpq -c rv
associd=0 status=0515 leap_none, sync_local, 1 event, clock_sync,
version="ntpd 4.2.8p10@1.3728-o (1)", processor="x86_64",
system="Linux/4.15.0-1019-aws", leap=00, stratum=11, precision=-24,
rootdelay=0.000, rootdisp=11.016, refid=LOCAL(0),
reftime=de1977a0.2605c5ad  Mon, Jan 29 2018  5:36:16.148,
clock=de1977a6.758ae7fc  Mon, Jan 29 2018  5:36:22.459, peer=57525, tc=6,
mintc=3, offset=0.000000, frequency=0.000, sys_jitter=0.000000,
clk_jitter=0.000, clk_wander=0.000, tai=37, leapsec=201701010000,
expire=201812280000

我尝试使用脚本从真正的NTP服务器获得时间,而不是在独立的NTP上。

我在这里错过了什么?

EN

回答 1

Server Fault用户

回答已采纳

发布于 2019-01-16 23:16:39

查看服务打开的端口的一种方法是:

netstat -an

当然,您可以使用grep命令过滤输出,如下所示:

netstat -an|grep 123

我有时也使用lsof,如下所示:

lsof -i udp -nP在基于RedHat的发行版中。

有关更多信息,请参见man lsofman netstat

我希望这能帮到你。

票数 2
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/949433

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档