How do I synchronise my single Debian Linux desktop clock to network?

You will find lots of tutorials about how to setup NTP server. However if you just wanna synchronize single Linux desktop connected via A/DSL Internet connection use ntpdate command. It is very easy to configure and install ntp client. Following instructions are only compatible with Debian / Ubuntu Linux.

ADVERTISEMENTS

ntpdate client

ntpdate sets the local date and time by polling the Network Time Protocol (NTP) server(s) given as the server arguments to determine the correct time. It must be run as root on the local host. A number of samples are obtained from each of the servers specified and a subset of the NTP clock filter and selection algorithms are applied to select the best of these. Note that the accuracy and reliability of ntpdate depends on the number of servers, the number of polls each time it is run and the interval between runs.

Install ntpdate utility

ntpdate command sets the local date and time by polling the Network Time Protocol (NTP) server(s).

# apt-get install ntpdate

You are done by default /etc/default/ntpdate file is use to point pool.ntp.org server .

Allow access to NTP client via Iptables firewall

NTP client uses the udp port 123 to communicate with NTP server. Following rule opens/allows NTP client outgoing request:

# NTP outgoing client request
iptables -A output -p udp -s 192.168.1.1 --sport 1024:65535 -d 0/0  --dport 123 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A input -p udp -s 0/0 --sport 123 -d 192.168.1.1  --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT

Add above rules to your existing iptables script. Please note if you have more than 2-3 computers, then it is better idea to setup your own NTP server. I will write on ntpserver configuration later on.

For more information visit public ntp time server for everyone NTP pool website and read ntpdate man page.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
4 comments… add one
  • Anonymous Oct 25, 2005 @ 17:03

    hehe thanks a lot for NTP iptables rule was looking at google

  • Baskar Jan 25, 2007 @ 18:31

    Hi,
    you told that how to configure own ntp server.
    i want to configure my local host into ntp server
    for that what i have to do and how to sync with this server from client
    please send step by step configuration
    reply to my mail id namazhwar.baskar@idearc.com
    its urgent
    Thanks in advance

  • Jaison Lucas Sep 2, 2008 @ 10:05

    I want to sync my debain system time using NTP with my Windows 2003 server. Both are in same IP range and can be pinged.
    Please help me with the ntp.conf file.

  • woolie Jan 10, 2013 @ 15:30

    here’s a one-liner with “ntpclient” (if you can find it in your repos – it works on Slackware based Tiny core Linux):

    $ sudo ntpclient -s -c 1 -h ca.pool.ntp.org

    this will do a one-time synchronization.
    be sure to pick your CORRECT regional pool of time servers from:
    http://www.pool.ntp.org/zone

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.