OpenNTPd 在 alpine Linux 中无法工作

OpenNTPd 在 alpine Linux 中无法工作

在 Clean Alpine Linux 安装中运行

apk add openntpd
service openntpd start
rc-update add openntpd

然后修改/etc/ntpd.conf

# $OpenBSD: ntpd.conf,v 1.16 2019/11/06 19:04:12 deraadt Exp $
#
# See ntpd.conf(5) and /etc/examples/ntpd.conf

servers pool.ntp.org
server time.cloudflare.com
sensor *

constraint from "9.9.9.9"              # quad9 v4 without DNS
constraint from "2620:fe::fe"          # quad9 v6 without DNS
constraints from "www.google.com"      # intentionally not 8.8.8.8

listen on 0.0.0.0

并运行

service openntpd restart

从另一台计算机对服务器运行端口扫描,nmap显示未侦听 NTP 请求,因此无法正常工作。

重新启动服务器时我的日志,过滤了内核日志,删除了旧日志,还过滤了 sshd 登录行

Feb  3 12:05:40 ns1 user.debug : Will stop /usr/sbin/ntpd
Feb  3 12:05:40 ns1 user.debug : Will stop PID 2480
Feb  3 12:05:40 ns1 user.debug : Sending signal 15 to PID 2480
Feb  3 12:05:59 ns1 daemon.info init: starting pid 2815, tty '': '/sbin/openrc shutdown'
Feb  3 12:05:59 ns1 user.debug : Will stop /usr/sbin/sshd
Feb  3 12:05:59 ns1 user.debug : Will stop PID 2526
Feb  3 12:05:59 ns1 user.debug : Sending signal 15 to PID 2526
Feb  3 12:05:59 ns1 auth.info sshd[2526]: Received signal 15; terminating.
Feb  3 12:05:59 ns1 auth.info sshd[2739]: Exiting on signal 15
Feb  3 12:05:59 ns1 user.debug : Will stop /usr/sbin/ntpd
Feb  3 12:05:59 ns1 user.debug : Will stop PID 2796
Feb  3 12:05:59 ns1 user.debug : Sending signal 15 to PID 2796
Feb  3 12:06:00 ns1 user.debug : Will stop PID 2451
Feb  3 12:06:00 ns1 user.debug : Sending signal 15 to PID 2451
Feb  3 12:06:00 ns1 user.debug : Will stop /usr/sbin/crond
Feb  3 12:06:00 ns1 user.debug : Will stop PID 2416
Feb  3 12:06:00 ns1 user.debug : Sending signal 15 to PID 2416
Feb  3 12:06:00 ns1 user.debug : Will stop /sbin/syslogd
Feb  3 12:06:00 ns1 user.debug : Will stop PID 2363
Feb  3 12:06:00 ns1 syslog.info syslogd exiting
Feb  3 12:06:18 ns1 syslog.info syslogd started: BusyBox v1.36.1
Feb  3 12:06:18 ns1 daemon.info init: starting pid 2343, tty '': '/sbin/openrc default'
Feb  3 12:06:18 ns1 cron.info crond[2389]: crond (busybox 1.36.1) started, log level 8
Feb  3 12:06:19 ns1 auth.info sshd[2501]: Server listening on 0.0.0.0 port 22.
Feb  3 12:06:19 ns1 auth.info sshd[2501]: Server listening on :: port 22.
Feb  3 12:06:19 ns1 daemon.info init: starting pid 2502, tty '/dev/tty1': '/sbin/getty 38400 tty1'
Feb  3 12:06:19 ns1 daemon.info init: starting pid 2503, tty '/dev/tty2': '/sbin/getty 38400 tty2'
Feb  3 12:06:19 ns1 daemon.info init: starting pid 2507, tty '/dev/tty3': '/sbin/getty 38400 tty3'
Feb  3 12:06:19 ns1 daemon.info init: starting pid 2511, tty '/dev/tty4': '/sbin/getty 38400 tty4'
Feb  3 12:06:19 ns1 daemon.info init: starting pid 2514, tty '/dev/tty5': '/sbin/getty 38400 tty5'
Feb  3 12:06:19 ns1 daemon.info init: starting pid 2518, tty '/dev/tty6': '/sbin/getty 38400 tty6'
Feb  3 12:06:19 ns1 daemon.info init: starting pid 2523, tty '/dev/ttyS0': '/sbin/getty -L 0 ttyS0 vt100'

为什么这个配置没有使其成为 NTP 服务器?

答案1

NTP 服务器可能正在工作,因为相反声明的唯一来源正在运行地图(1).如中所述https://superuser.com/a/1656244,地图默认情况下仅测试 TCP 端口,而 NTP 使用 UDP。

不过,如果使用任何防火墙,例如乌夫沃(8)、NTP端口应明确配置为允许传入连接。例如,使用如下命令:

# ufw allow ntp

或类似的。

不幸的是,到目前为止,OpenNTPD 不包含用于测试服务器是否实际工作的直接命令,但可以使用其他程序来测试。例如,日期(8) (与ntpdate -q),ntp客户端或者可以使用类似的程序。使用其他操作系统(例如 Windows)的网络对等点也可以设置为从“日期和时间”控制面板查询服务器上的 NTP,并且应该报告连接中是否存在任何错误。

相关内容