今回はCiscoルータをNTPサーバに接続し、時刻同期をしてみたいと思います。
検証環境

Ciscoルータ1台、NTP用のサーバ1台用意しました。
NTPサーバのIPアドレスは「192.168.1.100/24」、CiscoルータのIPアドレスを「192.168.1.1/24」に設定し、その間を接続した際に時刻同期できるのをゴールにしたいと思います。
Ciscoルータの初期設定
Router#show running-config
Building configuration...
Current configuration : 553 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
!
!
!
!
!
!
!
ip cef
no ipv6 cef
!
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface FastEthernet0/0
no ip address
duplex auto
speed auto
shutdown
!
interface FastEthernet0/1
no ip address
duplex auto
speed auto
shutdown
!
interface Vlan1
no ip address
shutdown
!
ip classless
!
ip flow-export version 9
!
!
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
login
!
!
!
end
ちなみに、現段階での「show clock」をこんな感じです。
この出鱈目な時刻が正常な時刻に変化するのをみていきたいと思います。
Router#show clock
*0:22:23.21 UTC Mon Mar 1 1993
Router#
Ciscoルータの設定
まずはNTPサーバに接続するインタフェースの設定を行います。
IPアドレスは「192.168.1.1/24」に設定し、「no shutdown」をしてインターフェースを解放します。
Router(config)#
Router(config)#interface fastEthernet 0/0
Router(config-if)#ip address 192.168.1.1 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
Router(config-if)#exit
Router(config)#
CiscoルータをNTPクライアントにするため、「ntp server」コマンドを投入します。NTPサーバのIPアドレスは「192.168.1.100」です。
Router(config)#
Router(config)#ntp server 192.168.1.100
Router(config)#
この一行でNTPサーバと同期する最低限の設定は完了です。
動作確認
では、動作確認をしてみます。NTPサーバと同期できているかを確認するためには「show ntp associations」コマンドをします。
すると、下記のような表記になります。
Router#show ntp associations
address ref clock st when poll reach delay offset disp
~192.168.1.100 127.127.1.1 1 4 16 77 0.00 939921706866.00 0.12
* sys.peer, # selected, + candidate, - outlyer, x falseticker, ~ configured
Router#
その時の「show clock」は下記の通りです。
Router#show clock
*0:34:12.321 UTC Mon Mar 1 1993
Router#
ご覧いただいて分かる通り、まだ同期できていません。
「show ntp associations」の結果で分かる通り、設定自体は入っていますが、NTPはTCPなので同期ができるようになるためには少し時間がかかります。
その後、2分ほど待った結果は下記の通りです。
Router#
Router#show ntp associations
address ref clock st when poll reach delay offset disp
*~192.168.1.100 127.127.1.1 1 11 16 3 0.00 0.00 0.12
* sys.peer, # selected, + candidate, - outlyer, x falseticker, ~ configured
Router#
Router#show clock
17:56:47.35 UTC Mon Dec 12 2022
Router#
ちゃんと時刻同期できていることが分かります。
先ほどとの違いはNTPサーバのIPアドレス「192.168.1.100」の左側に「✳︎」がついたことです。このマークがついたことで時刻同期できていることを確認できます。
最後に
ネットワーク機器に障害が発生した際に「いつどの機器で障害が起き、どのくらいの影響があったのか」を調べるために全ネットワーク機器で時刻を合わせておく必要があります。
たった一行の設定ですが、必須の設定と言えます。
今回はCiscoルータをNTPサーバに接続して時刻同期させる記事でしたが、Ciscoルータ自身をNTPサーバにする記事も記載したのでよかったら見てみてください。

コメント