LoginSignup
5

More than 5 years have passed since last update.

FreeBSD 10.3-RELEASE ntpd 閏秒ファイル更新

Posted at

FreeBSD 10.3-RELEASE では、ntpd デフォルト設定ファイルで閏秒ファイルを読み込むようになっています。
しかし、10.3-RELEASEの閏秒ファイルの有効期限が2016年6月1日となっているため、以下のようなエラーメッセージが出力されます。

May 31 09:03:20 freebsd10 ntpd[987]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): will expire in less than one day
Jun  1 20:13:15 freebsd10 ntpd[983]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): expired less than 1 day ago

1日1回、閏秒ファイルをチェックして自動更新する仕組みもありますが、正しく動作しません。

ここでは、手動で閏秒ファイルを更新する手順を書きます。

閏秒ファイル手動更新

FreeBSD-CURRENT の閏秒ファイルを取得して ntpd を再起動します。
サーバ証明書でエラーが出る場合は、sudo pkg install ca_root_nss でルートCA証明書をインストールします。

$ cd /tmp
$ svnlite export https://svn.FreeBSD.org/base/head/etc/ntp/leap-seconds
$ sudo cp leap-seconds /var/db/ntpd.leap-seconds.list
$ sudo service ntpd restart

ログメッセージを確認して、期限切れとなっていない有効な閏秒ファイルが読み込まれていることを確認します。

Aug 25 17:14:10 freebsd10 ntpd[9743]: ntpd 4.2.8p8-a (1): Starting
Aug 25 17:14:10 freebsd10 ntpd[9744]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): good hash signature
Aug 25 17:14:10 freebsd10 ntpd[9744]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): loaded, expire=2017-06-01T00:00:00Z last=2017-01-01T00:00:00Z ofs=37

自動更新の仕組み

$daily_ntpd_leapfile_enableYES なら、1日1回 periodic daily により /etc/periodic/daily/480.leapfile-ntpd から service ntpd fetch が実行されます。
service ntpd fetchは以下のような動作を順にします。

  1. $ntp_db_leapfile より $ntp_src_leapfile が新しければ、$ntp_db_leapfile$ntp_src_leapfile で置き換える。
  2. $ntp_db_leapfile の有効期限が近づいたら、$ntp_leapfile_sources から最新ファイルを取得し、$ntp_db_leapfile より新しければ置き換える。

変数のデフォルト値は以下のように設定されています。

/etc/defaults/periodic.conf
daily_ntpd_leapfile_enable="NO"                         # Fetch NTP leapfile
/etc/defaults/rc.conf
ntp_src_leapfile="/etc/ntp/leap-seconds"
                                # Initial source for ntpd leapfile
ntp_db_leapfile="/var/db/ntpd.leap-seconds.list"
                                # Working copy (updated weekly) leapfile
ntp_leapfile_sources="https://www.ietf.org/timezones/data/leap-seconds.list"
                                # Source from which to fetch leapfile

自動更新が動作しない理由

FreeBSD 10.3-RELEASE の /etc/ntp/leap-seconds より https://www.ietf.org/timezones/data/leap-seconds.list の方がタイムスタンプが古いため、ダウンロードしたファイルで置き換えられません。

2016年8月25日時点では以下のようになっています。

source last update file expires
FreeBSD 10.3-RELEASE 3660508800 (2015-12-31) 3673728000 (2016-06-01)
FreeBSD 12.0-CURRENT 3676752000 (2016-07-06) 3705264000 (2017-06-01)
www.ietf.org 3629404800 (2015-01-05) 3691872000 (2016-12-28)

また、ca_root_nss パッケージがインストールされていない場合は、www.ietf.org アクセス時にサーバ証明書の検証に失敗し、ダウンロードされません。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
5