在 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 服务器?