跳转到内容
Ask AI

Time Configuration

此内容尚不支持你的语言。

Table 1 Time View

CommandPurpose
show clockDisplay the time zone and time of the system.
show supported-timezonesDisplay the time zones the system supports.

[Command] show clock

[Purpose] Display the time zone and time of the system.

[View] Privileged User View

[Use Cases]

sonic# show clock
2024-10-19 09:19:01 Tuesday UTC+0000

[Command] show supported-timezones

[Purpose] Display the time zones the system supports.

[View] Privileged User View

[Use Cases]

sonic# show supported-timezones

Table 2 Time Config

CommandPurpose
clock datetime date timeSet the system time.
clock timezone zoneSet the system time zone.

[Command] clock datetime date time

[Purpose] Set the system time.

[Parameters]

ParameterDescription
dateIn YY-MM-DD format.
timeIn HH:MM:SS format.

[View] Global Configuration View

[Use Cases]

sonic# configure
sonic(config)# clock datetime 2022-02-22 20:30:30

[Command] clock timezone zone

[Purpose] Set the system time zone.

[Parameters]

ParameterDescription
zoneThe default time zone is UTC.

[View] Global Configuration View

[Notes] Run command no clock timezone to restore the system time zone to default.

[Use Cases]

sonic# configure
sonic(config)# clock timezone Asia/Shang

NTP(Network Time Protocol)is a protocol used to synchronize the time of individual machines on a network.

Table 3 NTP View

CommandPurpose
show ntpDisplay NTP status.
show ntp serverDisplay configuration of NTP Server.
show ntp globalDisplay global configuration of NTP.
show ntp authentication-keyidDisplay NTP authentication Key.

[Command] show ntp

[Purpose] Display NTP status.

[View] Privileged User View

[Use Cases]

sonic# show ntp
remote refid st t when poll reach delay offset jitter
==============================================================================
*10.250.0.240 203.107.6.88 3 u 46 64 377 0.165 10.575 3.198

[Command] show ntp server

[Purpose] Display configuration of NTP Server.

[View] Privileged User View

[Use Cases]

sonic# show ntp server
SERVER STATE TYPE KEY
------------ ------- ------ -----
10.250.0.242 enabled server -
10.250.0.243 enabled server -

[Command] show ntp global

[Purpose] Display global configuration of NTP.

[View] Privileged User View

[Use Cases]

sonic# show ntp global
State: enabled
Authentication: disabled
VRF: default

[Command] show ntp global

[Purpose] Display NTP authentication key.

[View] Privileged User View

[Use Cases]

sonic# show ntp authentication-keyid
KEY ID TYPE TRUSTED
-------- ------ ---------
1 md5 yes

Table 4 NTP Config

CommandPurpose
ntp enableEnable NTP automatic synchronization service.
ntp server server-ip [authentication-keyid]Specify a NTP server.
ntp source_interface {mgmt|loopback|ethernet|link-aggregation|vlan} interface_nameSpecify the source interface for NTP.
ntp synchronize [unprivileged] server-ipSynchronise manually from an NTP server.
ntp synchronize jumpEnable NTP jump synchronization.
ntp vrf {default|mgmt}Specify the VRF where the NTP source interface is located.
ntp authentication enableEnable NTP authentication.
ntp authentication-keyid key_id {md5|sha1|sha256|sha384|sha512}Add NTP key.

[Command] ntp enable

[Purpose] Enable NTP automatic synchronization service.

[View] Global Configuration View

[Notes] Run command no ntp enable to disable NTP.

[Use Cases]

sonic(config)# ntp enable

[Command] ntp server server-ip [authentication-keyid]

[Purpose] Specify a NTP server.

[Parameters]

ParameterDescription
server-ip|NTP Server IP address or domain name.-
authentication-keyid|-

[View] Global Configuration View

[Notes] Run command no ntp server server-ip to delete NTP server configuration.

[Use Cases]

sonic(config)# ntp server 10.250.0.242
Section titled “ntp source_interface {mgmt|loopback|ethernet|link-aggregation|vlan}”

[Command] ntp source_interface {mgmt|loopback|ethernet|link-aggregation|vlan} interface_name

[Purpose] Specify the source interface for NTP.

[Parameters]

ParameterDescription
interface_nameInterface name (eg.0/1). When specify mgmt the interface name is 0.

[View] Global Configuration View

[Notes] Run command no ntp source_interface to delete NTP source interface configuration.

[Use Cases]

sonic(config)# ntp source_interface mgmt 0
sonic(config)# ntp source_interface loopback 0

[Command] **ntp synchronize ** [unprivileged] server-ip

[Purpose] Synchronise manually from an NTP server.

[Parameters]

ParameterDescription
unprivilegedThis parameter should be enabled when the NTP auto-sync service is already running so that manual synchronisation can be performed over an unprivileged port.
server-ipSpecify NTP server IP address.

[View] Global Configuration View

[Notes] When you run this command, the system will immediately synchronise to NTP server time. This command is valid for a single time and will not be saved to running-config.

[Use Cases]

sonic(config)# ntp synchronize unprivileged 10.250.0.243
18 Nov 20:10:52 ntpdate[385097]: adjust time server 10.250.0.243 offset -0.009762 sec

[Command] ntp synchronize jump

[Purpose] Enable NTP jump synchronization.

[View] Global Configuration View

[Notes] With this command set, the system will make a time adjustment with a large offset every time the process restarts. By default a jump synchronization will be made only when the offset is over 600 seconds.

[Use Cases]

sonic(config)# ntp synchronize jump

[Command] ntp vrf {default|mgmt}

[Purpose] Specify the VRF where the NTP source interface is located.

[View] Global Configuration View

[Notes] When you have set the management port as NTP source interface as and enabled management VRF, please specify mgmt as NTP VRF. By default, the NTP VRF is default VRF.

[Use Cases]

sonic(config)# ntp vrf default
sonic(config)# ntp vrf mgmt

[Command] ntp authentication enable

[Purpose] Enable NTP authentication

[View] Global Configuration View

[Notes] Run command no ntp authentication enable to disable NTP authentication

[Use Cases]

sonic(config)# ntp authentication enable

[Command] ntp authentication-keyid key_id {md5|sha1|sha256|sha384|sha512}

[Purpose] Add NTP key.

[View] Global Configuration View

[Notes] Run command no ntp authentication-keyid key_id to delete NTP key

[Use Cases]

sonic(config)# ntp authentication-keyid 1 md5
Please enter authentication key value:
sonic(config)#