
R1(config)#ntp master 5
R1 sẽ làm server chính cho việc đồng bộ clock cho các server hoặc client khác có stratum lớn hơn 5. Càng có stratum nhỏ thì càng tốt.
R1#sh ntp status
Clock is synchronized, stratum 5, reference is 127.127.7.1
nominal freq is 250.0000 Hz, actual freq is 250.0000 Hz, precision is 2**18
reference time is C029436F.1BA81609 (00:01:51.108 UTC Fri Mar 1 2002)
clock offset is 0.0000 msec, root delay is 0.00 msec
root dispersion is 0.02 msec, peer dispersion is 0.02 msec
Điều quan trọng là ta nên chỉnh giờ trên con master clock trước khi áp lệnh ntp master vào.
Vì nếu làm ngược lại do IOS nên có thể không đồng bộ giờ được.
Nếu không đồng bộ giờ được thì ta “no ntp master 5” rồi sau đó“ntp master 5”
R2(config)#ntp server 192.168.12.1
R2 sẽ làm client đồng bộ với server có IP 192.168.12.1
R2#sh ntp status
Clock is synchronized, stratum 6, reference is 192.168.12.1
nominal freq is 250.0000 Hz, actual freq is 250.0000 Hz, precision is 2**18
reference time is CD94F775.14EE804C (01:05:57.081 UTC Sun Apr 19 2009)
clock offset is -13.7100 msec, root delay is 20.05 msec
root dispersion is 36.85 msec, peer dispersion is 23.10 msec
R2#sh ntp associations detail
192.168.12.1 configured, our_master, sane, valid, stratum 5
ref ID 127.127.7.1, time CD94F761.DF42B56A (01:05:37.872 UTC Sun Apr 19 2009)
our mode client, peer mode server, our poll intvl 64, peer poll intvl 64
root delay 0.00 msec, root disp 0.03, reach 377, sync dist 33.157
delay 20.05 msec, offset -13.7100 msec, dispersion 23.10
precision 2**24, version 3
org time CD94F775.073612ED (01:05:57.028 UTC Sun Apr 19 2009)
rcv time CD94F775.14EE804C (01:05:57.081 UTC Sun Apr 19 2009)
xmt time CD94F775.017195D6 (01:05:57.005 UTC Sun Apr 19 2009)
filtdelay = 76.11 44.04 36.07 20.05 92.13 48.13 32.12 36.10
filtoffset = -15.54 -25.68 -13.76 -13.71 6.06 -7.77 20.23 18.21
filterror = 0.02 0.99 1.01 1.02 1.04 1.05 1.07 1.08
R1(config-if)#ntp broadcast destination 192.168.12.1
R1 sẽ không gửi packet đồng bộ thời gian cho router có IP 192.168.12.1.
R2 đồng bộ cho R3
R3#sh clock
*00:10:30.759 UTC Fri Mar 1 2002
R2(config)#ntp authenticate
R2(config)#ntp authentication-key 1 md5 cisco
R2(config)#ntp trusted-key 1
R3(config)#ntp authenticate
R3(config)#ntp authentication-key 1 md5 cisco
R3(config)#ntp trusted-key 1
R3(config)#ntp peer 192.168.23.2
Nhớ là chỉ được peer một bên thôi, peer 2 bên cùng lúc không chạy.
Trong mối quan hệ peer thì một bên là active, một bên là passive.
R3 là active với “ntp peer”, còn R2 là passive nó sẽ lắng nghe trên NTP port và sẽ hình thành mối quan hệ neighbor với R3.
R3#sh clock
01:19:09.373 UTC Sun Apr 19 2009
R3#sh ntp status
Clock is synchronized, stratum 7, reference is 192.168.23.2 [stratum của R3]
nominal freq is 250.0000 Hz, actual freq is 249.9996 Hz, precision is 2**18
reference time is CD94FA8C.EDE6E94E (01:19:08.929 UTC Sun Apr 19 2009)
clock offset is 21.2817 msec, root delay is 100.25 msec
root dispersion is 69.26 msec, peer dispersion is 28.17 msec
R3#sh ntp associations detail
192.168.23.2 configured, our_master, sane, valid, stratum 6 => R3 đang đồng bộ với router có stratum 6 [R2]
ref ID 192.168.12.1, time CD94FA75.108C65C0 (01:18:45.064 UTC Sun Apr 19 2009)
our mode active, peer mode passive, our poll intvl 64, peer poll intvl 64
root delay 72.13 msec, root disp 19.82, reach 377, sync dist 98.114
delay 28.12 msec, offset 21.2817 msec, dispersion 28.17
precision 2**18, version 3
org time CD94FA8C.DA6E91FD (01:19:08.853 UTC Sun Apr 19 2009)
rcv time CD94FA8C.EDE6E94E (01:19:08.929 UTC Sun Apr 19 2009)
xmt time CD94FA8C.D028D7E3 (01:19:08.813 UTC Sun Apr 19 2009)
filtdelay = 112.35 60.26 140.17 100.34 28.12 71.99 92.18 92.18
filtoffset = -19.87 -12.08 9.69 -15.08 21.28 3.40 13.36 17.43
filterror = 0.02 0.99 1.97 2.94 3.92 3.94 3.95 3.97
R2#sh ntp status
Clock is synchronized, stratum 6, reference is 192.168.12.1
nominal freq is 250.0000 Hz, actual freq is 250.0003 Hz, precision is 2**18
reference time is CD94FAF5.11CB3507 (01:20:53.069 UTC Sun Apr 19 2009)
clock offset is -4.0551 msec, root delay is 76.14 msec
root dispersion is 18.74 msec, peer dispersion is 14.65 msec
R2#sh ntp associations detail
192.168.12.1 configured, our_master, sane, valid, stratum 5
ref ID 127.127.7.1, time CD94FAE1.DF38AF6F (01:20:33.871 UTC Sun Apr 19 2009)
our mode client, peer mode server, our poll intvl 64, peer poll intvl 64
root delay 0.00 msec, root disp 0.03, reach 377, sync dist 52.750
delay 76.14 msec, offset -4.0551 msec, dispersion 14.65
precision 2**24, version 3
org time CD94FAF5.0C5096F5 (01:20:53.048 UTC Sun Apr 19 2009)
rcv time CD94FAF5.11CB3507 (01:20:53.069 UTC Sun Apr 19 2009)
xmt time CD94FAF4.FD47435A (01:20:52.989 UTC Sun Apr 19 2009)
filtdelay = 80.12 76.14 76.14 76.02 72.13 80.12 71.95 91.92
filtoffset = 18.66 -4.06 5.55 -0.78 10.74 1.86 13.04 18.12
filterror = 0.03 1.01 1.98 2.96 3.94 4.91 5.89 6.87
Thêm:
R2(config)#ntp source loopback 0
Các packet NTP xuất phát từ R2 sẽ có địa chỉ source của loopback.[Bình thường là địa chỉ source của connected mà các gói NTP đi ra]
Nếu muốn chính xác đồng hóa với những host nào tao có thể dùng
R3(config)#ntp access-group peer 1
Với 1 là access-list 1. Cho phép R3 chỉ đồng bộ hóa với những router nằm trong ACL 1.
R2(config)#ntp server 192.168.12.1 key 1 prefer
R2(config)#ntp server 10.0.0.1 key
Nếu trong Domain có nhiều NTP master ta có thể dùng lệnh này để chọn những server nào muốn đồng bộ.
Comment