Jeremy’s IT Lab lecture video:
Commands
Commands List
NTP Show Commands
13. NTP
Link to original
- show clock
-->Shows basic clock information- show clock detail
-->Shows the time source (hardware calendar by default) and basic clock information- show ntp status
-->Shows general NTP information like stratum level and IP address of the connected time syncing server- show ntp associations
-->Shows the NTP servers the device is syncing toNTP Configuration Commands (Privileged EXEC)
NTP Privileged
Link to original
- clock set hh:mm:ss day month year
-->Sets the device’s software clock (day and month can be swapped around)- calendar set hh:mm:ss day month year
-->Sets the device’s hardware clock (day and month can be swapped around)- clock update-calendar
-->Syncs the calendar (hardware clock) to the clock’s (software clock) time- clock read-calendar
-->Syncs the clock (software time) to the calendar’s (hardware clock) timeNTP Configuration Commands (Global)
NTP Global
Link to original
- clock timezone timezone-name hours-offset [minutes-offset]
-->Changes the clock’s timezone to a user specified timezone name with an hours offset, and an optional minutes offset- clock summer-time name recurring start end [offset]
-->Sets the daylight saving time (summer time) configuration for the clock
- (start and end each require the week (first, last or number), weekday, month and time)
- ntp update-calendar
-->Updates the calendar (hardware clock) using NTP- ntp server ip-address [prefer]
-->Configures an NTP server that the client will sync to- ntp server ip-address key key-number
-->Configures an NTP server that the client will sync to along with the authentication key number- ntp peer ip-address
-->Sets up symmetric active peering mode with another NTP server- ntp peer ip-address key key-number
-->Sets up symmetric active peering mode with another NTP server along with the authentication key number- ntp master [stratum-level]
-->Configures the device as an NTP server with an optional stratum level argument (Defaults to stratum 8)- ntp source interface-id
-->Changes the source of NTP messages to be that of the specified interface- ntp authenticate
-->Enables NTP authentication- ntp authentication-key key-number md5 key/password
-->Configures an NTP authentication key- ntp trusted-key key-number
-->Trusts the NTP key number on the current device
NTP Info
General Information
All devices have two types of clocks, software (clock) and hardware (calendar) clocks.
- Software clock (aka. Clock) runs digitally on the operating system of the device.
- Hardware clock (aka. Calendar) is an internal physical clock built into the device.
- The default time zone for Cisco devices is UTC (Coordinated Universal Time)
- The most important reason to have accurate time on a device is to have accurate logs for troubleshooting. (with
show logging)
The calendar of a device tracks the date and time on the device even if it restarts, power is lost, etc. When the system is restarted the calendar is used to initialize the clock. The calendar does have a flaw though, and it’s that it will drift over time and become inaccurate, so it is not an ideal time source. That’s why the Network Time Protocol (NTP) is used to mitigate this problem.
Clock and Calendar Commands
Clock/Calendar Show Commands
show clock- You can view basic details about the clock through this command.
- It’ll display the current time.
- Sometimes, an asterisk ( * ) will be displayed to indicate that the time is not authoritative (not from a trusted source)
show clock detail- Using this command will show the previous information as well as the time source (set to the hardware calendar by default)
Clock/Calendar Config Commands
clock set HH:MM:SS DAY MONTH YEAR- You can use this command to manually configure the clock on the device.
calendar set HH:MM:SS DAY MONTH YEAR- You can also use this command to manually configure the calendar on the device.
- You can also use this command to manually configure the calendar on the device.
- Typically, you will want to synchronize both the clock and calendar, which can be done through two commands:
clock update-calendarto sync the calendar to the clock’s time.clock read-calendarto sync the clock to the calendar’s time.
clock timezone TIMEZONE-NAME HOURS-OFFSET [MINUTES-OFFSET]- The time zone can be configured with this command.
clock summer-time TIMEZONE-NAME recurring START END [OFFSET]- The daylight savings time (summer time) can be configured with this command.
- The default offset is 60 minutes, but it can be specified at the end if it’s necessary to change it.
- (start and end each require the week (first, last or number), weekday, month and time)
Network Time Protocol (NTP)
Network Time Protocol (NTP) is a protocol that allows automatic syncing of time over a network.
- It communicates over UDP port 123.
- NTP uses the UTC time zone by default. The appropriate time zone must be configured on each device.
- NTP clients request the time from NTP servers.
- A device can be an NTP client and an NTP server at the same time.
Stratum Levels
Some NTP servers are better (more reliable) than others. That is determined through a factor which is called stratum level and it defines the ‘distance’ of an NTP server from the original reference clock.
The stratum level range is (1 - 16), however, we start counting from (stratum 0).
Reference Clocks
A reference clock is usually a very accurate time device like an atomic clock or GPS clock. They are assigned stratum (0) within the NTP hierarchy.
- NTP servers connected directly to reference clocks are stratum 1.
NTP Hierarchy
- Reference clocks are stratum (0).
- Stratum (1) NTP servers get their time from reference clocks.
- Stratum (2) NTP servers get their time from stratum (1) NTP servers.
- Stratum (3) NTP servers get their time from stratum (2) NTP servers.
- Stratum (15) is the maximum. Anything above that is considered unreliable.
- Devices can also ‘peer’ with devices at the same stratum to become in a symmetric active mode in order to provide more accurate time.
Cisco NTP operational modes
Cisco devices can operate in three NTP modes:
- Server mode
- Client mode
- Symmetric Active mode
Stratum level names
- NTP servers which get their time directly from reference clocks are also referred to as ‘primary servers’
- NTP servers which get their time from other NTP servers are referred to as ‘secondary servers’. They operate in server mode and client mode at the same time.
NTP Configurations
NTP Show Commands
show ntp associations- Shows connected NTP servers
- It’ll show you a bunch of information for each server like:
- The address of the NTP servers the device is connected to along with a symbol to indicate the status.
- Their reference clocks
- Their stratum level
show ntp status- Shows information about the current NTP instance running on the device
- It includes this info:
- The current device’s stratum level.
- The IP of the NTP server which is being used as reference.
NTP Config Commands
ntp server IP-ADDRESS [prefer]- Forms a connection to an NTP server.
ntp server IP-ADDRESS key KEY-NUMBER- Forms a connection to an NTP server with an authentication key.
ntp peer IP-ADDRESS- Forms a symmetric active connection with another NTP device. Both devices will have the same stratum level.
ntp peer IP-ADDRESS key KEY-NUMBER- Forms a peering to another NTP device with an authentication key.
clock timezone TIMEZONE-NAME HOURS-OFFSET [MINUTES-OFFSET]- Allows you to configure the time zone on the current device.
clock summer-time NAME recurring START END [OFFSET]- Sets the daylight saving time (summer time) configuration for the clock.
- The default offset is 60 minutes, but it can be specified at the end if it’s necessary to change it.
- (start and end each require the week (first, last or number), weekday, month and time)
ntp source INTERFACE-ID- Lets you assign the interface which the NTP messages will source/originate from.
ntp master [STRATUM]- This will assign the current device as an NTP server with an optional stratum level.
- If the stratum level is not specified, it will default to 8 (displayed as 7 in the show commands, because stratum levels begin counting from 0)
ntp authenticate- Enables NTP authentication on the device.
ntp authentication-key KEY-NUMBER md5 KEY/PASSWORD- Initializes an NTP key number along with a password assigned to it.
ntp trusted-key KEY-NUMBER- Trusts an NTP key for it to be used in authentications.
Jeremy’s IT Lab előadásvideó:
Parancsok
Parancslista
NTP Show Parancsok
13. NTP
Eredeti hivatkozása
- show clock
-->Alapvető órainformációkat mutat- show clock detail
-->Megmutatja az időforrást (alapértelmezetten a hardveres naptár) és az alap óraadatokat- show ntp status
-->Általános NTP információkat mutat, mint a stratum szint és a szinkronizált szerver IP címe- show ntp associations
-->Listázza azokat az NTP szervereket, amelyekhez az eszköz szinkronizálNTP Konfigurációs Parancsok (Privileged EXEC mód)
NTP Privileged
Eredeti hivatkozása
- clock set hh:mm:ss day month year
-->Beállítja az eszköz szoftveres óráját (nap és hónap sorrendje felcserélhető)- calendar set hh:mm:ss day month year
-->Beállítja az eszköz hardveres óráját (calendar)- clock update-calendar
-->Szinkronizálja a hardveres naptárat (calendar) a szoftveres óra (clock) idejéhez- clock read-calendar
-->Szinkronizálja a szoftveres órát (clock) a hardveres naptár (calendar) idejéhezNTP Konfigurációs Parancsok (Globális mód)
NTP Globális
Eredeti hivatkozása
- clock timezone timezone-name hours-offset [minutes-offset]
-->Beállítja az időzóna nevét és az óra (opcionálisan perc) eltolását- clock summer-time name recurring start end [offset]
-->Beállítja a nyári időszámítás (daylight saving time) automatikus szabályait
- (a start és end megköveteli a hetet (first, last vagy szám), a napot, a hónapot és az időpontot)
- ntp update-calendar
-->Frissíti a naptárat (hardveres órát) NTP segítségével- ntp server ip-address [prefer]
-->NTP szervert konfigurál a kliens számára a szinkronizáláshoz- ntp server ip-address key key-number
-->NTP szervert konfigurál hitelesítési kulcsszámmal kiegészítve- ntp peer ip-address
-->Symmetric active peering kapcsolatot épít ki egy másik NTP szerverrel- ntp peer ip-address key key-number
-->Symmetric active kapcsolatot épít ki hitelesítési kulccsal- ntp master [stratum-level]
-->Beállítja az eszközt NTP szerverként megadott stratum szinttel (alapértelmezett: stratum 8)- ntp source interface-id
-->Megadja az NTP üzenetek forrás interfészét- ntp authenticate
-->Engedélyezi az NTP hitelesítést- ntp authentication-key key-number md5 key/password
-->Létrehoz egy NTP hitelesítési kulcsot- ntp trusted-key key-number
-->Megbízhatónak (trusted) jelöl egy NTP kulcsot az eszközön
NTP Információk
Általános Információk
Minden eszköz kétféle órával rendelkezik: szoftveres (clock) és hardveres (calendar) órával.
- A szoftveres óra (Clock) digitálisan fut az eszköz operációs rendszerében.
- A hardveres óra (Calendar) az eszközbe épített belső fizikai óra áramkör.
- Cisco eszközök alapértelmezett időzónája a UTC (Coordinated Universal Time).
- A pontos idő legfontosabb oka a pontos naplóbejegyzések (logok) megléte a hibakereséshez (troubleshooting) (a
show loggingparanccsal).
A készülék naptára (calendar) akkor is megőrzi a dátumot és időt, ha az eszköz újraindul vagy áramkimaradás történik. A rendszer indulásakor a calendar inicializálja a szoftveres clock-ot. A hardveres naptár hátránya azonban, hogy idővel pontatlanná válik és elcsúszik (drift). Ezért alkalmazzák a Network Time Protocol (NTP) protokollt ezen probléma kiküszöbölésére.
Clock és Calendar Parancsok
Clock/Calendar Show Parancsok
show clock- Alapvető információkat mutat a szoftveres clock-ról.
- Megjeleníti a pontos időt.
- Néha egy csillag ( * ) jelenik meg előtte, ami jelzi, hogy az idő nem hitelesített forrásból származik (nem authoritative).
show clock detail- Az előző információk mellett megmutatja az időforrást is (alapértelmezetten a hardveres naptár).
Clock/Calendar Konfigurációs Parancsok
clock set HH:MM:SS DAY MONTH YEAR- Manuálisan állítja be a szoftveres clock idejét az eszközön.
calendar set HH:MM:SS DAY MONTH YEAR- Manuálisan állítja be a hardveres calendar idejét.
- Manuálisan állítja be a hardveres calendar idejét.
- Általában szinkronban akarjuk tartani a clock és calendar órákat, amit két paranccsal tehetünk meg:
clock update-calendar: szinkronizálja a calendar-t a clock idejéhez.clock read-calendar: szinkronizálja a clock-ot a calendar idejéhez.
clock timezone TIMEZONE-NAME HOURS-OFFSET [MINUTES-OFFSET]- Beállítja a kívánt időzónát.
clock summer-time TIMEZONE-NAME recurring START END [OFFSET]- Beállítja a nyári időszámítás (summer time / daylight saving time) szabályait.
- Az alapértelmezett eltolás 60 perc, de felülbírálható.
- (a start és end megköveteli a hetet (first, last vagy szám), a napot, a hónapot és az időpontot)
Network Time Protocol (NTP)
A Network Time Protocol (NTP) egy olyan hálózati protokoll, amely lehetővé teszi az órák automatikus szinkronizációját a hálózaton keresztül.
- A UDP 123-as portján kommunikál.
- Az NTP alapértelmezés szerint a UTC időzónát használja. A megfelelő helyi időzónát minden eszközön külön be kell állítani.
- Az NTP kliensek az NTP szerverektől kérik le a pontos időt.
- Egy hálózati eszköz egyidejűleg lehet NTP kliens és NTP szerver is.
Stratum Szintek
Egyes NTP szerverek megbízhatóbbak és pontosabbak másoknál. Ezt az úgynevezett stratum szint határozza meg, amely megadja az NTP szerver 'távolságát' a legfelső referencia órától (reference clock).
A stratum tartomány (1 - 16), de a hierarchia a (stratum 0) szinttől indul.
Referencia Órák (Reference Clocks)
A referencia óra általában egy rendkívül nagy pontosságú fizikai időmérő eszköz (pl. atomóra vagy GPS óra). Ezek az NTP hierarchiában stratum (0) besorolásúak.
- A közvetlenül a referencia órákhoz csatlakozó NTP szerverek a stratum 1 szintet kapják.
NTP Hierarchia
- A referencia órák: stratum (0).
- A Stratum (1) NTP szerverek a referencia óráktól kapják az időt.
- A Stratum (2) NTP szerverek a stratum (1) szerverektől szinkronizálnak.
- A Stratum (3) NTP szerverek a stratum (2) szerverektől szinkronizálnak.
- A Stratum (15) a maximális érvényes szint. A Stratum 16 már érvénytelennek/megbízhatatlannak minősül.
- Az azonos stratum szinten lévő eszközök egymással is peering kapcsolatot létesíthetnek symmetric active módban a pontosabb időszinkronizáció érdekében.
Cisco NTP működési módok
A Cisco eszközök háromféle NTP módban működhetnek:
- Server mód
- Client mód
- Symmetric Active mód
Stratum szint elnevezések
- Azokat az NTP szervereket, amelyek közvetlenül a referencia órától kapják az időt, 'elsődleges szervereknek' (primary servers) is nevezik.
- Azokat az NTP szervereket, amelyek más NTP szerverektől kapják az időt, 'másodlagos szervereknek' (secondary servers) nevezik. Ezek egyszerre működnek server és client módban.
NTP Konfigurációk
NTP Show Parancsok
show ntp associations- Megjeleníti a csatlakoztatott NTP szervereket
- Számos hasznos információt listáz:
- A csatlakoztatott NTP szerverek IP címeit állapotjelző szimbólummal
- A szerverek referencia óráit
- A szerverek stratum szintjét
show ntp status- Információkat mutat a futó NTP folyamatról
- Tartalmazza:
- Az aktuális eszköz saját stratum szintjét
- A szinkronizációhoz használt referencia NTP szerver IP címét
NTP Konfigurációs Parancsok
ntp server IP-ADDRESS [prefer]- Kapcsolatot létesít egy NTP szerverrel
ntp server IP-ADDRESS key KEY-NUMBER- Kapcsolatot létesít egy NTP szerverrel hitelesítési kulcs használatával
ntp peer IP-ADDRESS- Symmetric active kapcsolatot épít ki egy másik NTP eszközzel (mindkét eszköz azonos stratum szinten lesz)
ntp peer IP-ADDRESS key KEY-NUMBER- Peering kapcsolatot épít ki egy másik NTP eszközzel hitelesítési kulccsal
clock timezone TIMEZONE-NAME HOURS-OFFSET [MINUTES-OFFSET]- Beállítja az aktuális eszköz időzónáját
clock summer-time NAME recurring START END [OFFSET]- Beállítja a nyári időszámítás (summer time) szabályait az órához
- Alapértelmezett eltolás: 60 perc
- (a start és end megköveteli a hetet (first, last vagy szám), a napot, a hónapot és az időpontot)
ntp source INTERFACE-ID- Meghatározza a kimenő NTP üzenetek forrás interfészét
ntp master [STRATUM]- Az aktuális eszközt NTP szerverként állítja be választható stratum szinttel
- Ha nincs stratum szint megadva, alapértelmezés szerint 8 lesz (a show parancsokban 7 jelenik meg, mert a számozás 0-tól indul)
ntp authenticate- Bekapcsolja az NTP hitelesítést
ntp authentication-key KEY-NUMBER md5 KEY/PASSWORD- Létrehoz egy NTP kulcsszámot a hozzá tartozó jelszóval
ntp trusted-key KEY-NUMBER- Megbízhatónak jelöli az NTP kulcsot a hitelesítéshez