QNAP の NAS の NTP サーバーの有効化

Aug. 6 2022

QNAP の NAS のコントロールパネルには「NTPサーバを有効にする」というオプションがあるのに、なぜか NTP サーバとして機能してくれない。
ntpd の設定ファイル /etc/config/ntp.conf を修正しても、起動時に /etc/init.d/ntpf.sh によってその都度書き換えられている。
ntp の設定を /etc/config/uLinux.conf に記述し、そこからサーバー設定を読み込むように /etc/init.d/ntpf.sh を修正したところ ntp サーバーとして使えるようになった。


動作確認環境

Model TS-453A : Firmware version 5.0.0.2055
Model TS-453D : Firmware version 5.0.0.2055

/etc/config/uLinux.conf 変更

[NTP] セクションの Server1 IP 〜 Server3 IP を設定。
下の例は ntp.nict.jp の ntp サーバープールから得られたアドレスの一部。


[NTP]
USE NTP Server = TRUE
NTP Server IP = ntp.nict.jp
Enable NTP Server = FALSE
Server1 IP = 133.243.238.243
Server2 IP = 133.243.238.164
Server3 IP = 61.205.120.130
Interval = 7
TimeUnit = DAY

/etc/init.d/ntpf.sh 変更

NTP server1 〜 NTP server3 の設定を読み込むようにコメントを3箇所外す。
使用する LAN に合わせて restrict も追加。

$ diff /etc/init.d/ntpf.sh.orig /etc/init.d/ntpf.sh

--- /etc/init.d/ntpf.sh.orig
+++ /etc/init.d/ntpf.sh
@@ -10,6 +10,7 @@
        echo "restrict -6 default limited kod nomodify notrap nopeer noquery" >> $NTP_CONF
        echo "restrict 127.0.0.1" >> $NTP_CONF
        echo "restrict -6 ::1" >> $NTP_CONF
+       echo "restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap" >> $NTP_CONF
 }
 case "$1" in
   start)
@@ -36,7 +37,7 @@
                        #       NTPSVR3=`echo $NTPSVR_IPS | /bin/cut -d " " -f 3`
                        #fi

-                       #srvip1=`/sbin/getcfg NTP "Server1 IP" -d ""`
+                       srvip1=`/sbin/getcfg NTP "Server1 IP" -d ""`
                        [ ! -z $NTPSVR1 ] && srvip1=$NTPSVR1
                        if [ "$srvip1" != "" ]; then
                                /usr/sbin/ntpdate -q $srvip1 2>/dev/null 1>/dev/null
@@ -46,7 +47,7 @@
                                fi
                        fi

-                       #srvip2=`/sbin/getcfg NTP "Server2 IP" -d ""`
+                       srvip2=`/sbin/getcfg NTP "Server2 IP" -d ""`
                        [ ! -z $NTPSVR2 ] && srvip2=$NTPSVR2
                        if [ "$srvip2" != "" ]; then
                                /usr/sbin/ntpdate -q $srvip2 2>/dev/null 1>/dev/null
@@ -56,7 +57,7 @@
                                fi
                        fi

-                       #srvip3=`/sbin/getcfg NTP "Server3 IP" -d ""`
+                       srvip3=`/sbin/getcfg NTP "Server3 IP" -d ""`
                        [ ! -z $NTPSVR3 ] && srvip3=$NTPSVR3
                        if [ "$srvip3" != "" ]; then
                                /usr/sbin/ntpdate -q $srvip3 2>/dev/null 1>/dev/null

ControlPanel — NTP Server を設定

一度 Enable NTP Server のチェックを外して Apply して ntpd を停止後、チェックを入れて Apply して ntpd を再起動する。
ntp サーバーに同期すると (NTP server is syncronizing) となる。


/sbin/ntpq で動作確認


$ /sbin/ntpq -p -c rv
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+ntp-a2.nict.go. .NICT.           1 u  248  256  377   10.159   -2.404   0.930
+ntp-b3.nict.go. .NICT.           1 u   63  256  377    9.383   -3.234   1.698
*ntp-k1.nict.jp  .NICT.           1 u  187  256  377   19.844   -2.899   1.451
associd=0 status=0615 leap_none, sync_ntp, 1 event, clock_sync,
version="ntpd 4.2.8p10@1.3728 Mon May 30 19:20:56 UTC 2022 (1)",
processor="x86_64", system="Linux/5.10.60-qnap", leap=00, stratum=2,
precision=-22, rootdelay=19.844, rootdisp=14.374, refid=61.205.120.130,
reftime=e6982128.dcc9f289  Sat, Aug  6 2022  8:07:20.862,
clock=e69822f0.639b7e9b  Sat, Aug  6 2022  8:14:56.389, peer=19803, tc=8,
mintc=3, offset=-2.478297, frequency=-6.622, sys_jitter=0.526662,
clk_jitter=0.745, clk_wander=0.551

あとがき

とりあえず、QNAP の NAS の NTP サーバーを有効にできたのは良いんだけれど、 ブラウザ経由用の全体設定ファイル経由の中途半端な設定よりも、普通に ntp.conf 読み込むようにした方が良い気がするんだけど、 そもそも NAS だし仕方ないのかなぁ。


www.finetune.co.jp [Mail] © 2000 Takayuki HOSODA.