DynagenでCCIEを目指す
20100804 NTP
最終更新:
it_certification
-
view
1. 目的
- NTPの設定方法を確認します。
2. 構成
2.1. 設定概要
- ルータの初期設定はIPアドレスのみです。
- トップページ/手順書 サーバ系に基づいて、coLinuxがインストールされているものとします。
- トップページ/手順書 サーバ系に基づいて、Linux上にNTPサーバが構築されているものとします。
2.2. 構成図

2.3. netファイル
model = 3620 [localhost] [[3620]] image = C:\Program Files\Dynamips\images\c3620-j1s3-mz.123-18.bin ram = 128 [[ROUTER R1]] f0/0 = NIO_gen_eth:\Device\NPF_{colinux eth1} f1/0 = R2 f1/0 [[ROUTER R2]]
2.4. 初期設定
- R1
! ! Last configuration change at 06:59:48 UTC Wed Aug 4 2010 ! NVRAM config last updated at 06:59:49 UTC Wed Aug 4 2010 ! version 12.3 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R1 ! boot-start-marker boot-end-marker ! ! no aaa new-model ip subnet-zero ! ! no ip domain lookup ! ip cef ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface FastEthernet0/0 ip address 192.168.201.1 255.255.255.0 duplex auto speed auto ! interface FastEthernet1/0 ip address 192.168.12.1 255.255.255.0 duplex auto speed auto ! ip http server ip classless ! ! no cdp run ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 login ! ntp clock-period 17179864 ! end
- R2
! version 12.3 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R2 ! boot-start-marker boot-end-marker ! ! no aaa new-model ip subnet-zero ! ! no ip domain lookup ! ip cef ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface FastEthernet1/0 ip address 192.168.12.2 255.255.255.0 duplex auto speed auto ! ip http server ip classless ! ! no cdp run ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
3. [検証] Linuxサーバとの同期
3.1. NTPサーバの設定
R1で、上位のNTPサーバにLinuxサーバを指定します。以下の通りの入力を行います。
R1(config)#ntp server 192.168.201.101
3.2. NTPの確認
時刻確認とNTPで同期が取れているかの確認を行います。
時刻はあっていませんし、同期も取れていません。「show ntp associations detail」でinsane, invaildと表示される場合は同期が取れていない事を意味します。
時刻はあっていませんし、同期も取れていません。「show ntp associations detail」でinsane, invaildと表示される場合は同期が取れていない事を意味します。
R1#show clock *00:01:36.443 UTC Mon Mar 1 1993 R1# R1# R1# R1#show ntp associations detail 192.168.201.101 configured, insane, invalid, unsynced, stratum 16 ref ID 0.0.0.0, time 00000000.00000000 (00:00:00.000 UTC 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 D00347D6.B3301AEF (01:58:46.699 UTC Wed Aug 4 2010) rcv time AF3BD0AF.334084E4 (00:00:47.200 UTC Mon Mar 1 1993) xmt time AF3BD0AF.27EF672C (00:00:47.155 UTC 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 R1#
3.3. NTPの再確認
7,8分経つと、NTPサーバと同期が取れた事が確認できます。
R1#show clock 07:04:59.798 UTC Wed Aug 4 2010 R1# R1# R1# R1#show ntp associations detail 192.168.201.101 configured, our_master, sane, valid, stratum 2 ref ID 133.243.238.243, time D0036F00.6843CCD3 (04:45:52.407 UTC Wed Aug 4 2010) our mode client, peer mode server, our poll intvl 64, peer poll intvl 64 root delay 109.82 msec, root disp 309.72, reach 377, sync dist 369.705 delay 2.59 msec, offset -28.8116 msec, dispersion 3.78 precision 2**7, version 3 org time D0038F9D.61F3A288 (07:05:01.382 UTC Wed Aug 4 2010) rcv time D0038F9D.6A325291 (07:05:01.414 UTC Wed Aug 4 2010) xmt time D0038F9D.6506DEAA (07:05:01.394 UTC Wed Aug 4 2010) filtdelay = 19.91 23.44 14.94 4.78 3.94 2.59 4.65 5.54 filtoffset = -22.25 -12.16 -23.29 -29.05 -29.49 -28.81 -28.86 -28.41 filterror = 0.02 0.99 1.97 2.94 2.96 2.98 2.99 3.01 R1#
「show ntp associations」と入力するとより簡易な表示が得られます。*が現在同期しているNTPサーバを表します。
R1#show ntp associations address ref clock st when poll reach delay offset disp *~192.168.201.101 133.243.238.243 2 1 64 376 7.1 -29.91 6.6 * master (synced), # master (unsynced), + selected, - candidate, ~ configured R1#
3.4. タイムゾーンの設定
LinuxのハードウェアクロックがUTCになっている場合は、UTCで時刻が同期されます。タイムゾーンの設定をするためには、以下のようなコマンドを入力します。
R1(config)#clock timezone JPN +9 R1(config)#^Z R1# Aug 4 07:14:24.624: %SYS-5-CONFIG_I: Configured from console by console R1# R1#show clock 16:14:29.884 JPN Wed Aug 4 2010 R1#
3.5. R2の設定
R2の上位NTPサーバとして、R1を指定します。
R2(config)#ntp server 192.168.12.1 R2(config)#clock timezone JPN +9 R2#show clock 16:23:18.149 JPN Wed Aug 4 2010 R2# R2# R2# R2#show ntp associations address ref clock st when poll reach delay offset disp *~192.168.12.1 192.168.201.101 3 38 64 377 51.9 13.14 37.7 * master (synced), # master (unsynced), + selected, - candidate, ~ configured R2#
4. [検証] Ciscoルータとの同期
4.1. 設定削除
「3. [検証] Linuxサーバとの同期」で投入した設定を削除します。
4.2. R1の設定
R1を上位のNTPサーバをして設定します。
以下の要領で現在時刻を設定します。
以下の要領で現在時刻を設定します。
R1#clock set 19:48:00 4 Aug 2010 R1# R1#show clock .19:48:03.195 UTC Wed Aug 4 2010 R1#
NTPサーバのstratum値を設定します。なお、「ntp master」と入力しstratum値を省略した場合は、stratum値として8が設定されます。
R1(config)#ntp master 8
4.3. R2の設定
R2(config)#ntp server 192.168.12.1
4.4. 同期確認
「*」マークが付加されている事により、NTPサーバと同期している事が確認できます。
R2#show ntp associations address ref clock st when poll reach delay offset disp *~192.168.12.1 127.127.7.1 8 56 64 3 72.0 5.99 7882.1 * master (synced), # master (unsynced), + selected, - candidate, ~ configured R2#
5. [検証] broadcastによる設定
5.1. 設定削除
「4. [検証] Ciscoルータとの同期」で投入した設定を削除します。
5.2. R1の設定
ユニキャストではなく、マルチキャストやブロードキャストを用いてNTPの同期を取る事も可能です。ブロードキャストを用いて、R1とR2を同期されるシナリオを想定します。
上位NTPサーバであるR1には以下のような設定を投入します。検証2と異なり、I/Fに対して設定が必要になります。
上位NTPサーバであるR1には以下のような設定を投入します。検証2と異なり、I/Fに対して設定が必要になります。
R1(config)#interface FastEthernet 1/0 R1(config-if)#ntp broadcast
5.3. R2の設定
R2には以下の設定を投入します。
R2(config)#interface FastEthernet 1/0 R2(config-if)#ntp broadcast client
5.4. 同期確認
「*」マークが付加されている事により、NTPサーバと同期している事が確認できます。
R2#show ntp associations address ref clock st when poll reach delay offset disp *~192.168.12.1 127.127.7.1 8 56 64 3 72.0 5.99 7882.1 * master (synced), # master (unsynced), + selected, - candidate, ~ configured R2#
6. [検証] peerによる同期
6.1. 設定削除
「5. [検証] broadcastによる設定」で投入した設定を削除します。
6.2. R1, R2の設定
上位NTPサーバとではなく、ルータ同士が互いに同期を取る事も可能です。例えば、インターネットに接続できない環境などで使用します。(実際は、Linuxサーバ同士が同期する事が多いですが)
R1(config)#ntp peer 192.168.12.2 R2(config)#ntp peer 192.168.12.1
6.3. 同期確認
show ntp associationsコマンドを発行します。「*」マークがつかないので、一見同期していないように見えますが、全く問題ありまん。(peerモードはshow ntp associationsコマンドで確認できないようです)
R1#show ntp associations address ref clock st when poll reach delay offset disp ~192.168.12.2 192.168.12.1 9 26 64 200 55.7 0.94 16000. * master (synced), # master (unsynced), + selected, - candidate, ~ configured R1# R2#show ntp associations address ref clock st when poll reach delay offset disp ~192.168.12.1 127.127.7.1 16 44 64 0 64.1 15.60 16000. * master (synced), # master (unsynced), + selected, - candidate, ~ configured R2#
R1, R2の現在時刻を表示すると、時刻はほぼ一致しており同期が取れている事が確認できます。
R1#show clock .09:44:39.403 UTC Thu Aug 5 2010 R1# R2#show clock .09:44:40.680 UTC Thu Aug 5 2010 R2#
デバッグメッセージを見ると、少しずつ時刻が調整されていく様子が読み取れます。
R2#debug ntp adjust NTP clock adjustments debugging is on R2# Aug 5 09:35:37.920: NTP: adj(0.000000224), rem. offset = 0.000000000, adj = 0.000000224 Aug 5 09:35:38.920: NTP: adj(0.000000220), rem. offset = 0.000000000, adj = 0.000000220 Aug 5 09:35:39.920: NTP: adj(0.000000217), rem. offset = 0.000000000, adj = 0.000000217 Aug 5 09:35:40.920: NTP: adj(0.000000214), rem. offset = 0.000000000, adj = 0.000000214 Aug 5 09:35:41.920: NTP: adj(0.000000210), rem. offset = 0.000000000, adj = 0.000000210 Aug 5 09:35:42.920: NTP: adj(0.000000207), rem. offset = 0.000000000, adj = 0.000000207 Aug 5 09:35:43.920: NTP: adj(0.000000204), rem. offset = 0.000000000, adj = 0.000000204 Aug 5 09:35:44.920: NTP: adj(0.000000201), rem. offset = 0.000000000, adj = 0.000000201 Aug 5 09:35:45.920: NTP: adj(0.000000197), rem. offset = 0.000000000, adj = 0.000000197 Aug 5 09:35:46.920: NTP: adj(0.000000194), rem. offset = 0.000000000, adj = 0.000000194 Aug 5 09:35:47.920: NTP: adj(0.000000191), rem. offset = 0.000000000, adj = 0.000000191 Aug 5 09:35:48.920: NTP: adj(0.000000188), rem. offset = 0.000000000, adj = 0.000000188
7. [補足] デバッグメッセージ
7.1. デバッグメッセージの確認
NTPは同期が取れるまで時間がかかります。待つのが面倒な場合は、デバッグメッセージを有効にする事で同期が開始された事を確認する事ができます。
R2#debug ntp packets NTP packets debugging is on R2#debug ntp adjust NTP clock adjustments debugging is on R2#debug ntp events NTP events debugging is on R2# R2# R2# *Aug 5 09:25:14.995: NTP: peer stratum change *Aug 5 09:25:14.995: NTP: clock reset .Aug 5 09:25:15.871: NTP: xmit packet to 192.168.12.1: .Aug 5 09:25:15.871: leap 3, mode 3, version 3, stratum 0, ppoll 64 .Aug 5 09:25:15.875: rtdel 1A9B (103.928), rtdsp 30E288F5 (12514534.988), refid C0A80C01 (192.168.12.1) .Aug 5 09:25:15.875: ref AF3BD129.51EAC158 (00:02:49.319 UTC Mon Mar 1 1993) .Aug 5 09:25:15.875: org 00000000.00000000 (00:00:00.000 UTC Mon Jan 1 1900) .Aug 5 09:25:15.875: rec 00000000.00000000 (00:00:00.000 UTC Mon Jan 1 1900) .Aug 5 09:25:15.875: xmt D00501FB.DF39486E (09:25:15.871 UTC Thu Aug 5 2010) .Aug 5 09:25:15.935: NTP: rcv packet from 192.168.12.1 to 192.168.12.2 on FastEthernet1/0: .Aug 5 09:25:15.939: leap 0, mode 4, version 3, stratum 8, ppoll 64 .Aug 5 09:25:15.939: rtdel 0000 (0.000), rtdsp 0002 (0.031), refid 7F7F0701 (127.127.7.1) .Aug 5 09:25:15.939: ref D00501DB.6B85AB76 (09:24:43.420 UTC Thu Aug 5 2010) .Aug 5 09:25:15.939: org D00501FB.DF39486E (09:25:15.871 UTC Thu Aug 5 2010) .Aug 5 09:25:15.939: rec D00501FB.ED8EB340 (09:25:15.927 UTC Thu Aug 5 2010) .Aug 5 09:25:15.939: xmt D00501FB.ED8EB340 (09:25:15.927 UTC Thu Aug 5 2010) .Aug 5 09:25:15.939: inp D00501FB.EFA5FFE8 (09:25:15.936 UTC Thu Aug 5 2010) .Aug 5 09:25:15.939: NTP: 192.168.12.1 reachable Aug 5 09:25:15.939: NTP: sync change Aug 5 09:25:15.939: NTP: peer stratum change Aug 5 09:25:16.871: NTP: adj(0.000373616), rem. offset = 0.000000000, adj = 0.000373616 Aug 5 09:25:17.872: NTP: adj(0.000367778), rem. offset = 0.000000000, adj = 0.000367778 Aug 5 09:25:18.872: NTP: adj(0.000362032), rem. offset = 0.000000000, adj = 0.000362032 Aug 5 09:25:19.873: NTP: adj(0.000356375), rem. offset = 0.000000000, adj = 0.000356375 Aug 5 09:25:20.873: NTP: adj(0.000350806), rem. offset = 0.000000000, adj = 0.000350806 Aug 5 09:25:21.873: NTP: adj(0.000345325), rem. offset = 0.000000000, adj = 0.000345325 Aug 5 09:25:22.874: NTP: adj(0.000339929), rem. offset = 0.000000000, adj = 0.000339929 Aug 5 09:25:23.874: NTP: adj(0.000334618), rem. offset = 0.000000000, adj = 0.000334618 Aug 5 09:25:24.874: NTP: adj(0.000329390), rem. offset = 0.000000000, adj = 0.000329390 Aug 5 09:25:25.875: NTP: adj(0.000324243), rem. offset = 0.000000000, adj = 0.000324243 Aug 5 09:25:26.875: NTP: adj(0.000319177), rem. offset = 0.000000000, adj = 0.000319177 Aug 5 09:25:27.875: NTP: adj(0.000314189), rem. offset = 0.000000000, adj = 0.000314189 Aug 5 09:25:28.876: NTP: adj(0.000309280), rem. offset = 0.000000000, adj = 0.000309280 Aug 5 09:25:29.876: NTP: adj(0.000304448), rem. offset = 0.000000000, adj = 0.000304448 Aug 5 09:25:30.876: NTP: adj(0.000299691), rem. offset = 0.000000000, adj = 0.000299691
添付ファイル