LoginSignup
2
2

More than 5 years have passed since last update.

NTP/UDPをport fowardingしてネットに出られない機器でもNTP同期させる

Last updated at Posted at 2015-02-06

CentOS7で実施。イントラの機器はNTPサーバ建てないと同期できないですよね。
しかしNTPサーバ自身が時刻狂ったら・・・と思うと外部のNTPサーバを利用したい。

sshだとUDPのport fowardingが出来ない。
stoneなら出来る。

stoneのビルド

cd /opt/
wget http://www.gcd.org/sengoku/stone/stone-2.3e.tar.gz
tar xzf stone-2.3e.tar.gz
cd stone-2.3d-2.3.2.7/

ビルドには-D_GNU_SOURCEを付ける必要がある。

Makefile
--- Makefile.org    2015-02-06 19:49:53.000000000 +0900
+++ Makefile    2015-02-06 19:50:17.000000000 +0900
@@ -97,7 +97,7 @@
    $(MAKE) FLAGS="-DNT_SERVICE $(FLAGS)" LIBS="$(LIBS) $(SVC_LIBS) -ladvapi32 -luser32 -lshell32 -lkernel32" $(TARGET)

 linux:
-   $(MAKE) FLAGS="-O -Wall -DCPP='\"/usr/bin/cpp -traditional\"' -DPTHREAD -DUNIX_DAEMON -DPRCTL -DSO_ORIGINAL_DST=80 -DUSE_EPOLL $(FLAGS)" LIBS="-lpthread $(LIBS)" stone
+   $(MAKE) FLAGS="-O -Wall -DCPP='\"/usr/bin/cpp -traditional\"' -DPTHREAD -DUNIX_DAEMON -DPRCTL -DSO_ORIGINAL_DST=80 -DUSE_EPOLL -D_GNU_SOURCE $(FLAGS)" LIBS="-lpthread $(LIBS)" stone

 linux-pop:
    $(MAKE) TARGET=linux pop_stone

参考: CentOSにstoneをインストールしてみた

ビルド

make linux

/opt/stone-2.3d-2.3.2.7/stone が生成される。

使い方

stone destinationhost:port port

/opt/stone-2.3d-2.3.2.7/stone 11.11.11.11:ntp/udp ntp/udp
  • 11.11.11.11:ntp/udp を0.0.0.0:ntp/udp にport forwarding

ciscoの機器

NTP同期できない状態

#show ntp associations detail
192.168.11.11 configured, insane, invalid, unsynced, stratum 16
ref ID 0.0.0.0, time 00000000.00000000 (09:00:00.000 JST Mon Jan 1 1900)
our mode client, peer mode unspec, our poll intvl 64, peer poll intvl 64
root delay 0.00 msec, root disp 0.00, reach 0, sync dist 0.000
delay 0.00 msec, offset 0.0000 msec, dispersion 16000.00
precision 2**5, version 3
org time 00000000.00000000 (09:00:00.000 JST Mon Jan 1 1900)
rcv time 00000000.00000000 (09:00:00.000 JST Mon Jan 1 1900)
xmt time AF3BD40B.4743EEB5 (09:15:07.278 JST Mon Mar 1 1993)
filtdelay =     0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00
filtoffset =    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00
filterror =  16000.0 16000.0 16000.0 16000.0 16000.0 16000.0 16000.0 16000.0
#show clock
*09:14:58.394 JST Mon Mar 1 1993

NTP同期できる状態

#show ntp associations detail
192.168.11.11 configured, our_master, sane, valid, stratum 2
ref ID 10.84.87.146, time D87F1D37.F4E3026A (20:00:07.956 JST Fri Feb 6 2015)
our mode client, peer mode server, our poll intvl 64, peer poll intvl 64
root delay 1.77 msec, root disp 0.06, reach 1, sync dist 15877.151
delay 2.40 msec, offset -0.4845 msec, dispersion 15875.02
precision 2**20, version 3
org time D87F1D5A.38416368 (20:00:42.219 JST Fri Feb 6 2015)
rcv time D87F1D5A.38AFA7C9 (20:00:42.221 JST Fri Feb 6 2015)
xmt time D87F1D5A.38104702 (20:00:42.218 JST Fri Feb 6 2015)
filtdelay =     2.40    0.00    0.00    0.00    0.00    0.00    0.00    0.00
filtoffset =   -0.48    0.00    0.00    0.00    0.00    0.00    0.00    0.00
filterror =     0.02 16000.0 16000.0 16000.0 16000.0 16000.0 16000.0 16000.0
#show clock
20:01:41.634 JST Fri Feb 6 2015
2
2
0

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
  3. You can use dark theme
What you can do with signing up
2
2