🙆♀️
raspberry pi 4でNTPサーバーの設定をする
raspberry pi 4のバージョン
uname -a
Linux production 6.6.74+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.74-1+rpt1 (2025-01-27) aarch64 GNU/Linux
cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
手順
-
sudo timedatectl set-ntp true
でNTPを有効化する -
sudo vim /etc/systemd/timesyncd.conf
でファイルを開く -
NTP=
とFallbackNTP=
に好きなNTPサーバー名を入れる -
FallbackNTP=
に複数のサーバー名を入力する場合、スペースで区切る - 以下のコマンドで反映させる
sudo systemctl daemon-reload
sudo systemctl restart systemd-timesyncd.service
/etc/systemd/timesyncd.conf
の設定例
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 2.1 of the License, or (at your option)
# any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the timesyncd.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# See timesyncd.conf(5) for details.
[Time]
NTP=time.aws.com
FallbackNTP=time.google.com
#FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048
#ConnectionRetrySec=30
#SaveIntervalSec=60
補足
公開されているNTPサーバーは調べたら大量に出てきます。好きなやつを使ってください。
Discussion