NTP Management
This section describes the configuration model of the NTP server and provides examples of XML packets.
Data Model
The configuration model file matching NTP is ietf-system.yang and huawei-ntp.yang.
Object |
Description |
Value | Remarks |
---|---|---|---|
/ietf-system:system/ntp/enabled |
Enables or disables IPv4 NTP and IPv6 NTP. |
The value is of the Boolean type:
The default value is true. |
N/A |
/ietf-system:system/ntp/server/transport/udp/address |
Indicates the IP address of the NTP server. |
The value is a character string:
|
N/A |
/ietf-system:system/ntp/server/transport/udp/port |
Indicates the number of the port that sends NTP unicast packets. |
The value is an integer that ranges from 1025 to 65535. The default value is 123. |
N/A |
/ietf-system:system/ntp/server/transport/association-type |
Specifies the switch as an NTP peer or NTP server. |
The value is of the enumerated type:
|
Determine whether an IPv4 or IPv6 NTP peer or NTP server is configured based on the configured NTP server address. |
/ietf-system:system/ntp/server/transport/iburst |
Indicates that the device sends a burst of packets when receiving a response of an unreachable server. |
The value is of the Boolean type:
The default value is false. |
N/A |
/ietf-system:system/ntp/server/transport/prefer |
Indicates that the remote server is the preferentially selected server. |
The value is of the Boolean type:
The default value is false. |
N/A |
/ietf-system:system/huawei-ntp:ntp-server:ipv4-enable |
Indicates whether the IPv4 NTP function is enabled. |
The value is of the Boolean type:
The default value is true. |
N/A |
/ietf-system:system/huawei-ntp:ntp-server:ipv6-enable |
Indicates whether the IPv6 NTP function is enabled. |
The value is of the Boolean type:
The default value is true. |
N/A |
/ietf-system:system/ntp/huawei-ntp:source-interface-ipv6 |
Indicates the source interface through which the switch sends IPv6 NTP packets. |
The value is a character string in the format of interface-type interface-number. |
N/A |
Enabling the NTP Server Function
This section provides a sample of enabling the NTP server function using the edit-config method.
Operation |
XPATH |
---|---|
edit-config |
/ietf-system:system/huawei-ntp:ntp-server |
Data requirement
Item |
Data |
Description |
---|---|---|
IPv4 NTP server function |
true |
Enables the IPv4 NTP server function. |
IPv6 NTP server function |
false |
Disable the IPv6 NTP server function. |
Request example
<?xml version='1.0' encoding='UTF-8'?> <rpc message-id="1" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <edit-config> <target> <running/> </target> <config> <sys:system xmlns:sys="urn:ietf:params:xml:ns:yang:ietf-system"> <huawei-ntp:ntp-server xmlns:huawei-ntp="urn:huawei:params:xml:ns:yang:huawei-ntp"> <huawei-ntp:ipv4-enable>true</huawei-ntp:ipv4-enable> <huawei-ntp:ipv6-enable>false</huawei-ntp:ipv6-enable> </huawei-ntp:ntp-server> </sys:system> </config> </edit-config> </rpc>
Response example
Sample of successful response
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1"> <ok/> </rpc-reply>
Sample of failed response
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1"> <rpc-error> <error-type>application</error-type> <error-tag>operation-failed</error-tag> <error-severity>error</error-severity> <error-message>parse rpc config error.</error-message> </rpc-error> </rpc-reply>
Configuring NTP
This section describes provides a sample of configuring NTP using the edit-config method.
Operation |
XPATH |
---|---|
edit-config:create |
/ietf-system:system/ntp |
Data Requirements
Item |
Data |
Description |
---|---|---|
NTP status |
true |
Configure the NTP server. |
NTP server name |
t1 |
|
NTP server address |
10.1.1.1 |
|
NTP server port number |
1025 |
|
Specifying the type as NTP server |
server |
|
Indicating that the device sends a burst of packets when receiving a response of an unreachable server |
true |
|
Specifying the remote server as the preferentially selected server |
true |
Request Example
<?xml version='1.0' encoding='UTF-8'?> <rpc message-id="1" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <edit-config> <target> <running/> </target> <config> <sys:system xmlns:sys="urn:ietf:params:xml:ns:yang:ietf-system" xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" xc:operation="replace"> <sys:ntp> <sys:enabled>true</sys:enabled> <sys:server> <sys:name>t1</sys:name> <sys:udp> <sys:address>10.1.1.1</sys:address> <sys:port>1025</sys:port> </sys:udp> <sys:association-type>server</sys:association-type> <sys:iburst>true</sys:iburst> <sys:prefer>true</sys:prefer> </sys:server> </sys:ntp> </sys:system> </config> </edit-config> </rpc>
Response Example
Sample of successful response
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="35"> <ok/> </rpc-reply>
Sample of failed response
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="36"> <rpc-error> <error-type>application</error-type> <error-tag>operation-failed</error-tag> <error-severity>error</error-severity> <error-message>parse rpc config error.</error-message> </rpc-error> </rpc-reply>
Configuring an IPv6 NTP Source Interface
This section provides a sample of configuring an IPv6 NTP source interface using the edit-config method.
Operation |
XPATH |
---|---|
edit-config |
/ietf-system:system/ntp/huawei-ntp:source-interface-ipv6 |
Data requirement
Item |
Data |
Description |
---|---|---|
Set an IPv6 NTP source interface |
Vlanif1 |
Ensure that this interface exists and has been configured on the device. For details about the configuration, see Configuring Basic Attributes of an Interface. |
Request example
<?xml version='1.0' encoding='UTF-8'?> <rpc message-id="6" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <edit-config> <target> <running/> </target> <config> <sys:system xmlns:sys="urn:ietf:params:xml:ns:yang:ietf-system"> <sys:ntp> <huawei-ntp:source-interface-ipv6 xmlns:huawei-ntp="urn:huawei:params:xml:ns:yang:huawei-ntp">Vlanif1</huawei-ntp:source-interface-ipv6> </sys:ntp> </sys:system> </config> </edit-config> </rpc>
Response example
Sample of successful response
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1"> <ok/> </rpc-reply>
Sample of failed response
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1"> <rpc-error> <error-type>application</error-type> <error-tag>operation-failed</error-tag> <error-severity>error</error-severity> <error-message>parse rpc config error.</error-message> </rpc-error> </rpc-reply>