Configuring time synchronization via the PTP protocol in CentOS

To configure time synchronization via PTP in CentOS:

  1. Open the operating system console.
  2. Check whether the linuxptp package is installed. To do so, enter the following command:

    dnf list installed

  3. If the linuxptp package is not installed, enter the following commands to add the package and enable the ptp4l time synchronization service:

    sudo dnf install linuxptp
    sudo systemctl enable ptp4l
    sudo systemctl start ptp4l

  4. Open the service configuration file. To do so, enter the following command:

    sudo mcedit /etc/ptp4l.conf

  5. Enter 1 for the slaveOnly parameter.
  6. Save and close the configuration file.
  7. Open the file containing the general settings for the service. To do so, enter the following command:

    sudo mcedit /etc/sysconfig/ptp4l

  8. In the OPTIONS string, specify the parameters as follows:

    OPTIONS="-f <configuration file> -i <interface name> -S -s"

    where:

    • -f <configuration file> – default name and full path of the configuration file.
    • -i <interface name> – name of the network interface that is used for time synchronization.
    • -S – enables use of software-based timestamps. You can skip this parameter if you want to use hardware-based timestamps. However, first make sure that the equipment supports this capability.
    • -s – enables subordinate time synchronization.

    Example OPTIONS string:

    OPTIONS="-f /etc/ptp4l.conf -i eth0 -S -s"

  9. Save and close the general settings file.
  10. Allow use of ports 319 and 320 in the firewall for the UDP protocol. To do so, enter the following commands:

    sudo firewall-cmd --permanent --add-port=319/udp
    sudo firewall-cmd --permanent --add-port=320/udp

  11. Restart the firewall service. To do so, enter the following command:

    sudo systemctl restart firewalld

  12. Restart the time synchronization service. To do so, enter the following command:

    sudo systemctl restart ptp4l

Page top