ntp.confでIPv6のアドレス空間2001:db8:feed:cafe::/64を対象に
restrict 192.0.2.32 mask 255.255.255.224 nopeer notrapに相当する設定をしようと思いました。
さて、どう書きゃいいんだ? とman ntp.confしてみました。しかし、かねてから(ntp.orgの実装の)ntpのリファレンスマニュアルって、どうもかゆいところに手が届かないという個人の感想をいだいていたんですが、今回も
restrict address [mask mask] [flag ...]
(略)The mask argument expressed in dotted-quad form defaults to 255.255.255.255, meaning that the address is treated as the address of an individual host.(略)と、ダメだこりゃ。次、いってみよう! な説明。
これはマニュアルがコードに追いついていないのかも、とhttp://www.ntp.org/ → Documentation → Official NTP Documentation → Access Control Supportを見ると restrict address [mask mask] [flag][...]
(略)The mask argument expressed in IPv4 or IPv6 numeric address form defaults to all mask bits on, meaning that the address is treated as the address of an individual host.(略)と、お前、それはないだろぉ、な説明。
配布元のドキュメントに頼れないなら先人の知見に頼るか、と検索してみたんですが、どうも思わしい情報が得られませんでした。仕方ないので、当てずっぽで試してみることにしました。たしかアドレスの前に-6って書くんだったよなぁ、maskって言われても128bit分のビットマップを書くなんて、他の設定ファイルじゃないよなぁ、と、まず試してみたのが
restrict -6 2001:db8:feed:cafe::/64 nopeer notrapです。
ところがntpdを再起動してみると、/var/log/messagesに
restrict: ignoring line 16, address/host '2001:db8:feed:cafe::/64' unusable.というメッセージが出ています。
それでは、と
restrict -6 2001:db8:feed:cafe:: mask 64 nopeer notrapと書いて見たところ、今度は
line 15 column 27 syntax error, unexpected T_Mask, expecting T_EOCというメッセージが出ました。
syntax error in /etc/ntp.conf line 15, column 27
restrict -6 [2001:db8:feed:cafe::/64] nopeer notrap
restrict [2001:db8:feed:cafe::] mask 64 nopeer notrapなどと思いつく限りに手当たり次第試してみたんですが、どうにもダメです。
うーん、もう1回やってみるか、と、キーワードを取っ替えひっかえしながら検索してみたところ、URLを控えておくのを忘れてしまったんですが、maskを先入観で避けていたビットマップで書いているページがあったので
restrict -6 2001:db8:feed:cafe:: mask ffff:ffff:ffff:ffff:: nopeer notrapとしてみたんすが、やっぱりダメです。そこで-6をとってみるか、と
restrict 2001:db8:feed:cafe:: mask ffff:ffff:ffff:ffff:: nopeer notrapだとエラーは出なくなりました。
# ntpq -c reslistを実行してみると
: 0 2001:db8:feed:cafe::/64 nopeer notrap :と、意図通りに解釈されていることも確認できました。