{"id":12754,"date":"2022-05-14T15:51:46","date_gmt":"2022-05-14T12:51:46","guid":{"rendered":"https:\/\/kifarunix.com\/?p=12754"},"modified":"2024-03-09T13:04:27","modified_gmt":"2024-03-09T10:04:27","slug":"install-and-configure-ntp-client-on-ubuntu-debian-systems","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-configure-ntp-client-on-ubuntu-debian-systems\/","title":{"rendered":"Install and Configure NTP Client on Ubuntu\/Debian systems"},"content":{"rendered":"\n

Follow through this tutorial to quickly learn how to install and configure NTP<\/a> Client on Ubuntu\/Debian systems.<\/p>\n\n\n\n

Install and Configure NTP Client on Ubuntu\/Debian systems<\/h2>\n\n\n\n

We will discuss three ways in which you can install and configure NTP Client.<\/p>\n\n\n\n

    \n
  1. Synchronize time with Systemd-timesyncd Service<\/a><\/li>\n\n\n\n
  2. Synchronize time using ntpdate command<\/a><\/li>\n\n\n\n
  3. Synchronize time using NTP service<\/a><\/li>\n<\/ol>\n\n\n\n

    The guide is based on the NTP servers we configured as per our previous guides on how to configure NTP Server<\/a>.<\/p>\n\n\n\n

    Synchronizing using systemd timesyncd service<\/h3>\n\n\n\n

    In an Ubuntu\/Debian systems, an NTP Client, systemd-timesyncd.service,<\/code><\/strong> is running by default.<\/p>\n\n\n\n

    Edit the file \/etc\/systemd\/timesyncd.conf<\/code><\/strong> and add the address for your NTP server by adding such an entry at the end of the file:<\/p>\n\n\n\n

    vim \/etc\/systemd\/timesyncd.conf<\/code><\/pre>\n\n\n\n
    NTP=192.168.59.38<\/code><\/pre>\n\n\n\n

    Where 192.168.56.103<\/code> is the IP address of configured NTP server.<\/p>\n\n\n\n

    You can also set FallBack by uncommenting the line below;<\/p>\n\n\n\n

    FallbackNTP=ntp.ubuntu.com<\/code><\/pre>\n\n\n\n

    Restart systemd-timesyncd<\/em> NTP client service:<\/p>\n\n\n\n

    sudo systemctl restart systemd-timesyncd<\/code><\/pre>\n\n\n\n

    Confirm the status of status that it is now synchronized with the configured NTP server.<\/p>\n\n\n\n

     systemctl status systemd-timesyncd<\/code><\/pre>\n\n\n\n

    Output:<\/p>\n\n\n\n

    \u25cf systemd-timesyncd.service - Network Time Synchronization\n     Loaded: loaded (\/lib\/systemd\/system\/systemd-timesyncd.service; enabled; vendor preset: enabled)\n     Active: active (running) since Sat 2022-05-14 12:10:14 UTC; 2s ago\n       Docs: man:systemd-timesyncd.service(8)\n   Main PID: 1166 (systemd-timesyn)\n     Status: \"Initial synchronization to time server 192.168.59.38:123 (192.168.59.38).\"\n      Tasks: 2 (limit: 2241)\n     Memory: 1.2M\n        CPU: 73ms\n     CGroup: \/system.slice\/systemd-timesyncd.service\n             \u2514\u25001166 \/lib\/systemd\/systemd-timesyncd\n\nMay 14 12:10:14 jellyfish systemd[1]: Starting Network Time Synchronization...\nMay 14 12:10:14 jellyfish systemd[1]: Started Network Time Synchronization.\nMay 14 12:10:14 jellyfish systemd-timesyncd[1166]: Initial synchronization to time server 192.168.59.38:123 (192.168.59.38).\n<\/code><\/pre>\n\n\n\n
    timedatectl status<\/code><\/pre>\n\n\n\n
                   Local time: Sat 2022-05-14 12:10:53 UTC\n           Universal time: Sat 2022-05-14 12:10:53 UTC\n                 RTC time: Sat 2022-05-14 12:10:53\n                Time zone: Etc\/UTC (UTC, +0000)\nSystem clock synchronized: yes\n              NTP service: active\n          RTC in local TZ: no\n<\/code><\/pre>\n\n\n\n

    Using ntpdate<\/code> to Synchronize Client Systems’ Time<\/h3>\n\n\n\n

    Optionally the ntpdate<\/code> command can be used to manually synchronize client system time with NTP server. This guide uses Ubuntu 18.04 as the client.<\/p>\n\n\n\n

    Install ntpdate<\/code> package, if not already installed.<\/p>\n\n\n\n

    sudo apt install ntpdate -y<\/code><\/pre>\n\n\n\n

    NOTE:<\/strong> Ensure that Client and NTP Server can communicate. You can use nc command to verify NTP server port connection.<\/p>\n\n\n\n

    For example;<\/p>\n\n\n\n

    nc -uvz 192.168.59.38 123<\/code><\/pre>\n\n\n\n

    Sample output;<\/p>\n\n\n\n

    Connection to 192.168.59.38 123 port [udp\/ntp] succeeded!<\/code><\/pre>\n\n\n\n

    Next, use ntpdate Command to Query Time Service. The ntpdate<\/code> command can be uses to query time service from an NTP server by running the command:<\/p>\n\n\n\n

    sudo ntpdate 192.168.59.38<\/code><\/pre>\n\n\n\n

    The output shows the time offset between the two systems.<\/p>\n\n\n\n

    14 May 12:17:28 ntpdate[1516]: adjust time server 192.168.59.38 offset -0.019108 sec<\/code><\/pre>\n\n\n\n

    Synchronize time Automatically Using NTP<\/h3>\n\n\n\n

    NTP client can automatically be configured to query NTP server by using the NTPd daemon.<\/p>\n\n\n\n

    Install NTP on Ubuntu\/Debian<\/p>\n\n\n\n

    sudo apt install ntp -y<\/code><\/pre>\n\n\n\n

    The installation of NTP will mask the systemd-timesyncd.service<\/code><\/strong>.<\/p>\n\n\n\n

    The NTP service is set to run by default after installation. First check if the client is synchronized with NTP:<\/p>\n\n\n\n

    timedatectl<\/code><\/pre>\n\n\n\n

    The output will show if the system clock is synchronized or not. The output below clearly indicates time is not synced to any server.<\/p>\n\n\n\n

                   Local time: Sat 2022-05-14 12:20:04 UTC\n           Universal time: Sat 2022-05-14 12:20:04 UTC\n                 RTC time: Sat 2022-05-14 12:20:04\n                Time zone: Etc\/UTC (UTC, +0000)\nSystem clock synchronized: no\n              NTP service: n\/a\n          RTC in local TZ: no<\/code><\/pre>\n\n\n\n

    To configure the NTP client to synchronize time from your NTP server, edit the ntp configuration file:<\/p>\n\n\n\n

     sudo vim \/etc\/ntp.conf <\/code><\/pre>\n\n\n\n

    Replace public NTP pool servers with your server.<\/p>\n\n\n\n

    #pool 0.ubuntu.pool.ntp.org iburst\n#pool 1.ubuntu.pool.ntp.org iburst\n#pool 2.ubuntu.pool.ntp.org iburst\n#pool 3.ubuntu.pool.ntp.org iburst\n\npool 192.168.59.38 iburst<\/code><\/pre>\n\n\n\n

    Ideally the server can be added without commenting out the default NTP servers by making it the preferred reference clock using the prefer<\/strong> option:<\/p>\n\n\n\n

    pool 192.168.59.38 prefer iburst<\/code><\/pre>\n\n\n\n

    Save the configuration file and restart ntp.<\/p>\n\n\n\n

     sudo systemctl restart ntp<\/code><\/pre>\n\n\n\n

    The client is now successfully configured to sychronize system time with NTP server. This can be verified by running the command:<\/p>\n\n\n\n

    ntpq -p<\/code><\/pre>\n\n\n\n
         remote           refid      st t when poll reach   delay   offset  jitter\n==============================================================================\n 192.168.59.38   .POOL.          16 p    -   64    0    0.000   +0.000   0.000\n ntp.ubuntu.com  .POOL.          16 p    -   64    0    0.000   +0.000   0.000\n*192.168.59.38   91.189.89.198    3 u    2   64    1    1.732  +16.240   0.089\n<\/strong> chilipepper.can 17.253.34.251    2 u    8   64    1  255.060  -41.243   0.000\n pugot.canonical 17.253.108.125   2 u    5   64    1  171.300   -0.021   0.000\n golem.canonical 134.71.66.21     2 u    4   64    1  263.212  -45.093   0.000\n alphyn.canonica 194.58.200.20    2 u    5   64    1  251.289   +2.991   0.000\n<\/code><\/pre>\n\n\n\n

    From the output we can see NTP server (192.168.56.103) as the time synchronization host\/source in the queue.<\/p>\n\n\n\n

    Confirm NTP service is set to start at boot time:<\/p>\n\n\n\n

    systemctl is-enabled ntp<\/code><\/pre>\n\n\n\n

    To enable NTP service to start at boot time, just in case is not enabled, then you would run the command:<\/p>\n\n\n\n

    systemctl enable ntp<\/code><\/pre>\n\n\n\n

    Great, your NTP Clients should now be able to query the time services from your NTP Server.<\/p>\n\n\n\n

    That brings us to the end of the guide on how install and setup NTP Client on Ubuntu\/Debian.<\/p>\n","protected":false},"excerpt":{"rendered":"

    Follow through this tutorial to quickly learn how to install and configure NTP Client on Ubuntu\/Debian systems. Install and Configure NTP Client on Ubuntu\/Debian systems<\/p>\n","protected":false},"author":1,"featured_media":12756,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121],"tags":[5153,5152,5156,5154,5157,5155],"class_list":["post-12754","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-install-ntp-client-on-debian","tag-install-ntp-client-on-ubuntu","tag-install-ntp-on-debian","tag-ntpdate-client-ubuntu","tag-synchronize-time-to-ntp","tag-systemd-timesyncd-service","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/12754"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=12754"}],"version-history":[{"count":2,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/12754\/revisions"}],"predecessor-version":[{"id":20514,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/12754\/revisions\/20514"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/12756"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=12754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=12754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=12754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}