Configuration example for NTP client/server mode with authentication

Network requirements

As shown in Figure 42, perform the following tasks:

Figure 42: Network diagram

Configuration procedure

  1. Assign an IP address to each interface, and make sure Device A and Device B can reach each other, as shown in Figure 42. (Details not shown.)

  2. Configure Device A:

    # Enable the NTP service.

    <DeviceA> system-view
    [DeviceA] ntp-service enable
    

    # Specify the local clock as the reference source, with stratum level 2.

    [DeviceA] ntp-service refclock-master 2
    
  3. Configure Device B:

    # Enable the NTP service.

    <DeviceB> system-view
    [DeviceB] ntp-service enable
    

    # Enable NTP authentication on Device B.

    [DeviceB] ntp-service authentication enable
    

    # Set an authentication key, and input the key in plain text.

    [DeviceB] ntp-service authentication-keyid 42 authentication-mode md5 simple aNiceKey
    

    # Specify the key as a trusted key.

    [DeviceB] ntp-service reliable authentication-keyid 42
    

    # Specify Device A as the NTP server of Device B, and associate the server with key 42.

    [DeviceB] ntp-service unicast-server 1.0.1.11 authentication-keyid 42
    

    Before Device B can synchronize its clock to that of Device A, enable NTP authentication for Device A.

  4. Configure NTP authentication on Device A:

    # Enable NTP authentication.

    [DeviceA] ntp-service authentication enable
    

    # Set an authentication key, and input the key in plain text.

    [DeviceA] ntp-service authentication-keyid 42 authentication-mode md5 simple aNiceKey
    

    # Specify the key as a trusted key.

    [DeviceA] ntp-service reliable authentication-keyid 42
    
  5. Verify the configuration:

    # Verify that Device B has synchronized to Device A, and the clock stratum level is 3 on Device B and 2 on Device A.

    [DeviceB] display ntp-service status
     Clock status: synchronized
     Clock stratum: 3
     System peer: 1.0.1.11
     Local mode: client
     Reference clock ID: 1.0.1.11
     Leap indicator: 00
     Clock jitter: 0.005096 s
     Stability: 0.000 pps
     Clock precision: 2^-18
     Root delay: 0.00655 ms
     Root dispersion: 1.15869 ms
     Reference time: d0c62687.ab1bba7d  Wed, Dec 29 2010 21:28:39.668
    

    # Verify that an IPv4 NTP association has been established between Device B and Device A.

    [DeviceB] display ntp-service sessions
           source          reference       stra reach poll  now offset  delay disper
    ********************************************************************************
     [1245]1.0.1.11        127.127.1.0        2     1   64  519   -0.0 0.0065    0.0
    Notes: 1 source(master),2 source(peer),3 selected,4 candidate,5 configured.
     Total sessions: 1