Red Hat Linux 7.3 における ntp の設定

/etc/ntp.conf に以下の6行を追加するのが正しいようだ。

restrict 210.173.160.27 mask 255.255.255.255 nomodify notrap noquery
server 210.173.160.27
restrict 210.173.160.57 mask 255.255.255.255 nomodify notrap noquery
server 210.173.160.57
restrict 210.173.160.87 mask 255.255.255.255 nomodify notrap noquery
server 210.173.160.87

restrict 指定されているので、ちゃんと設定しないとあらゆる同期できないのだ。ntpq の結果は以下のような感じとなる。

$ /usr/sbin/ntpq -pn
      remote           refid      st t when poll reach   delay   offset  jitter
 ==============================================================================
 +210.173.160.27  133.243.236.19   2 u  413 1024  213   15.952   -0.697   0.079
 +210.173.160.57  133.243.236.18   2 u  330 1024  373   14.798   -0.074   0.431
 *210.173.160.87  133.243.236.18   2 u  494 1024  377   15.599    0.258   0.243
 127.127.1.0     127.127.1.0     10 l   28   64  377    0.000    0.000   0.008

* ちなみに Debian では

dpkg-reconfigure であうあうして、 /etc/default/ntp-servers を以下の感じに。

NTPSERVERS="ntp1.jst.mfeed.ad.jp ntp2.jst.mfeed.ad.jp ntp3.jst.mfeed.ad.jp"
$ ntpq -pn 
     remote           refid      st t when poll reach   delay   offset  jitter
 ==============================================================================
 +210.173.160.27  133.243.236.19   2 u  52m 1024  130   15.368   -1.854   0.317
 +210.173.160.57  133.243.236.19   2 u  511 1024  253   16.513   -2.487   0.841
 *210.173.160.87  133.243.236.19   2 u  480 1024  377   14.945   -1.293   0.140

* cron.dairy

てなわけで、cron.daily.pl で今日の時計も載せることにした。

#!/usr/bin/perl
@montable = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
$time=time()-86400;
($year, $mon, $day) = (localtime($time))[5,4,3];
$cmd=sprintf('sudo grep "%s %2d" /var/log/kern.log|grep ppp0|grep -v output|', $montable[$mon], $day);
$file=sprintf('/home/tnh/diary/%04d/d%04d%02d%02d.hnf', $year+1900, $year+1900, $mon+1, $day);
unless(-e $file){
	open(FL,">$file");
	print FL "OK\n";
	print FL "\n";
	print FL "CAT 睡眠\n";
	print FL "NEW 起床\n";
	close(FL);
}
open(FL,$cmd);
@datas=<FL>;
close(FL);
open(FL,">>$file");
print FL "\n";
print FL "CAT Linux\n";
print FL "NEW 今日のパケット\n";
print FL "\n";
if(@datas){
	print FL "PRE\n";
	foreach(@datas){
		if(/:1433/){
			++$n1433;
		}else{
			print FL;
		}
	}
	print FL "/PRE\n";
	if($n1433){
		print FL "\n";
		print FL "P\n";
		print FL "その他 1433 へのアクセス $n1433 件。\n";
		print FL "/P\n";
	}
}else{
	print FL "P\n";
	print FL "平和\n";
	print FL "/P\n";
}
open(RL,'ntpq -pn |');
@datas=<RL>;
close(RL);
print FL "\n";
print FL "CAT Linux\n";
print FL "NEW 今日の時計\n";
print FL "\n";
print FL "PRE\n";
print FL '$ ntpq -pn'."\n";
foreach(@datas){
	print FL;
}
print FL "/PRE\n";
close(FL);